Compare commits
47
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c02c982853 | ||
|
|
0d590f912a | ||
|
|
d89337946e | ||
|
|
416cd51298 | ||
|
|
dd4efda8d5 | ||
|
|
7126c19714 | ||
|
|
19a88e347b | ||
|
|
7719255851 | ||
|
|
7cd4b9ca59 | ||
|
|
9702ae65b2 | ||
|
|
5a2c4b1ed8 | ||
|
|
359c587a41 | ||
|
|
b801aae9ab | ||
|
|
342ef94868 | ||
|
|
f0d39d3248 | ||
|
|
0111a2efee | ||
|
|
5b66a9656f | ||
|
|
c9467af711 | ||
|
|
9c201a2b98 | ||
|
|
d3fa3e5db8 | ||
|
|
9afd9baed9 | ||
|
|
fb4c13c4ef | ||
|
|
f9e14ae7bc | ||
|
|
fed250e96c | ||
|
|
9fb79b4ea8 | ||
|
|
33cb7143c6 | ||
|
|
f630f7fa8d | ||
|
|
09d3397238 | ||
|
|
0fdbc36f58 | ||
|
|
9bd1371a04 | ||
|
|
34edb51e7e | ||
|
|
a784252a15 | ||
|
|
19a3b76fba | ||
|
|
e26e54fb83 | ||
|
|
aef4b58c64 | ||
|
|
18ffac05d8 | ||
|
|
f7e7d201b9 | ||
|
|
6337911bbc | ||
|
|
8df7cce6e1 | ||
|
|
6ae455b869 | ||
|
|
8c236e7119 | ||
|
|
521e2a3c8a | ||
|
|
3b459e152d | ||
|
|
93f280d257 | ||
|
|
1be68e5723 | ||
|
|
d9a6ff01e0 | ||
|
|
f48f626bad |
@@ -1,11 +0,0 @@
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_size = 4
|
||||
tab_width = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
max_line_length = 160
|
||||
|
||||
[*.{c,h,cpp,hpp,inl}]
|
||||
charset = latin1
|
||||
@@ -1,34 +0,0 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
|
||||
|
||||
# Whitespace rules
|
||||
# strict (no trailing, no tabs)
|
||||
*.cpp whitespace=trailing-space,space-before-tab,tab-in-indent,cr-at-eol
|
||||
*.h whitespace=trailing-space,space-before-tab,tab-in-indent,cr-at-eol
|
||||
|
||||
# normal (no trailing)
|
||||
*.sql whitespace=trailing-space,space-before-tab,cr-at-eol
|
||||
*.txt whitespace=trailing-space,space-before-tab,cr-at-eol
|
||||
|
||||
# special files which must ignore whitespace
|
||||
*.patch whitespace=-trailing-space eol=lf
|
||||
*.diff whitespace=-trailing-space eol=lf
|
||||
|
||||
# Standard to msysgit
|
||||
*.doc diff=astextplain
|
||||
*.DOC diff=astextplain
|
||||
*.docx diff=astextplain
|
||||
*.DOCX diff=astextplain
|
||||
*.dot diff=astextplain
|
||||
*.DOT diff=astextplain
|
||||
*.pdf diff=astextplain
|
||||
*.PDF diff=astextplain
|
||||
*.rtf diff=astextplain
|
||||
*.RTF diff=astextplain
|
||||
|
||||
# Ignore sql/* files
|
||||
sql/* linguist-documentation
|
||||
|
||||
# Always LF endings
|
||||
*.sh eol=lf
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
|
||||
build*/
|
||||
.directory
|
||||
.mailmap
|
||||
*.orig
|
||||
*.rej
|
||||
*~
|
||||
.hg/
|
||||
*.kdev*
|
||||
.DS_Store
|
||||
CMakeLists.txt.user
|
||||
*.bak
|
||||
*.patch
|
||||
*.diff
|
||||
*.REMOTE.*
|
||||
*.BACKUP.*
|
||||
*.BASE.*
|
||||
*.LOCAL.*
|
||||
nbproject/*
|
||||
.idea/*
|
||||
.browse.VC*
|
||||
.vscode
|
||||
cmake-build-*/*
|
||||
.vs
|
||||
*.user
|
||||
@@ -1,99 +0,0 @@
|
||||
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
|
||||
# add this options before PROJECT keyword
|
||||
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
|
||||
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
|
||||
|
||||
# Set projectname (must be done AFTER setting configurationtypes)
|
||||
project(TrinityCore)
|
||||
|
||||
if(POLICY CMP0144)
|
||||
cmake_policy(SET CMP0144 NEW) # find_package() uses upper-case <PACKAGENAME>_ROOT variables
|
||||
endif()
|
||||
|
||||
if(POLICY CMP0153)
|
||||
cmake_policy(SET CMP0153 NEW) # The exec_program() command should not be called
|
||||
endif()
|
||||
|
||||
# Set RPATH-handing (CMake parameters)
|
||||
set(CMAKE_SKIP_BUILD_RPATH 0)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH 0)
|
||||
list(APPEND CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH 1)
|
||||
|
||||
# set macro-directory
|
||||
list(APPEND CMAKE_MODULE_PATH
|
||||
"${CMAKE_SOURCE_DIR}/cmake/macros")
|
||||
|
||||
# build in Release-mode by default if not explicitly set
|
||||
if(CMAKE_GENERATOR STREQUAL "Ninja Multi-Config")
|
||||
set(CMAKE_DEFAULT_BUILD_TYPE "RelWithDebInfo" CACHE INTERNAL "")
|
||||
endif()
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
include(CheckCXXSourceRuns)
|
||||
include(CheckIncludeFiles)
|
||||
include(ConfigureScripts)
|
||||
|
||||
# set default buildoptions and print them
|
||||
include(cmake/options.cmake)
|
||||
|
||||
# turn off PCH totally if enabled (hidden setting, mainly for devs)
|
||||
if(NOPCH)
|
||||
set(USE_COREPCH 0)
|
||||
set(USE_SCRIPTPCH 0)
|
||||
endif()
|
||||
|
||||
include(ConfigureBaseTargets)
|
||||
include(CheckPlatform)
|
||||
|
||||
include(GroupSources)
|
||||
include(AutoCollect)
|
||||
|
||||
find_package(PCHSupport)
|
||||
|
||||
if(NOT WITHOUT_GIT)
|
||||
find_package(Git 1.7)
|
||||
endif()
|
||||
|
||||
# find mysql client binary (needed by genrev)
|
||||
find_package(MySQL OPTIONAL_COMPONENTS binary)
|
||||
|
||||
# Find revision ID and hash of the sourcetree
|
||||
include(cmake/genrev.cmake)
|
||||
|
||||
# print out the results before continuing
|
||||
include(cmake/showoptions.cmake)
|
||||
|
||||
# add dependencies
|
||||
add_subdirectory(dep)
|
||||
|
||||
# add core sources
|
||||
add_subdirectory(src)
|
||||
|
||||
include(CTest)
|
||||
if(BUILD_TESTING)
|
||||
list(APPEND CMAKE_MODULE_PATH
|
||||
"${Catch2_SOURCE_DIR}/contrib")
|
||||
include(Catch)
|
||||
|
||||
add_subdirectory(tests)
|
||||
|
||||
# Catch cmakefile messes with our settings we explicitly leave up to the user
|
||||
# restore user preference
|
||||
if (NOT WITH_SOURCE_TREE STREQUAL "hierarchical-folders")
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS OFF)
|
||||
endif()
|
||||
endif()
|
||||
@@ -1,23 +0,0 @@
|
||||
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
# This file is run right before CMake starts configuring the sourcetree
|
||||
|
||||
# Example: Force CMAKE_INSTALL_PREFIX to be preloaded with something before
|
||||
# doing the actual first "configure"-part - allows for hardforcing
|
||||
# destinations elsewhere in the CMake buildsystem (commented out on purpose)
|
||||
|
||||
# Override CMAKE_INSTALL_PREFIX on Windows platforms
|
||||
#if(WIN32)
|
||||
# if(NOT CYGWIN)
|
||||
# set(CMAKE_INSTALL_PREFIX
|
||||
# "" CACHE PATH "Default install path")
|
||||
# endif()
|
||||
#endif()
|
||||
@@ -1,39 +0,0 @@
|
||||
# Introduction:
|
||||
|
||||
WowCommunity Project is a World of Warcraft blizzlike design based on TrinityCore, which is based on the Midnight Expansion version 12.1.0.69814.
|
||||
|
||||
|
||||
# Developers:
|
||||
|
||||
- [Burkinc](https://github.com/Burkinc)
|
||||
|
||||
- [Céfiro_Caecias](http://github.com/Cefiro-Caecias)
|
||||
|
||||
- [Sistemas](https://github.com/SistemasCPU)
|
||||
|
||||
- [Thordekk](https://github.com/Thordekk)
|
||||
|
||||
|
||||
# Tools/Herramientas:
|
||||
|
||||
01a.- [Git Extensions v.6.0.5.18375](https://sourceforge.net/projects/gitextensions/)
|
||||
|
||||
01b.- [Git for Windows v.2.53.0 x64](https://gitforwindows.org/)
|
||||
|
||||
01c.- [Windows Desktop Runtime v.9.0.13 x64](https://dotnet.microsoft.com/es-es/download/dotnet/thank-you/runtime-desktop-9.0.13-windows-x64-installer)
|
||||
|
||||
02.- [Visual Studio Community 2022 v.17.14.40](https://www.junian.net/dev/visual-studio-community-download-links/)
|
||||
|
||||
03a.- [Python v.3.15.0a6 x64](https://www.python.org/downloads/)
|
||||
|
||||
03b.- [MySQL Community Server v.8.4.8 LTS x86-x64](https://dev.mysql.com/downloads/mysql/)
|
||||
|
||||
04.- [Boost v.1.89.0 msvc 14.3 x64 (or 1.91)](https://www.boost.org/)
|
||||
|
||||
05.- [CMake v.3.30.0-rc1 x86-x64](https://cmake.org/download/)
|
||||
|
||||
06.- [OpenSSL v.3.6.1 x64 (or 4.0.0)](https://slproweb.com/products/Win32OpenSSL.html)
|
||||
|
||||
07.- [SQLyog Community Edition v.13.3.1 x64](https://github.com/webyog/sqlyog-community/wiki/Downloads)
|
||||
|
||||
08.- [HeidiSQL v.12.21.0.7344 x64](https://www.heidisql.com/download.php)
|
||||
@@ -1,42 +0,0 @@
|
||||
version: 1.0.{build}
|
||||
image: Visual Studio 2022
|
||||
clone_depth: 1
|
||||
init:
|
||||
- ps: ''
|
||||
environment:
|
||||
BOOST_ROOT: C:\Libraries\boost_1_85_0
|
||||
MYSQL_ROOT_DIR: C:\Program Files\MySQL\MySQL Server 8.0
|
||||
OPENSSL_ROOT_DIR: C:\OpenSSL-v32-Win64
|
||||
build_script:
|
||||
- cmd: >-
|
||||
git config user.email "[email protected]" && git config user.name "AppVeyor"
|
||||
|
||||
cmake -S . -B .\build -G"Visual Studio 17 2022" -A x64 -DSCRIPTS=dynamic -DWITH_WARNINGS_AS_ERRORS=ON -DTOOLS=ON
|
||||
|
||||
cd build
|
||||
|
||||
"C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe" /nologo /m:2 /p:Configuration=RelWithDebInfo /p:Platform="X64" /verbosity:minimal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" "TrinityCore.sln"
|
||||
|
||||
cd bin\RelWithDebInfo\
|
||||
|
||||
copy "%MYSQL_ROOT_DIR%\lib\libmysql.dll" libmysql.dll
|
||||
|
||||
copy "%OPENSSL_ROOT_DIR%\libssl-3-x64.dll" libssl-3-x64.dll
|
||||
|
||||
copy "%OPENSSL_ROOT_DIR%\libcrypto-3-x64.dll" libcrypto-3-x64.dll
|
||||
|
||||
cd ..
|
||||
|
||||
7z a TrinityCoreWin64VS2022.zip .\RelWithDebInfo\*
|
||||
|
||||
del /F /Q /S "RelWithDebInfo\*.pdb" > NUL
|
||||
|
||||
7z a TrinityCoreWin64VS2022NoSymbols.zip .\RelWithDebInfo\*
|
||||
|
||||
test: off
|
||||
artifacts:
|
||||
- path: build\bin\TrinityCoreWin64VS2022.zip
|
||||
name: TrinityCoreWin64VS2022
|
||||
|
||||
- path: build\bin\TrinityCoreWin64VS2022NoSymbols.zip
|
||||
name: TrinityCoreWin64VS2022NoSymbols
|
||||
@@ -1,165 +0,0 @@
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
set(CLANG_EXPECTED_VERSION 11.0.0)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
|
||||
# apple doesnt like to do the sane thing which would be to use the same version numbering as regular clang
|
||||
# version number pulled from https://en.wikipedia.org/wiki/Xcode#Toolchain_versions for row matching LLVM 11
|
||||
set(CLANG_EXPECTED_VERSION 12.0.5)
|
||||
# enable -fpch-instantiate-templates for AppleClang (by default it is active only for regular clang)
|
||||
set(CMAKE_C_COMPILE_OPTIONS_INSTANTIATE_TEMPLATES_PCH -fpch-instantiate-templates)
|
||||
set(CMAKE_CXX_COMPILE_OPTIONS_INSTANTIATE_TEMPLATES_PCH -fpch-instantiate-templates)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS CLANG_EXPECTED_VERSION)
|
||||
message(FATAL_ERROR "Clang: TrinityCore requires version ${CLANG_EXPECTED_VERSION} to build but found ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
else()
|
||||
message(STATUS "Clang: Minimum version required is ${CLANG_EXPECTED_VERSION}, found ${CMAKE_CXX_COMPILER_VERSION} - ok!")
|
||||
endif()
|
||||
|
||||
# This tests for a bug in clang-7 that causes linkage to fail for 64-bit from_chars (in some configurations)
|
||||
# If the clang requirement is bumped to >= clang-8, you can remove this check, as well as
|
||||
# the associated ifdef block in src/common/Utilities/StringConvert.h
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <charconv>
|
||||
#include <cstdint>
|
||||
|
||||
int main()
|
||||
{
|
||||
uint64_t n;
|
||||
char const c[] = \"0\";
|
||||
std::from_chars(c, c+1, n);
|
||||
return static_cast<int>(n);
|
||||
}
|
||||
" CLANG_HAVE_PROPER_CHARCONV)
|
||||
|
||||
if (NOT CLANG_HAVE_PROPER_CHARCONV)
|
||||
message(STATUS "Clang: Detected from_chars bug for 64-bit integers, workaround enabled")
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
TRINITY_NEED_CHARCONV_WORKAROUND)
|
||||
endif()
|
||||
|
||||
if(WITH_WARNINGS)
|
||||
target_compile_options(trinity-warning-interface
|
||||
INTERFACE
|
||||
-W
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wimplicit-fallthrough
|
||||
-Winit-self
|
||||
-Wfatal-errors
|
||||
-Wno-mismatched-tags
|
||||
-Woverloaded-virtual
|
||||
-Wno-missing-field-initializers) # this warning is useless when combined with structure members that have default initializers
|
||||
|
||||
message(STATUS "Clang: All warnings enabled")
|
||||
endif()
|
||||
|
||||
if(WITH_COREDEBUG)
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-g3 -glldb)
|
||||
|
||||
message(STATUS "Clang: Debug-flags set (-g3 -glldb)")
|
||||
endif()
|
||||
|
||||
if(ASAN)
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-fno-omit-frame-pointer
|
||||
-fsanitize=address
|
||||
-fsanitize-recover=address
|
||||
-fsanitize-address-use-after-scope)
|
||||
|
||||
target_link_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-fno-omit-frame-pointer
|
||||
-fsanitize=address
|
||||
-fsanitize-recover=address
|
||||
-fsanitize-address-use-after-scope)
|
||||
|
||||
message(STATUS "Clang: Enabled Address Sanitizer ASan")
|
||||
endif()
|
||||
|
||||
if(MSAN)
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-fno-omit-frame-pointer
|
||||
-fsanitize=memory
|
||||
-fsanitize-memory-track-origins
|
||||
-mllvm
|
||||
-msan-keep-going=1)
|
||||
|
||||
target_link_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-fno-omit-frame-pointer
|
||||
-fsanitize=memory
|
||||
-fsanitize-memory-track-origins)
|
||||
|
||||
message(STATUS "Clang: Enabled Memory Sanitizer MSan")
|
||||
endif()
|
||||
|
||||
if(UBSAN)
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-fno-omit-frame-pointer
|
||||
-fsanitize=undefined)
|
||||
|
||||
target_link_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-fno-omit-frame-pointer
|
||||
-fsanitize=undefined)
|
||||
|
||||
message(STATUS "Clang: Enabled Undefined Behavior Sanitizer UBSan")
|
||||
endif()
|
||||
|
||||
if(TSAN)
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-fno-omit-frame-pointer
|
||||
-fsanitize=thread)
|
||||
|
||||
target_link_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-fno-omit-frame-pointer
|
||||
-fsanitize=thread)
|
||||
|
||||
message(STATUS "Clang: Enabled Thread Sanitizer TSan")
|
||||
endif()
|
||||
|
||||
if(BUILD_TIME_ANALYSIS)
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-ftime-trace)
|
||||
|
||||
message(STATUS "Clang: Enabled build time analysis (-ftime-trace)")
|
||||
endif()
|
||||
|
||||
# -Wno-narrowing needed to suppress a warning in g3d
|
||||
# -Wno-deprecated-register is needed to suppress 185 gsoap warnings on Unix systems.
|
||||
# -Wno-undefined-inline needed for a compile time optimization hack with fmt
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-Wno-narrowing
|
||||
-Wno-deprecated-register
|
||||
-Wno-undefined-inline)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
# -fPIC is needed to allow static linking in shared libs.
|
||||
# -fvisibility=hidden sets the default visibility to hidden to prevent exporting of all symbols.
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-fPIC)
|
||||
|
||||
target_compile_options(trinity-hidden-symbols-interface
|
||||
INTERFACE
|
||||
-fvisibility=hidden)
|
||||
|
||||
# --no-undefined to throw errors when there are undefined symbols
|
||||
# (caused through missing TRINITY_*_API macros).
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --no-undefined")
|
||||
|
||||
message(STATUS "Clang: Disallow undefined symbols")
|
||||
endif()
|
||||
@@ -1,86 +0,0 @@
|
||||
set(GCC_EXPECTED_VERSION 11.1.0)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS GCC_EXPECTED_VERSION)
|
||||
message(FATAL_ERROR "GCC: TrinityCore requires version ${GCC_EXPECTED_VERSION} to build but found ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
else()
|
||||
message(STATUS "GCC: Minimum version required is ${GCC_EXPECTED_VERSION}, found ${CMAKE_CXX_COMPILER_VERSION} - ok!")
|
||||
endif()
|
||||
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-fno-delete-null-pointer-checks)
|
||||
|
||||
if(PLATFORM EQUAL 32)
|
||||
# Required on 32-bit systems to enable SSE2 (standard on x64)
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-msse2
|
||||
-mfpmath=sse)
|
||||
endif()
|
||||
if(TRINITY_SYSTEM_PROCESSOR MATCHES "x86|amd64")
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
HAVE_SSE2
|
||||
__SSE2__)
|
||||
message(STATUS "GCC: SFMT enabled, SSE2 flags forced")
|
||||
endif()
|
||||
|
||||
if(WITH_WARNINGS)
|
||||
target_compile_options(trinity-warning-interface
|
||||
INTERFACE
|
||||
-W
|
||||
-Wall
|
||||
-Wextra
|
||||
-Winit-self
|
||||
-Winvalid-pch
|
||||
-Wfatal-errors
|
||||
-Woverloaded-virtual
|
||||
-Wno-missing-field-initializers # this warning is useless when combined with structure members that have default initializers
|
||||
-Wno-maybe-uninitialized) # this warning causes many false positives with std::optional
|
||||
|
||||
message(STATUS "GCC: All warnings enabled")
|
||||
endif()
|
||||
|
||||
if(WITH_COREDEBUG)
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-ggdb3)
|
||||
|
||||
message(STATUS "GCC: Debug-flags set (-ggdb3)")
|
||||
endif()
|
||||
|
||||
if(ASAN)
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-fno-omit-frame-pointer
|
||||
-fsanitize=address
|
||||
-fsanitize-recover=address
|
||||
-fsanitize-address-use-after-scope)
|
||||
|
||||
target_link_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-fno-omit-frame-pointer
|
||||
-fsanitize=address
|
||||
-fsanitize-recover=address
|
||||
-fsanitize-address-use-after-scope)
|
||||
|
||||
message(STATUS "GCC: Enabled Address Sanitizer")
|
||||
endif()
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-fPIC
|
||||
-Wno-attributes)
|
||||
|
||||
target_compile_options(trinity-hidden-symbols-interface
|
||||
INTERFACE
|
||||
-fvisibility=hidden)
|
||||
|
||||
# Should break the build when there are TRINITY_*_API macros missing
|
||||
# but it complains about missing references in precompiled headers.
|
||||
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--no-undefined")
|
||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-undefined")
|
||||
|
||||
message(STATUS "GCC: Enabled shared linking")
|
||||
endif()
|
||||
@@ -1,24 +0,0 @@
|
||||
if(PLATFORM EQUAL 32)
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-axSSE2)
|
||||
else()
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-xSSE2)
|
||||
endif()
|
||||
|
||||
if(WITH_WARNINGS)
|
||||
target_compile_options(trinity-warning-interface
|
||||
INTERFACE
|
||||
-w1)
|
||||
|
||||
message(STATUS "ICC: All warnings enabled")
|
||||
endif()
|
||||
|
||||
if(WITH_COREDEBUG)
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
-g)
|
||||
message(STATUS "ICC: Debug-flag set (-g)")
|
||||
endif()
|
||||
@@ -1,6 +0,0 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<UseMultiToolTask>false</UseMultiToolTask>
|
||||
<UseMSBuildResourceManager>false</UseMSBuildResourceManager>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,178 +0,0 @@
|
||||
set(MSVC_EXPECTED_VERSION 19.32)
|
||||
set(MSVC_EXPECTED_VERSION_STRING "Microsoft Visual Studio 2022 17.2")
|
||||
|
||||
# This file is also used by compilers that pretend to be MSVC but report their own version number - don't version check them
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MSVC_EXPECTED_VERSION)
|
||||
message(FATAL_ERROR "MSVC: TrinityCore requires version ${MSVC_EXPECTED_VERSION} (${MSVC_EXPECTED_VERSION_STRING}) to build but found ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
else()
|
||||
message(STATUS "MSVC: Minimum version required is ${MSVC_EXPECTED_VERSION}, found ${CMAKE_CXX_COMPILER_VERSION} - ok!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# CMake sets warning flags by default, however we manage it manually
|
||||
# for different core and dependency targets
|
||||
string(REGEX REPLACE "/W[0-4] " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
# Search twice, once for space after /W argument,
|
||||
# once for end of line as CMake regex has no \b
|
||||
string(REGEX REPLACE "/W[0-4]$" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REGEX REPLACE "/W[0-4] " "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
string(REGEX REPLACE "/W[0-4]$" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
|
||||
target_compile_options(trinity-warning-interface
|
||||
INTERFACE
|
||||
/W3)
|
||||
|
||||
# disable permissive mode to make msvc more eager to reject code that other compilers don't already accept
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
/permissive-
|
||||
/utf-8)
|
||||
|
||||
if(PLATFORM EQUAL 32)
|
||||
# mark 32 bit executables large address aware so they can use > 2GB address space
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
|
||||
message(STATUS "MSVC: Enabled large address awareness")
|
||||
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
/arch:SSE2)
|
||||
message(STATUS "MSVC: Enabled SSE2 support")
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
|
||||
message(STATUS "MSVC: Disabled Safe Exception Handlers for debug builds")
|
||||
endif()
|
||||
|
||||
if("${CMAKE_MAKE_PROGRAM}" MATCHES "MSBuild")
|
||||
# multithreaded compiling on VS
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
/MP)
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
# Forces writes to the PDB file to be serialized through mspdbsrv.exe (/FS)
|
||||
# Enable faster PDB generation in parallel builds by minimizing RPC calls to mspdbsrv.exe (/Zf)
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
$<$<CONFIG:Debug,RelWithDebInfo>:/FS /Zf>)
|
||||
endif()
|
||||
|
||||
if((PLATFORM EQUAL 64) OR (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.23026.0) OR BUILD_SHARED_LIBS)
|
||||
# Enable extended object support
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
/bigobj)
|
||||
|
||||
message(STATUS "MSVC: Enabled increased number of sections in object files")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
/Zc:__cplusplus # Enable updated __cplusplus macro value
|
||||
/Zc:preprocessor # Enable preprocessor conformance mode
|
||||
/Zc:templateScope # Check template parameter shadowing
|
||||
/Zc:throwingNew) # Assume operator new throws
|
||||
endif()
|
||||
|
||||
# Define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES - eliminates the warning by changing the strcpy call to strcpy_s, which prevents buffer overruns
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES)
|
||||
message(STATUS "MSVC: Overloaded standard names")
|
||||
|
||||
# Ignore warnings about older, less secure functions
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
_CRT_SECURE_NO_WARNINGS)
|
||||
message(STATUS "MSVC: Disabled NON-SECURE warnings")
|
||||
|
||||
# Ignore warnings about POSIX deprecation
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
_CRT_NONSTDC_NO_WARNINGS)
|
||||
|
||||
# Force math constants like M_PI to be available
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
_USE_MATH_DEFINES)
|
||||
|
||||
message(STATUS "MSVC: Disabled POSIX warnings")
|
||||
|
||||
# Ignore specific warnings
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
/wd4351 # C4351: new behavior: elements of array 'x' will be default initialized
|
||||
/wd4091) # C4091: 'typedef ': ignored on left of '' when no variable is declared
|
||||
|
||||
if(NOT WITH_WARNINGS)
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
/wd4996 # C4996 deprecation
|
||||
/wd4985 # C4985 'symbol-name': attributes not present on previous declaration.
|
||||
/wd4244 # C4244 'argument' : conversion from 'type1' to 'type2', possible loss of data
|
||||
/wd4267 # C4267 'var' : conversion from 'size_t' to 'type', possible loss of data
|
||||
/wd4619 # C4619 #pragma warning : there is no warning number 'number'
|
||||
/wd4512) # C4512 'class' : assignment operator could not be generated
|
||||
|
||||
message(STATUS "MSVC: Disabled generic compiletime warnings")
|
||||
endif()
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
/wd4251 # C4251: needs to have dll-interface to be used by clients of class '...'
|
||||
/wd4275) # C4275: non dll-interface class ...' used as base for dll-interface class '...'
|
||||
|
||||
message(STATUS "MSVC: Enabled shared linking")
|
||||
endif()
|
||||
|
||||
# Move some warnings that are enabled for other compilers from level 4 to level 3 and enable some warnings which are off by default
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
/w15038 # C5038: data member 'member1' will be initialized after data member 'member2'
|
||||
/w34100 # C4100: 'identifier' : unreferenced formal parameter
|
||||
/w34101 # C4101: 'identifier' : unreferenced local variable
|
||||
/w34189 # C4189: 'identifier' : local variable is initialized but not referenced
|
||||
/w34389 # C4389: 'equality-operator' : signed/unsigned mismatch
|
||||
/w35054) # C5054: 'operator 'operator-name': deprecated between enumerations of different types'
|
||||
|
||||
# Enable and treat as errors the following warnings to easily detect virtual function signature failures:
|
||||
# 'function' : member function does not override any base class virtual member function
|
||||
# 'virtual_function' : no override available for virtual member function from base 'class'; function is hidden
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
/we4263
|
||||
/we4264)
|
||||
|
||||
if(ASAN)
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
_DISABLE_STRING_ANNOTATION
|
||||
_DISABLE_VECTOR_ANNOTATION)
|
||||
|
||||
target_compile_options(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
/fsanitize=address)
|
||||
|
||||
message(STATUS "MSVC: Enabled Address Sanitizer ASan")
|
||||
endif()
|
||||
|
||||
# Disable incremental linking in debug builds.
|
||||
# To prevent linking getting stuck (which might be fixed in a later VS version).
|
||||
macro(DisableIncrementalLinking variable)
|
||||
string(REGEX REPLACE "/INCREMENTAL *" "" ${variable} "${${variable}}")
|
||||
set(${variable} "${${variable}} /INCREMENTAL:NO")
|
||||
endmacro()
|
||||
|
||||
# Disable Visual Studio 2022 build process management
|
||||
# This will make compiler behave like in 2019 - compiling num_cpus * num_projects at the same time
|
||||
# it is neccessary because of a bug in current implementation that makes scripts build only a single
|
||||
# file at the same time after game project finishes building
|
||||
if (NOT MSVC_TOOLSET_VERSION LESS 143)
|
||||
file(COPY "${CMAKE_CURRENT_LIST_DIR}/Directory.Build.props" DESTINATION "${CMAKE_BINARY_DIR}")
|
||||
endif()
|
||||
|
||||
DisableIncrementalLinking(CMAKE_EXE_LINKER_FLAGS_DEBUG)
|
||||
DisableIncrementalLinking(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO)
|
||||
DisableIncrementalLinking(CMAKE_SHARED_LINKER_FLAGS_DEBUG)
|
||||
DisableIncrementalLinking(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO)
|
||||
@@ -1,150 +0,0 @@
|
||||
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
# User has manually chosen to ignore the git-tests, so throw them a warning.
|
||||
# This is done EACH compile so they can be alerted about the consequences.
|
||||
|
||||
if(NOT BUILDDIR)
|
||||
# Workaround for cmake script mode
|
||||
set(BUILDDIR ${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
if(WITHOUT_GIT)
|
||||
set(rev_date "1970-01-01 00:00:00 +0000")
|
||||
set(rev_hash "unknown")
|
||||
set(rev_branch "Archived")
|
||||
# No valid git commit date, use today
|
||||
string(TIMESTAMP rev_date_fallback "%Y-%m-%d %H:%M:%S" UTC)
|
||||
else()
|
||||
if(GIT_EXECUTABLE)
|
||||
# Create a revision-string that we can use
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" rev-parse --short=12 HEAD
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE rev_hash
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
|
||||
if(rev_hash)
|
||||
# Retrieve repository dirty status
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD --
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
RESULT_VARIABLE is_dirty
|
||||
ERROR_QUIET
|
||||
)
|
||||
|
||||
# Append dirty marker to commit hash
|
||||
if(is_dirty)
|
||||
set(rev_hash "${rev_hash}+")
|
||||
endif()
|
||||
|
||||
# And grab the commits timestamp
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" show -s --format=%ci
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE rev_date
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
|
||||
# Also retrieve branch name
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" symbolic-ref -q --short HEAD
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE rev_branch
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
|
||||
# when ran on CI, repository is put in detached HEAD state, attempt to scan for known local branches
|
||||
if(NOT rev_branch)
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" for-each-ref --points-at=HEAD refs/heads "--format=%(refname:short)"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE rev_branch
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
endif()
|
||||
|
||||
# if local branch scan didn't find anything, try remote branches
|
||||
if(NOT rev_branch)
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" for-each-ref --points-at=HEAD refs/remotes "--format=%(refname:short)"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE rev_branch
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
endif()
|
||||
|
||||
# give up finding a name for branch, use commit hash
|
||||
if(NOT rev_branch)
|
||||
set(rev_branch ${rev_hash})
|
||||
endif()
|
||||
|
||||
# normalize branch to single line (for-each-ref can output multiple lines if there are multiple branches on the same commit)
|
||||
string(REGEX MATCH "^[^ \t\r\n]+" rev_branch ${rev_branch})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Last minute check - ensure that we have a proper revision
|
||||
# If everything above fails (means the user has erased the git revision control directory or removed the origin/HEAD tag)
|
||||
if(NOT rev_hash)
|
||||
# No valid ways available to find/set the revision/hash, so let's force some defaults
|
||||
message(STATUS "
|
||||
Could not find a proper repository signature (hash) - you may need to pull tags with git fetch -t
|
||||
Continuing anyway - note that the versionstring will be set to \"unknown 1970-01-01 00:00:00 (Archived)\"")
|
||||
set(rev_date "1970-01-01 00:00:00 +0000")
|
||||
set(rev_hash "unknown")
|
||||
set(rev_branch "Archived")
|
||||
# No valid git commit date, use today
|
||||
string(TIMESTAMP rev_date_fallback "%Y-%m-%d %H:%M:%S" UTC)
|
||||
else()
|
||||
# We have valid date from git commit, use that
|
||||
set(rev_date_fallback ${rev_date})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# For package/copyright information we always need a proper date - keep "Archived/1970" for displaying git info but a valid year elsewhere
|
||||
string(REGEX MATCH "([0-9]+)-([0-9]+)-([0-9]+)" rev_date_fallback_match ${rev_date_fallback})
|
||||
set(rev_year ${CMAKE_MATCH_1})
|
||||
set(rev_month ${CMAKE_MATCH_2})
|
||||
set(rev_day ${CMAKE_MATCH_3})
|
||||
|
||||
# Create the actual revision_data.h file from the above params
|
||||
cmake_host_system_information(RESULT TRINITY_BUILD_HOST_SYSTEM QUERY OS_NAME)
|
||||
cmake_host_system_information(RESULT TRINITY_BUILD_HOST_DISTRO QUERY DISTRIB_INFO)
|
||||
cmake_host_system_information(RESULT TRINITY_BUILD_HOST_SYSTEM_RELEASE QUERY OS_RELEASE)
|
||||
# on windows OS_RELEASE contains sub-type string tag like "Professional" instead of a version number and OS_VERSION has only build number
|
||||
# so we grab that with Get-CimInstance powershell cmdlet
|
||||
if(WIN32)
|
||||
execute_process(
|
||||
COMMAND powershell -NoProfile -Command "$v=(Get-CimInstance -ClassName Win32_OperatingSystem); '{0} ({1})' -f $v.Caption, $v.Version"
|
||||
OUTPUT_VARIABLE TRINITY_BUILD_HOST_SYSTEM_RELEASE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
# Remove "Microsoft Windows" from the result
|
||||
string(REGEX REPLACE "^.* Windows " "" TRINITY_BUILD_HOST_SYSTEM_RELEASE "${TRINITY_BUILD_HOST_SYSTEM_RELEASE}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SCRIPT_MODE_FILE)
|
||||
# hack for CMAKE_SYSTEM_PROCESSOR missing in script mode
|
||||
set(CMAKE_PLATFORM_INFO_DIR ${BUILDDIR}${CMAKE_FILES_DIRECTORY})
|
||||
include(${CMAKE_ROOT}/Modules/CMakeDetermineSystem.cmake)
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_SOURCE_DIR}/revision_data.h.in.cmake"
|
||||
"${BUILDDIR}/revision_data.h"
|
||||
@ONLY
|
||||
)
|
||||
@@ -1,84 +0,0 @@
|
||||
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
# Adds all found source files to a given target
|
||||
#
|
||||
# Use it like:
|
||||
# CollectAndAddSourceFiles(
|
||||
# common
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
# EXCLUDE
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/Platform
|
||||
# HEADER_VISIBILITY PRIVATE) # default is PUBLIC, this controls whether other targets that have this target as dependency will be able to access its headers
|
||||
#
|
||||
function(CollectAndAddSourceFiles target_name current_dir)
|
||||
cmake_parse_arguments(PARSE_ARGV 2 arg "" "BASE_DIR;HEADER_VISIBILITY" "EXCLUDE")
|
||||
if(NOT arg_BASE_DIR)
|
||||
set(arg_BASE_DIR "${current_dir}")
|
||||
endif()
|
||||
if(NOT arg_HEADER_VISIBILITY)
|
||||
set(arg_HEADER_VISIBILITY "PUBLIC")
|
||||
endif()
|
||||
list(FIND arg_EXCLUDE "${current_dir}" IS_EXCLUDED)
|
||||
if(IS_EXCLUDED EQUAL -1)
|
||||
cmake_path(RELATIVE_PATH current_dir BASE_DIRECTORY "${arg_BASE_DIR}" OUTPUT_VARIABLE fileset_name)
|
||||
# normalize file set name
|
||||
string(REGEX REPLACE "[./\\]" "_" fileset_name "${fileset_name}")
|
||||
|
||||
file(GLOB private_source_files
|
||||
${current_dir}/*.c
|
||||
${current_dir}/*.cc
|
||||
${current_dir}/*.cpp)
|
||||
|
||||
file(GLOB public_header_files
|
||||
${current_dir}/*.inl
|
||||
${current_dir}/*.h
|
||||
${current_dir}/*.hh
|
||||
${current_dir}/*.hpp)
|
||||
|
||||
target_sources(${target_name} PRIVATE ${private_source_files})
|
||||
target_sources(${target_name} ${arg_HEADER_VISIBILITY} FILE_SET "headers_${fileset_name}" TYPE HEADERS BASE_DIRS ${current_dir} FILES ${public_header_files})
|
||||
|
||||
file(GLOB SUB_DIRECTORIES ${current_dir}/*)
|
||||
foreach(SUB_DIRECTORY ${SUB_DIRECTORIES})
|
||||
if(IS_DIRECTORY ${SUB_DIRECTORY})
|
||||
CollectAndAddSourceFiles("${target_name}" "${SUB_DIRECTORY}" BASE_DIR ${arg_BASE_DIR} HEADER_VISIBILITY ${arg_HEADER_VISIBILITY} EXCLUDE ${arg_EXCLUDE})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Collects all subdirectoroies into the given variable,
|
||||
# which is useful to include all subdirectories.
|
||||
# Ignores full qualified directories listed in the variadic arguments.
|
||||
#
|
||||
# Use it like:
|
||||
# CollectIncludeDirectories(
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
# COMMON_PUBLIC_INCLUDES
|
||||
# EXCLUDE
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/Platform)
|
||||
#
|
||||
function(CollectIncludeDirectories current_dir sources_variable)
|
||||
cmake_parse_arguments(PARSE_ARGV 2 arg "" "" "EXCLUDE")
|
||||
list(FIND arg_EXCLUDE "${current_dir}" IS_EXCLUDED)
|
||||
if(IS_EXCLUDED EQUAL -1)
|
||||
list(APPEND ${sources_variable} ${current_dir})
|
||||
file(GLOB SUB_DIRECTORIES ${current_dir}/*)
|
||||
foreach(SUB_DIRECTORY ${SUB_DIRECTORIES})
|
||||
if(IS_DIRECTORY ${SUB_DIRECTORY})
|
||||
CollectIncludeDirectories("${SUB_DIRECTORY}" "${sources_variable}" EXCLUDE ${arg_EXCLUDE})
|
||||
endif()
|
||||
endforeach()
|
||||
set(${sources_variable} ${${sources_variable}} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -1,23 +0,0 @@
|
||||
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
#
|
||||
# Force out-of-source build
|
||||
#
|
||||
|
||||
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" BUILDING_IN_SOURCE)
|
||||
|
||||
if(BUILDING_IN_SOURCE)
|
||||
message(FATAL_ERROR "
|
||||
This project requires an out of source build. Remove the file 'CMakeCache.txt'
|
||||
found in this directory before continuing, create a separate build directory
|
||||
and run 'cmake path_to_project [options]' from there.
|
||||
")
|
||||
endif()
|
||||
@@ -1,47 +0,0 @@
|
||||
# check what platform we're on (64-bit or 32-bit), and create a simpler test than CMAKE_SIZEOF_VOID_P
|
||||
if(CMAKE_SIZEOF_VOID_P MATCHES 8)
|
||||
set(PLATFORM 64)
|
||||
MESSAGE(STATUS "Detected 64-bit platform")
|
||||
else()
|
||||
set(PLATFORM 32)
|
||||
MESSAGE(STATUS "Detected 32-bit platform")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64")
|
||||
set(TRINITY_SYSTEM_PROCESSOR "amd64")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm|ARM|aarch)64$")
|
||||
set(TRINITY_SYSTEM_PROCESSOR "arm64")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm|ARM)$")
|
||||
set(TRINITY_SYSTEM_PROCESSOR "arm")
|
||||
else()
|
||||
set(TRINITY_SYSTEM_PROCESSOR "x86")
|
||||
endif()
|
||||
|
||||
# detect MSVC special case of using cmake -A switch (which doesn't set any cross compiling variables)
|
||||
if(CMAKE_GENERATOR_PLATFORM STREQUAL "Win32")
|
||||
set(TRINITY_SYSTEM_PROCESSOR "x86")
|
||||
elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "x64")
|
||||
set(TRINITY_SYSTEM_PROCESSOR "amd64")
|
||||
elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "ARM")
|
||||
set(TRINITY_SYSTEM_PROCESSOR "arm")
|
||||
elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64")
|
||||
set(TRINITY_SYSTEM_PROCESSOR "arm64")
|
||||
endif()
|
||||
|
||||
message(STATUS "Detected ${TRINITY_SYSTEM_PROCESSOR} processor architecture")
|
||||
|
||||
if(WIN32)
|
||||
include("${CMAKE_SOURCE_DIR}/cmake/platform/win/settings.cmake")
|
||||
elseif(UNIX)
|
||||
include("${CMAKE_SOURCE_DIR}/cmake/platform/unix/settings.cmake")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
||||
include("${CMAKE_SOURCE_DIR}/cmake/compiler/msvc/settings.cmake")
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
include("${CMAKE_SOURCE_DIR}/cmake/compiler/clang/settings.cmake")
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
include("${CMAKE_SOURCE_DIR}/cmake/compiler/gcc/settings.cmake")
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
include("${CMAKE_SOURCE_DIR}/cmake/compiler/icc/settings.cmake")
|
||||
endif()
|
||||
@@ -1,70 +0,0 @@
|
||||
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
# An interface library to make the target com available to other targets
|
||||
add_library(trinity-compile-option-interface INTERFACE)
|
||||
|
||||
# Use -std=c++11 instead of -std=gnu++11
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
# Set build-directive (used in core to tell which buildtype we used)
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
TRINITY_BUILD_TYPE="$<CONFIG>"
|
||||
TRINITY_BUILD_HAS_DEBUG_INFO=$<CONFIG:Debug,RelWithDebInfo>)
|
||||
|
||||
# An interface library to make the target features available to other targets
|
||||
add_library(trinity-feature-interface INTERFACE)
|
||||
|
||||
# An interface library to make the warnings level available to other targets
|
||||
# This interface taget is set-up through the platform specific script
|
||||
add_library(trinity-warning-interface INTERFACE)
|
||||
|
||||
# An interface used for all other interfaces
|
||||
add_library(trinity-default-interface INTERFACE)
|
||||
target_link_libraries(trinity-default-interface
|
||||
INTERFACE
|
||||
trinity-compile-option-interface
|
||||
trinity-feature-interface)
|
||||
|
||||
# An interface used for silencing all warnings
|
||||
add_library(trinity-no-warning-interface INTERFACE)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
target_compile_options(trinity-no-warning-interface
|
||||
INTERFACE
|
||||
/W0)
|
||||
else()
|
||||
target_compile_options(trinity-no-warning-interface
|
||||
INTERFACE
|
||||
-w)
|
||||
endif()
|
||||
|
||||
# An interface library to change the default behaviour
|
||||
# to hide symbols automatically.
|
||||
add_library(trinity-hidden-symbols-interface INTERFACE)
|
||||
|
||||
# An interface amalgamation which provides the flags and definitions
|
||||
# used by the dependency targets.
|
||||
add_library(trinity-dependency-interface INTERFACE)
|
||||
target_link_libraries(trinity-dependency-interface
|
||||
INTERFACE
|
||||
trinity-default-interface
|
||||
trinity-no-warning-interface
|
||||
trinity-hidden-symbols-interface)
|
||||
|
||||
# An interface amalgamation which provides the flags and definitions
|
||||
# used by the core targets.
|
||||
add_library(trinity-core-interface INTERFACE)
|
||||
target_link_libraries(trinity-core-interface
|
||||
INTERFACE
|
||||
trinity-default-interface
|
||||
trinity-warning-interface)
|
||||
@@ -1,106 +0,0 @@
|
||||
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
# Returns the base path to the script directory in the source directory
|
||||
function(WarnAboutSpacesInBuildPath)
|
||||
# Only check win32 since unix doesn't allow spaces in paths
|
||||
if(WIN32)
|
||||
string(FIND "${CMAKE_BINARY_DIR}" " " SPACE_INDEX_POS)
|
||||
|
||||
if(SPACE_INDEX_POS GREATER -1)
|
||||
message("")
|
||||
message(WARNING " *** WARNING!\n"
|
||||
" *** Your selected build directory contains spaces!\n"
|
||||
" *** Please note that this will cause issues!")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Returns the base path to the script directory in the source directory
|
||||
function(GetScriptsBasePath variable)
|
||||
set(${variable} "${CMAKE_SOURCE_DIR}/src/server/scripts" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Stores the absolut path of the given module in the variable
|
||||
function(GetPathToScriptModule module variable)
|
||||
GetScriptsBasePath(SCRIPTS_BASE_PATH)
|
||||
set(${variable} "${SCRIPTS_BASE_PATH}/${module}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Stores the project name of the given module in the variable
|
||||
function(GetProjectNameOfScriptModule module variable)
|
||||
string(TOLOWER "scripts_${SCRIPT_MODULE}" GENERATED_NAME)
|
||||
set(${variable} "${GENERATED_NAME}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Creates a list of all script modules
|
||||
# and stores it in the given variable.
|
||||
function(GetScriptModuleList variable)
|
||||
GetScriptsBasePath(BASE_PATH)
|
||||
file(GLOB LOCALE_SCRIPT_MODULE_LIST RELATIVE
|
||||
${BASE_PATH}
|
||||
${BASE_PATH}/*)
|
||||
|
||||
set(${variable})
|
||||
foreach(SCRIPT_MODULE ${LOCALE_SCRIPT_MODULE_LIST})
|
||||
GetPathToScriptModule(${SCRIPT_MODULE} SCRIPT_MODULE_PATH)
|
||||
if(IS_DIRECTORY ${SCRIPT_MODULE_PATH})
|
||||
list(APPEND ${variable} ${SCRIPT_MODULE})
|
||||
endif()
|
||||
endforeach()
|
||||
set(${variable} ${${variable}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Converts the given script module name into it's
|
||||
# variable name which holds the linkage type.
|
||||
function(ScriptModuleNameToVariable module variable)
|
||||
string(TOUPPER ${module} ${variable})
|
||||
set(${variable} "SCRIPTS_${${variable}}")
|
||||
set(${variable} ${${variable}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Stores in the given variable whether dynamic linking is required
|
||||
function(IsDynamicLinkingRequired variable)
|
||||
if(SCRIPTS MATCHES "dynamic")
|
||||
set(IS_DEFAULT_VALUE_DYNAMIC ON)
|
||||
endif()
|
||||
|
||||
GetScriptModuleList(SCRIPT_MODULE_LIST)
|
||||
set(IS_REQUIRED OFF)
|
||||
foreach(SCRIPT_MODULE ${SCRIPT_MODULE_LIST})
|
||||
ScriptModuleNameToVariable(${SCRIPT_MODULE} SCRIPT_MODULE_VARIABLE)
|
||||
if((${SCRIPT_MODULE_VARIABLE} STREQUAL "dynamic") OR
|
||||
(${SCRIPT_MODULE_VARIABLE} STREQUAL "default" AND IS_DEFAULT_VALUE_DYNAMIC))
|
||||
set(IS_REQUIRED ON)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
set(${variable} ${IS_REQUIRED} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Stores the native variable name
|
||||
function(GetNativeSharedLibraryName module variable)
|
||||
if(WIN32)
|
||||
set(${variable} "${module}.dll" PARENT_SCOPE)
|
||||
elseif(APPLE)
|
||||
set(${variable} "lib${module}.dylib" PARENT_SCOPE)
|
||||
else()
|
||||
set(${variable} "lib${module}.so" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Stores the native install path in the variable
|
||||
function(GetInstallOffset variable)
|
||||
if(WIN32)
|
||||
set(${variable} "${CMAKE_INSTALL_PREFIX}/scripts" PARENT_SCOPE)
|
||||
else()
|
||||
set(${variable} "${CMAKE_INSTALL_PREFIX}/bin/scripts" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -1,114 +0,0 @@
|
||||
# This file defines the following macros for developers to use in ensuring
|
||||
# that installed software is of the right version:
|
||||
#
|
||||
# ENSURE_VERSION - test that a version number is greater than
|
||||
# or equal to some minimum
|
||||
# ENSURE_VERSION_RANGE - test that a version number is greater than
|
||||
# or equal to some minimum and less than some
|
||||
# maximum
|
||||
# ENSURE_VERSION2 - deprecated, do not use in new code
|
||||
#
|
||||
|
||||
# ENSURE_VERSION
|
||||
# This macro compares version numbers of the form "x.y.z" or "x.y"
|
||||
# ENSURE_VERSION(FOO_MIN_VERSION FOO_VERSION_FOUND FOO_VERSION_OK)
|
||||
# will set FOO_VERSION_OK to true if FOO_VERSION_FOUND >= FOO_MIN_VERSION
|
||||
# Leading and trailing text is ok, e.g.
|
||||
# ENSURE_VERSION("2.5.31" "flex 2.5.4a" VERSION_OK)
|
||||
# which means 2.5.31 is required and "flex 2.5.4a" is what was found on the system
|
||||
|
||||
# Copyright (c) 2006, David Faure, <[email protected]>
|
||||
# Copyright (c) 2007, Will Stephenson <[email protected]>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
# ENSURE_VERSION_RANGE
|
||||
# This macro ensures that a version number of the form
|
||||
# "x.y.z" or "x.y" falls within a range defined by
|
||||
# min_version <= found_version < max_version.
|
||||
# If this expression holds, FOO_VERSION_OK will be set TRUE
|
||||
#
|
||||
# Example: ENSURE_VERSION_RANGE3("0.1.0" ${FOOCODE_VERSION} "0.7.0" FOO_VERSION_OK)
|
||||
#
|
||||
# This macro will break silently if any of x,y,z are greater than 100.
|
||||
#
|
||||
# Copyright (c) 2007, Will Stephenson <[email protected]>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
# NORMALIZE_VERSION
|
||||
# Helper macro to convert version numbers of the form "x.y.z"
|
||||
# to an integer equal to 10^4 * x + 10^2 * y + z
|
||||
#
|
||||
# This macro will break silently if any of x,y,z are greater than 100.
|
||||
#
|
||||
# Copyright (c) 2006, David Faure, <[email protected]>
|
||||
# Copyright (c) 2007, Will Stephenson <[email protected]>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
# CHECK_RANGE_INCLUSIVE_LOWER
|
||||
# Helper macro to check whether x <= y < z
|
||||
#
|
||||
# Copyright (c) 2007, Will Stephenson <[email protected]>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
MACRO(NORMALIZE_VERSION _requested_version _normalized_version)
|
||||
STRING(REGEX MATCH "[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" _threePartMatch "${_requested_version}")
|
||||
if(_threePartMatch)
|
||||
# parse the parts of the version string
|
||||
STRING(REGEX REPLACE "[^0-9]*([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _major_vers "${_requested_version}")
|
||||
STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _minor_vers "${_requested_version}")
|
||||
STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _patch_vers "${_requested_version}")
|
||||
else(_threePartMatch)
|
||||
STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+" "\\1" _major_vers "${_requested_version}")
|
||||
STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)" "\\1" _minor_vers "${_requested_version}")
|
||||
set(_patch_vers "0")
|
||||
endif(_threePartMatch)
|
||||
|
||||
# compute an overall version number which can be compared at once
|
||||
MATH(EXPR ${_normalized_version} "${_major_vers}*10000 + ${_minor_vers}*100 + ${_patch_vers}")
|
||||
ENDMACRO(NORMALIZE_VERSION)
|
||||
|
||||
MACRO(CHECK_RANGE_INCLUSIVE_LOWER _lower_limit _value _upper_limit _ok)
|
||||
if(${_value} LESS ${_lower_limit})
|
||||
set(${_ok} FALSE)
|
||||
elseif(${_value} EQUAL ${_lower_limit})
|
||||
set(${_ok} TRUE)
|
||||
elseif(${_value} EQUAL ${_upper_limit})
|
||||
set(${_ok} FALSE)
|
||||
elseif(${_value} GREATER ${_upper_limit})
|
||||
set(${_ok} FALSE)
|
||||
else(${_value} LESS ${_lower_limit})
|
||||
set(${_ok} TRUE)
|
||||
endif(${_value} LESS ${_lower_limit})
|
||||
ENDMACRO(CHECK_RANGE_INCLUSIVE_LOWER)
|
||||
|
||||
MACRO(ENSURE_VERSION requested_version found_version var_too_old)
|
||||
NORMALIZE_VERSION(${requested_version} req_vers_num)
|
||||
NORMALIZE_VERSION(${found_version} found_vers_num)
|
||||
|
||||
if(found_vers_num LESS req_vers_num)
|
||||
set(${var_too_old} FALSE)
|
||||
else(found_vers_num LESS req_vers_num)
|
||||
set(${var_too_old} TRUE)
|
||||
endif(found_vers_num LESS req_vers_num)
|
||||
|
||||
ENDMACRO(ENSURE_VERSION)
|
||||
|
||||
MACRO(ENSURE_VERSION2 requested_version2 found_version2 var_too_old2)
|
||||
ENSURE_VERSION(${requested_version2} ${found_version2} ${var_too_old2})
|
||||
ENDMACRO(ENSURE_VERSION2)
|
||||
|
||||
MACRO(ENSURE_VERSION_RANGE min_version found_version max_version var_ok)
|
||||
NORMALIZE_VERSION(${min_version} req_vers_num)
|
||||
NORMALIZE_VERSION(${found_version} found_vers_num)
|
||||
NORMALIZE_VERSION(${max_version} max_vers_num)
|
||||
|
||||
CHECK_RANGE_INCLUSIVE_LOWER(${req_vers_num} ${found_vers_num} ${max_vers_num} ${var_ok})
|
||||
ENDMACRO(ENSURE_VERSION_RANGE)
|
||||
@@ -1,351 +0,0 @@
|
||||
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation; either version 2 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindMySQL
|
||||
-----------
|
||||
|
||||
Find MySQL.
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines the following :prop_tgt:`IMPORTED` targets:
|
||||
|
||||
``MySQL::MySQL``
|
||||
MySQL client library, if found.
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
``MYSQL_FOUND``
|
||||
System has MySQL.
|
||||
``MYSQL_INCLUDE_DIR``
|
||||
MySQL include directory.
|
||||
``MYSQL_LIBRARY``
|
||||
MySQL library.
|
||||
``MYSQL_EXECUTABLE``
|
||||
Path to mysql client binary.
|
||||
``MYSQL_FLAVOR``
|
||||
Flavor of mysql installation (MySQL or MariaDB).
|
||||
``MYSQL_VERSION``
|
||||
MySQL version string.
|
||||
|
||||
Hints
|
||||
^^^^^
|
||||
|
||||
Set ``MYSQL_ROOT_DIR`` to the root directory of MySQL installation.
|
||||
#]=======================================================================]
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
set(MYSQL_FOUND 0)
|
||||
|
||||
set(_MYSQL_ROOT_HINTS
|
||||
${MYSQL_ROOT_DIR}
|
||||
ENV MYSQL_ROOT_DIR
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
set(MYSQL_CONFIG_PREFER_PATH "$ENV{MYSQL_HOME}/bin" CACHE FILEPATH
|
||||
"preferred path to MySQL (mysql_config)"
|
||||
)
|
||||
|
||||
find_program(MYSQL_CONFIG mysql_config
|
||||
${MYSQL_CONFIG_PREFER_PATH}
|
||||
/usr/local/mysql/bin/
|
||||
/usr/local/bin/
|
||||
/usr/bin/
|
||||
)
|
||||
|
||||
if(MYSQL_CONFIG)
|
||||
message(STATUS "Using mysql-config: ${MYSQL_CONFIG}")
|
||||
# set INCLUDE_DIR
|
||||
execute_process(
|
||||
COMMAND "${MYSQL_CONFIG}" --include
|
||||
OUTPUT_VARIABLE MY_TMP
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
string(REGEX REPLACE "-I([^ ]*)( .*)?" "\\1" MY_TMP "${MY_TMP}")
|
||||
set(MYSQL_ADD_INCLUDE_PATH ${MY_TMP} CACHE FILEPATH INTERNAL)
|
||||
#message("[DEBUG] MYSQL ADD_INCLUDE_PATH : ${MYSQL_ADD_INCLUDE_PATH}")
|
||||
# set LIBRARY_DIR
|
||||
execute_process(
|
||||
COMMAND "${MYSQL_CONFIG}" --libs_r
|
||||
OUTPUT_VARIABLE MY_TMP
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
set(MYSQL_ADD_LIBRARIES "")
|
||||
string(REGEX MATCHALL "-l[^ ]*" MYSQL_LIB_LIST "${MY_TMP}")
|
||||
foreach(LIB ${MYSQL_LIB_LIST})
|
||||
string(REGEX REPLACE "[ ]*-l([^ ]*)" "\\1" LIB "${LIB}")
|
||||
list(APPEND MYSQL_ADD_LIBRARIES "${LIB}")
|
||||
#message("[DEBUG] MYSQL ADD_LIBRARIES : ${MYSQL_ADD_LIBRARIES}")
|
||||
endforeach(LIB ${MYSQL_LIB_LIST})
|
||||
|
||||
set(MYSQL_ADD_LIBRARIES_PATH "")
|
||||
string(REGEX MATCHALL "-L[^ ]*" MYSQL_LIBDIR_LIST "${MY_TMP}")
|
||||
foreach(LIB ${MYSQL_LIBDIR_LIST})
|
||||
string(REGEX REPLACE "[ ]*-L([^ ]*)" "\\1" LIB "${LIB}")
|
||||
list(APPEND MYSQL_ADD_LIBRARIES_PATH "${LIB}")
|
||||
#message("[DEBUG] MYSQL ADD_LIBRARIES_PATH : ${MYSQL_ADD_LIBRARIES_PATH}")
|
||||
endforeach(LIB ${MYSQL_LIBS})
|
||||
|
||||
else(MYSQL_CONFIG)
|
||||
set(MYSQL_ADD_LIBRARIES "")
|
||||
list(APPEND MYSQL_ADD_LIBRARIES "mysqlclient_r")
|
||||
endif(MYSQL_CONFIG)
|
||||
endif(UNIX)
|
||||
|
||||
set(_MYSQL_ROOT_PATHS)
|
||||
|
||||
if(WIN32)
|
||||
# read environment variables and change \ to /
|
||||
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" PROGRAM_FILES_32)
|
||||
file(TO_CMAKE_PATH "$ENV{ProgramW6432}" PROGRAM_FILES_64)
|
||||
|
||||
cmake_host_system_information(
|
||||
RESULT
|
||||
_MYSQL_ROOT_HINTS_SUBKEYS
|
||||
QUERY
|
||||
WINDOWS_REGISTRY
|
||||
"HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB" SUBKEYS
|
||||
VIEW BOTH
|
||||
)
|
||||
list(FILTER _MYSQL_ROOT_HINTS_SUBKEYS INCLUDE REGEX "^MySQL Server ")
|
||||
list(SORT _MYSQL_ROOT_HINTS_SUBKEYS COMPARE NATURAL ORDER DESCENDING)
|
||||
|
||||
set(_MYSQL_ROOT_HINTS_REGISTRY_LOCATIONS)
|
||||
foreach(subkey IN LISTS _MYSQL_ROOT_HINTS_SUBKEYS)
|
||||
cmake_host_system_information(
|
||||
RESULT
|
||||
_MYSQL_ROOT_HINTS_REGISTRY_LOCATION
|
||||
QUERY
|
||||
WINDOWS_REGISTRY
|
||||
"HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\${subkey}" VALUE "Location"
|
||||
VIEW BOTH
|
||||
)
|
||||
list(APPEND _MYSQL_ROOT_HINTS_REGISTRY_LOCATIONS ${_MYSQL_ROOT_HINTS_REGISTRY_LOCATION})
|
||||
endforeach()
|
||||
|
||||
cmake_host_system_information(
|
||||
RESULT
|
||||
_MYSQL_ROOT_HINTS_SUBKEYS
|
||||
QUERY
|
||||
WINDOWS_REGISTRY
|
||||
"HKEY_LOCAL_MACHINE\\SOFTWARE" SUBKEYS
|
||||
VIEW BOTH
|
||||
)
|
||||
list(FILTER _MYSQL_ROOT_HINTS_SUBKEYS INCLUDE REGEX "^MariaDB ")
|
||||
list(SORT _MYSQL_ROOT_HINTS_SUBKEYS COMPARE NATURAL ORDER DESCENDING)
|
||||
|
||||
foreach(subkey IN LISTS _MYSQL_ROOT_HINTS_SUBKEYS)
|
||||
cmake_host_system_information(
|
||||
RESULT
|
||||
_MYSQL_ROOT_HINTS_REGISTRY_LOCATION
|
||||
QUERY
|
||||
WINDOWS_REGISTRY
|
||||
"HKEY_LOCAL_MACHINE\\SOFTWARE\\${subkey}" VALUE "INSTALLDIR"
|
||||
VIEW BOTH
|
||||
)
|
||||
list(APPEND _MYSQL_ROOT_HINTS_REGISTRY_LOCATIONS ${_MYSQL_ROOT_HINTS_REGISTRY_LOCATION})
|
||||
endforeach()
|
||||
|
||||
set(_MYSQL_ROOT_HINTS
|
||||
${_MYSQL_ROOT_HINTS}
|
||||
${_MYSQL_ROOT_HINTS_REGISTRY_LOCATIONS}
|
||||
)
|
||||
|
||||
file(GLOB _MYSQL_ROOT_PATHS_VERSION_SUBDIRECTORIES
|
||||
LIST_DIRECTORIES TRUE
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server *"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server *"
|
||||
"$ENV{SystemDrive}/MySQL/MySQL Server *"
|
||||
"${PROGRAM_FILES_64}/MariaDB *"
|
||||
"${PROGRAM_FILES_32}/MariaDB *"
|
||||
"$ENV{SystemDrive}/MariaDB *"
|
||||
)
|
||||
|
||||
list(SORT _MYSQL_ROOT_PATHS_VERSION_SUBDIRECTORIES COMPARE NATURAL ORDER DESCENDING)
|
||||
|
||||
set(_MYSQL_ROOT_PATHS
|
||||
${_MYSQL_ROOT_PATHS}
|
||||
${_MYSQL_ROOT_PATHS_VERSION_SUBDIRECTORIES}
|
||||
"${PROGRAM_FILES_64}/MySQL"
|
||||
"${PROGRAM_FILES_32}/MySQL"
|
||||
"$ENV{SystemDrive}/MySQL"
|
||||
)
|
||||
endif(WIN32)
|
||||
|
||||
find_path(MYSQL_INCLUDE_DIR
|
||||
NAMES
|
||||
mysql.h
|
||||
HINTS
|
||||
${_MYSQL_ROOT_HINTS}
|
||||
PATHS
|
||||
${MYSQL_ADD_INCLUDE_PATH}
|
||||
/usr/include
|
||||
/usr/include/mysql
|
||||
/usr/local/include
|
||||
/usr/local/include/mysql
|
||||
/usr/local/mysql/include
|
||||
${_MYSQL_ROOT_PATHS}
|
||||
PATH_SUFFIXES
|
||||
include
|
||||
include/mysql
|
||||
DOC
|
||||
"Specify the directory containing mysql.h."
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
foreach(LIB ${MYSQL_ADD_LIBRARIES})
|
||||
find_library(MYSQL_LIBRARY
|
||||
NAMES
|
||||
mysql libmysql ${LIB}
|
||||
PATHS
|
||||
${MYSQL_ADD_LIBRARIES_PATH}
|
||||
/usr/lib
|
||||
/usr/lib/mysql
|
||||
/usr/local/lib
|
||||
/usr/local/lib/mysql
|
||||
/usr/local/mysql/lib
|
||||
DOC "Specify the location of the mysql library here."
|
||||
)
|
||||
endforeach(LIB ${MYSQL_ADD_LIBRARY})
|
||||
endif(UNIX)
|
||||
|
||||
if(WIN32)
|
||||
find_library(MYSQL_LIBRARY
|
||||
NAMES
|
||||
libmysql libmariadb
|
||||
HINTS
|
||||
${_MYSQL_ROOT_HINTS}
|
||||
PATHS
|
||||
${MYSQL_ADD_LIBRARIES_PATH}
|
||||
${_MYSQL_ROOT_PATHS}
|
||||
PATH_SUFFIXES
|
||||
lib
|
||||
lib/opt
|
||||
DOC "Specify the location of the mysql library here."
|
||||
)
|
||||
endif(WIN32)
|
||||
|
||||
# On Windows you typically don't need to include any extra libraries
|
||||
# to build MYSQL stuff.
|
||||
|
||||
if(UNIX)
|
||||
find_program(MYSQL_EXECUTABLE mysql
|
||||
PATHS
|
||||
${MYSQL_CONFIG_PREFER_PATH}
|
||||
/usr/local/mysql/bin/
|
||||
/usr/local/bin/
|
||||
/usr/bin/
|
||||
DOC
|
||||
"path to your mysql binary."
|
||||
)
|
||||
endif(UNIX)
|
||||
|
||||
if(WIN32)
|
||||
find_program(MYSQL_EXECUTABLE mysql
|
||||
HINTS
|
||||
${_MYSQL_ROOT_HINTS}
|
||||
PATHS
|
||||
${_MYSQL_ROOT_PATHS}
|
||||
PATH_SUFFIXES
|
||||
bin
|
||||
bin/opt
|
||||
DOC
|
||||
"path to your mysql binary."
|
||||
)
|
||||
endif(WIN32)
|
||||
|
||||
unset(MySQL_lib_WANTED)
|
||||
unset(MySQL_binary_WANTED)
|
||||
set(MYSQL_REQUIRED_VARS "")
|
||||
foreach(_comp IN LISTS MySQL_FIND_COMPONENTS)
|
||||
if(_comp STREQUAL "lib")
|
||||
set(MySQL_${_comp}_WANTED TRUE)
|
||||
if(MySQL_FIND_REQUIRED_${_comp})
|
||||
list(APPEND MYSQL_REQUIRED_VARS "MYSQL_LIBRARY")
|
||||
list(APPEND MYSQL_REQUIRED_VARS "MYSQL_INCLUDE_DIR")
|
||||
endif()
|
||||
if(EXISTS "${MYSQL_LIBRARY}" AND EXISTS "${MYSQL_INCLUDE_DIR}")
|
||||
set(MySQL_${_comp}_FOUND TRUE)
|
||||
else()
|
||||
set(MySQL_${_comp}_FOUND FALSE)
|
||||
endif()
|
||||
elseif(_comp STREQUAL "binary")
|
||||
set(MySQL_${_comp}_WANTED TRUE)
|
||||
if(MySQL_FIND_REQUIRED_${_comp})
|
||||
list(APPEND MYSQL_REQUIRED_VARS "MYSQL_EXECUTABLE")
|
||||
endif()
|
||||
if(EXISTS "${MYSQL_EXECUTABLE}" )
|
||||
set(MySQL_${_comp}_FOUND TRUE)
|
||||
else()
|
||||
set(MySQL_${_comp}_FOUND FALSE)
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "${_comp} is not a valid MySQL component")
|
||||
set(MySQL_${_comp}_FOUND FALSE)
|
||||
endif()
|
||||
endforeach()
|
||||
unset(_comp)
|
||||
|
||||
find_package_handle_standard_args(MySQL
|
||||
REQUIRED_VARS
|
||||
${MYSQL_REQUIRED_VARS}
|
||||
HANDLE_COMPONENTS
|
||||
FAIL_MESSAGE
|
||||
"Could not find the MySQL libraries! Please install the development libraries and headers"
|
||||
)
|
||||
unset(MYSQL_REQUIRED_VARS)
|
||||
|
||||
if(MySQL_lib_WANTED AND MySQL_lib_FOUND)
|
||||
try_run(MYSQL_VERSION_DETECTED MYSQL_VERSION_COMPILED ${CMAKE_BINARY_DIR}
|
||||
SOURCES "${CMAKE_CURRENT_LIST_DIR}/FindMySQLVersion.c"
|
||||
CMAKE_FLAGS -DINCLUDE_DIRECTORIES=${MYSQL_INCLUDE_DIR}
|
||||
LINK_LIBRARIES ${MYSQL_LIBRARY}
|
||||
RUN_OUTPUT_VARIABLE MYSQL_VERSION_DETECTION_RUN_OUTPUT
|
||||
)
|
||||
|
||||
string(JSON MYSQL_VERSION GET "${MYSQL_VERSION_DETECTION_RUN_OUTPUT}" "version")
|
||||
string(JSON MYSQL_FLAVOR GET "${MYSQL_VERSION_DETECTION_RUN_OUTPUT}" "flavor")
|
||||
|
||||
if(MYSQL_MIN_VERSION_${MYSQL_FLAVOR} VERSION_GREATER MYSQL_VERSION)
|
||||
message(FATAL_ERROR "Found ${MYSQL_FLAVOR} version: \"${MYSQL_VERSION}\", but required is at least \"${MYSQL_MIN_VERSION_${MYSQL_FLAVOR}}\"")
|
||||
else()
|
||||
message(STATUS "Found ${MYSQL_FLAVOR} version: \"${MYSQL_VERSION}\", minimum required is \"${MYSQL_MIN_VERSION_${MYSQL_FLAVOR}}\"")
|
||||
endif()
|
||||
|
||||
message(STATUS "Found ${MYSQL_FLAVOR} library: ${MYSQL_LIBRARY}")
|
||||
message(STATUS "Found ${MYSQL_FLAVOR} headers: ${MYSQL_INCLUDE_DIR}")
|
||||
endif()
|
||||
if(MySQL_binary_WANTED AND MySQL_binary_FOUND)
|
||||
message(STATUS "Found MySQL executable: ${MYSQL_EXECUTABLE}")
|
||||
endif()
|
||||
mark_as_advanced(MYSQL_FOUND MYSQL_LIBRARY MYSQL_INCLUDE_DIR MYSQL_EXECUTABLE)
|
||||
|
||||
if(NOT TARGET MySQL::MySQL AND MySQL_lib_WANTED AND MySQL_lib_FOUND)
|
||||
add_library(MySQL::MySQL UNKNOWN IMPORTED)
|
||||
set_target_properties(MySQL::MySQL
|
||||
PROPERTIES
|
||||
IMPORTED_LOCATION
|
||||
"${MYSQL_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${MYSQL_INCLUDE_DIR}")
|
||||
endif()
|
||||
@@ -1,18 +0,0 @@
|
||||
#include <mysql.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("{ "
|
||||
"\"version\": \"%d.%d.%d\", "
|
||||
"\"flavor\": \"%s\""
|
||||
" }",
|
||||
MYSQL_VERSION_ID / 10000, (MYSQL_VERSION_ID / 100) % 100, MYSQL_VERSION_ID % 100,
|
||||
#ifdef MARIADB_VERSION_ID
|
||||
"MariaDB"
|
||||
#else
|
||||
"MySQL"
|
||||
#endif
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,821 +0,0 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindOpenSSL
|
||||
-----------
|
||||
|
||||
Find the OpenSSL encryption library.
|
||||
|
||||
This module finds an installed OpenSSL library and determines its version.
|
||||
|
||||
.. versionadded:: 3.19
|
||||
When a version is requested, it can be specified as a simple value or as a
|
||||
range. For a detailed description of version range usage and capabilities,
|
||||
refer to the :command:`find_package` command.
|
||||
|
||||
.. versionadded:: 3.18
|
||||
Support for OpenSSL 3.0.
|
||||
|
||||
Optional COMPONENTS
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. versionadded:: 3.12
|
||||
|
||||
This module supports two optional COMPONENTS: ``Crypto`` and ``SSL``. Both
|
||||
components have associated imported targets, as described below.
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
.. versionadded:: 3.4
|
||||
|
||||
This module defines the following :prop_tgt:`IMPORTED` targets:
|
||||
|
||||
``OpenSSL::SSL``
|
||||
The OpenSSL ``ssl`` library, if found.
|
||||
``OpenSSL::Crypto``
|
||||
The OpenSSL ``crypto`` library, if found.
|
||||
``OpenSSL::applink``
|
||||
.. versionadded:: 3.18
|
||||
|
||||
The OpenSSL ``applink`` components that might be need to be compiled into
|
||||
projects under MSVC. This target is available only if found OpenSSL version
|
||||
is not less than 0.9.8. By linking this target the above OpenSSL targets can
|
||||
be linked even if the project has different MSVC runtime configurations with
|
||||
the above OpenSSL targets. This target has no effect on platforms other than
|
||||
MSVC.
|
||||
|
||||
NOTE: Due to how ``INTERFACE_SOURCES`` are consumed by the consuming target,
|
||||
unless you certainly know what you are doing, it is always preferred to link
|
||||
``OpenSSL::applink`` target as ``PRIVATE`` and to make sure that this target is
|
||||
linked at most once for the whole dependency graph of any library or
|
||||
executable:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
target_link_libraries(myTarget PRIVATE OpenSSL::applink)
|
||||
|
||||
Otherwise you would probably encounter unexpected random problems when building
|
||||
and linking, as both the ISO C and the ISO C++ standard claims almost nothing
|
||||
about what a link process should be.
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
``OPENSSL_FOUND``
|
||||
System has the OpenSSL library. If no components are requested it only
|
||||
requires the crypto library.
|
||||
``OPENSSL_INCLUDE_DIR``
|
||||
The OpenSSL include directory.
|
||||
``OPENSSL_CRYPTO_LIBRARY``
|
||||
The OpenSSL crypto library.
|
||||
``OPENSSL_CRYPTO_LIBRARIES``
|
||||
The OpenSSL crypto library and its dependencies.
|
||||
``OPENSSL_SSL_LIBRARY``
|
||||
The OpenSSL SSL library.
|
||||
``OPENSSL_SSL_LIBRARIES``
|
||||
The OpenSSL SSL library and its dependencies.
|
||||
``OPENSSL_LIBRARIES``
|
||||
All OpenSSL libraries and their dependencies.
|
||||
``OPENSSL_VERSION``
|
||||
This is set to ``$major.$minor.$revision$patch`` (e.g. ``0.9.8s``).
|
||||
``OPENSSL_APPLINK_SOURCE``
|
||||
The sources in the target ``OpenSSL::applink`` that is mentioned above. This
|
||||
variable shall always be undefined if found openssl version is less than
|
||||
0.9.8 or if platform is not MSVC.
|
||||
|
||||
Hints
|
||||
^^^^^
|
||||
|
||||
The following variables may be set to control search behavior:
|
||||
|
||||
``OPENSSL_ROOT_DIR``
|
||||
Set to the root directory of an OpenSSL installation.
|
||||
|
||||
``OPENSSL_USE_STATIC_LIBS``
|
||||
.. versionadded:: 3.4
|
||||
|
||||
Set to ``TRUE`` to look for static libraries.
|
||||
|
||||
``OPENSSL_MSVC_STATIC_RT``
|
||||
.. versionadded:: 3.5
|
||||
|
||||
Set to ``TRUE`` to choose the MT version of the lib.
|
||||
|
||||
``ENV{PKG_CONFIG_PATH}``
|
||||
On UNIX-like systems, ``pkg-config`` is used to locate the system OpenSSL.
|
||||
Set the ``PKG_CONFIG_PATH`` environment variable to look in alternate
|
||||
locations. Useful on multi-lib systems.
|
||||
#]=======================================================================]
|
||||
|
||||
macro(_OpenSSL_test_and_find_dependencies ssl_library crypto_library)
|
||||
unset(_OpenSSL_extra_static_deps)
|
||||
if(UNIX AND
|
||||
(("${ssl_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$") OR
|
||||
("${crypto_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")))
|
||||
set(_OpenSSL_has_dependencies TRUE)
|
||||
unset(_OpenSSL_has_dependency_zlib)
|
||||
if(OPENSSL_USE_STATIC_LIBS)
|
||||
set(_OpenSSL_libs "${_OPENSSL_STATIC_LIBRARIES}")
|
||||
set(_OpenSSL_ldflags_other "${_OPENSSL_STATIC_LDFLAGS_OTHER}")
|
||||
else()
|
||||
set(_OpenSSL_libs "${_OPENSSL_LIBRARIES}")
|
||||
set(_OpenSSL_ldflags_other "${_OPENSSL_LDFLAGS_OTHER}")
|
||||
endif()
|
||||
if(_OpenSSL_libs)
|
||||
unset(_OpenSSL_has_dependency_dl)
|
||||
foreach(_OPENSSL_DEP_LIB IN LISTS _OpenSSL_libs)
|
||||
if (_OPENSSL_DEP_LIB STREQUAL "ssl" OR _OPENSSL_DEP_LIB STREQUAL "crypto")
|
||||
# ignoring: these are the targets
|
||||
elseif(_OPENSSL_DEP_LIB STREQUAL CMAKE_DL_LIBS)
|
||||
set(_OpenSSL_has_dependency_dl TRUE)
|
||||
elseif(_OPENSSL_DEP_LIB STREQUAL "z")
|
||||
find_package(ZLIB)
|
||||
set(_OpenSSL_has_dependency_zlib TRUE)
|
||||
else()
|
||||
list(APPEND _OpenSSL_extra_static_deps "${_OPENSSL_DEP_LIB}")
|
||||
endif()
|
||||
endforeach()
|
||||
unset(_OPENSSL_DEP_LIB)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(_OpenSSL_has_dependency_dl TRUE)
|
||||
endif()
|
||||
if(_OpenSSL_ldflags_other)
|
||||
unset(_OpenSSL_has_dependency_threads)
|
||||
foreach(_OPENSSL_DEP_LDFLAG IN LISTS _OpenSSL_ldflags_other)
|
||||
if (_OPENSSL_DEP_LDFLAG STREQUAL "-pthread")
|
||||
set(_OpenSSL_has_dependency_threads TRUE)
|
||||
find_package(Threads)
|
||||
endif()
|
||||
endforeach()
|
||||
unset(_OPENSSL_DEP_LDFLAG)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(_OpenSSL_has_dependency_threads TRUE)
|
||||
find_package(Threads)
|
||||
endif()
|
||||
unset(_OpenSSL_libs)
|
||||
unset(_OpenSSL_ldflags_other)
|
||||
else()
|
||||
set(_OpenSSL_has_dependencies FALSE)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
function(_OpenSSL_add_dependencies libraries_var)
|
||||
if(_OpenSSL_has_dependency_zlib)
|
||||
list(APPEND ${libraries_var} ${ZLIB_LIBRARY})
|
||||
endif()
|
||||
if(_OpenSSL_has_dependency_threads)
|
||||
list(APPEND ${libraries_var} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
if(_OpenSSL_has_dependency_dl)
|
||||
list(APPEND ${libraries_var} ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
list(APPEND ${libraries_var} ${_OpenSSL_extra_static_deps})
|
||||
set(${libraries_var} ${${libraries_var}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(_OpenSSL_target_add_dependencies target)
|
||||
if(_OpenSSL_has_dependencies)
|
||||
if(_OpenSSL_has_dependency_zlib)
|
||||
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ZLIB::ZLIB )
|
||||
endif()
|
||||
if(_OpenSSL_has_dependency_threads)
|
||||
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads)
|
||||
endif()
|
||||
if(_OpenSSL_has_dependency_dl)
|
||||
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS} )
|
||||
endif()
|
||||
if(_OpenSSL_extra_static_deps)
|
||||
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${_OpenSSL_extra_static_deps})
|
||||
endif()
|
||||
endif()
|
||||
if(WIN32 AND OPENSSL_USE_STATIC_LIBS)
|
||||
if(WINCE)
|
||||
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ws2 )
|
||||
else()
|
||||
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ws2_32 )
|
||||
endif()
|
||||
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES crypt32 )
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if (UNIX)
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(_OPENSSL QUIET openssl)
|
||||
endif ()
|
||||
|
||||
# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
|
||||
if(OPENSSL_USE_STATIC_LIBS)
|
||||
set(_openssl_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
if(MSVC)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
else()
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .a )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "QNX" AND
|
||||
CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL "7.0" AND CMAKE_SYSTEM_VERSION VERSION_LESS "7.1" AND
|
||||
OpenSSL_FIND_VERSION VERSION_GREATER_EQUAL "1.1" AND OpenSSL_FIND_VERSION VERSION_LESS "1.2")
|
||||
# QNX 7.0.x provides openssl 1.0.2 and 1.1.1 in parallel:
|
||||
# * openssl 1.0.2: libcrypto.so.2 and libssl.so.2, headers under usr/include/openssl
|
||||
# * openssl 1.1.1: libcrypto1_1.so.2.1 and libssl1_1.so.2.1, header under usr/include/openssl1_1
|
||||
# See http://www.qnx.com/developers/articles/rel_6726_0.html
|
||||
set(_OPENSSL_FIND_PATH_SUFFIX "openssl1_1")
|
||||
set(_OPENSSL_NAME_POSTFIX "1_1")
|
||||
else()
|
||||
set(_OPENSSL_FIND_PATH_SUFFIX "include")
|
||||
endif()
|
||||
|
||||
if (OPENSSL_ROOT_DIR OR NOT "$ENV{OPENSSL_ROOT_DIR}" STREQUAL "")
|
||||
set(_OPENSSL_ROOT_HINTS HINTS ${OPENSSL_ROOT_DIR} ENV OPENSSL_ROOT_DIR)
|
||||
set(_OPENSSL_ROOT_PATHS NO_DEFAULT_PATH)
|
||||
elseif (MSVC)
|
||||
# http://www.slproweb.com/products/Win32OpenSSL.html
|
||||
set(_OPENSSL_MSI_INSTALL_GUIDS "")
|
||||
|
||||
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
|
||||
if(TRINITY_SYSTEM_PROCESSOR STREQUAL "arm64")
|
||||
set(_arch "Win64-ARM")
|
||||
set(_OPENSSL_MSI_INSTALL_GUIDS "99C28AFA-6419-40B1-B88D-32B810BB4234")
|
||||
else()
|
||||
set(_arch "Win64")
|
||||
set(_OPENSSL_MSI_INSTALL_GUIDS "117551DB-A110-4BBD-BB05-CFE0BCB3ED31" "50A9FBE2-0F8C-4D5D-97A4-A63A71C4EA1E")
|
||||
endif()
|
||||
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
|
||||
set(_OPENSSL_ROOT_HINTS HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]")
|
||||
else()
|
||||
set(_arch "Win32")
|
||||
set(_progfiles_x86 "ProgramFiles(x86)")
|
||||
if(NOT "$ENV{${_progfiles_x86}}" STREQUAL "")
|
||||
# under windows 64 bit machine
|
||||
file(TO_CMAKE_PATH "$ENV{${_progfiles_x86}}" _programfiles)
|
||||
else()
|
||||
# under windows 32 bit machine
|
||||
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" _programfiles)
|
||||
endif()
|
||||
set(_OPENSSL_ROOT_HINTS HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]")
|
||||
set(_OPENSSL_MSI_INSTALL_GUIDS "A1EEC576-43B9-4E75-9E02-03DA542D2A38" "31D2408A-9CAE-4988-9EC3-F40FDE7D6AE5")
|
||||
endif()
|
||||
|
||||
# If OpenSSL was installed using .msi package instead of .exe, Inno Setup registry values are not written to Uninstall\OpenSSL
|
||||
# but because it is only a shim around Inno Setup it does write the location of uninstaller which we can use to determine path
|
||||
foreach(_OPENSSL_MSI_INSTALL_GUID IN LISTS _OPENSSL_MSI_INSTALL_GUIDS)
|
||||
get_filename_component(_OPENSSL_MSI_INSTALL_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Inno Setup MSIs\\${_OPENSSL_MSI_INSTALL_GUID};]" DIRECTORY)
|
||||
if(NOT _OPENSSL_MSI_INSTALL_PATH STREQUAL "/")
|
||||
list(INSERT _OPENSSL_ROOT_HINTS 2 ${_OPENSSL_MSI_INSTALL_PATH})
|
||||
endif()
|
||||
endforeach()
|
||||
unset(_OPENSSL_MSI_INSTALL_GUIDS)
|
||||
|
||||
set(_OPENSSL_ROOT_PATHS
|
||||
PATHS
|
||||
"${_programfiles}/OpenSSL"
|
||||
"${_programfiles}/OpenSSL-${_arch}"
|
||||
"C:/OpenSSL/"
|
||||
"C:/OpenSSL-${_arch}/"
|
||||
)
|
||||
unset(_programfiles)
|
||||
unset(_arch)
|
||||
endif ()
|
||||
|
||||
if(HOMEBREW_PREFIX)
|
||||
list(APPEND _OPENSSL_ROOT_HINTS
|
||||
"${HOMEBREW_PREFIX}/opt/openssl@3")
|
||||
endif()
|
||||
|
||||
set(_OPENSSL_ROOT_HINTS_AND_PATHS
|
||||
${_OPENSSL_ROOT_HINTS}
|
||||
${_OPENSSL_ROOT_PATHS}
|
||||
)
|
||||
|
||||
find_path(OPENSSL_INCLUDE_DIR
|
||||
NAMES
|
||||
openssl/ssl.h
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
HINTS
|
||||
${_OPENSSL_INCLUDEDIR}
|
||||
${_OPENSSL_INCLUDE_DIRS}
|
||||
PATH_SUFFIXES
|
||||
${_OPENSSL_FIND_PATH_SUFFIX}
|
||||
)
|
||||
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
if(MSVC)
|
||||
# /MD and /MDd are the standard values - if someone wants to use
|
||||
# others, the libnames have to change here too
|
||||
# use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b
|
||||
# enable OPENSSL_MSVC_STATIC_RT to get the libs build /MT (Multithreaded no-DLL)
|
||||
# In Visual C++ naming convention each of these four kinds of Windows libraries has it's standard suffix:
|
||||
# * MD for dynamic-release
|
||||
# * MDd for dynamic-debug
|
||||
# * MT for static-release
|
||||
# * MTd for static-debug
|
||||
|
||||
# Implementation details:
|
||||
# We are using the libraries located in the VC subdir instead of the parent directory even though :
|
||||
# libeay32MD.lib is identical to ../libeay32.lib, and
|
||||
# ssleay32MD.lib is identical to ../ssleay32.lib
|
||||
# enable OPENSSL_USE_STATIC_LIBS to use the static libs located in lib/VC/static
|
||||
|
||||
if (OPENSSL_MSVC_STATIC_RT)
|
||||
set(_OPENSSL_MSVC_RT_MODE "MT")
|
||||
else ()
|
||||
set(_OPENSSL_MSVC_RT_MODE "MD")
|
||||
endif ()
|
||||
|
||||
# Since OpenSSL 1.1, lib names are like libcrypto32MTd.lib and libssl32MTd.lib
|
||||
if( "${CMAKE_SIZEOF_VOID_P}" STREQUAL "8" )
|
||||
set(_OPENSSL_MSVC_ARCH_SUFFIX "64")
|
||||
if(TRINITY_SYSTEM_PROCESSOR STREQUAL "arm64")
|
||||
set(_OPENSSL_MSVC_ARCH_DIRECTORY "arm64")
|
||||
else()
|
||||
set(_OPENSSL_MSVC_ARCH_DIRECTORY "x64")
|
||||
endif()
|
||||
else()
|
||||
set(_OPENSSL_MSVC_ARCH_SUFFIX "32")
|
||||
set(_OPENSSL_MSVC_ARCH_DIRECTORY "x86")
|
||||
endif()
|
||||
|
||||
if(OPENSSL_USE_STATIC_LIBS)
|
||||
set(_OPENSSL_STATIC_SUFFIX
|
||||
"_static"
|
||||
)
|
||||
set(_OPENSSL_PATH_SUFFIXES
|
||||
"lib/VC/static"
|
||||
"VC/static"
|
||||
"lib"
|
||||
)
|
||||
else()
|
||||
set(_OPENSSL_STATIC_SUFFIX
|
||||
""
|
||||
)
|
||||
set(_OPENSSL_PATH_SUFFIXES
|
||||
"lib/VC"
|
||||
"VC"
|
||||
"lib"
|
||||
)
|
||||
endif ()
|
||||
|
||||
find_library(LIB_EAY_DEBUG
|
||||
NAMES
|
||||
libcrypto${_OPENSSL_STATIC_SUFFIX}
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES
|
||||
"lib/VC/${_OPENSSL_MSVC_ARCH_DIRECTORY}/${_OPENSSL_MSVC_RT_MODE}d"
|
||||
)
|
||||
|
||||
if(NOT LIB_EAY_DEBUG)
|
||||
find_library(LIB_EAY_DEBUG
|
||||
NAMES
|
||||
# When OpenSSL is built with default options, the static library name is suffixed with "_static".
|
||||
# Looking the "libcrypto_static.lib" with a higher priority than "libcrypto.lib" which is the
|
||||
# import library of "libcrypto.dll".
|
||||
libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||
libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||
libcrypto${_OPENSSL_STATIC_SUFFIX}d
|
||||
libeay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||
libeay32${_OPENSSL_STATIC_SUFFIX}d
|
||||
crypto${_OPENSSL_STATIC_SUFFIX}d
|
||||
# When OpenSSL is built with the "-static" option, only the static build is produced,
|
||||
# and it is not suffixed with "_static".
|
||||
libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||
libcrypto${_OPENSSL_MSVC_RT_MODE}d
|
||||
libcryptod
|
||||
libeay32${_OPENSSL_MSVC_RT_MODE}d
|
||||
libeay32d
|
||||
cryptod
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES
|
||||
${_OPENSSL_PATH_SUFFIXES}
|
||||
)
|
||||
endif()
|
||||
|
||||
find_library(LIB_EAY_RELEASE
|
||||
NAMES
|
||||
# When OpenSSL is built with default options, the static library name is suffixed with "_static".
|
||||
# Looking the "libcrypto_static.lib" with a higher priority than "libcrypto.lib" which is the
|
||||
# import library of "libcrypto.dll".
|
||||
libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||
libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||
libcrypto${_OPENSSL_STATIC_SUFFIX}
|
||||
libeay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||
libeay32${_OPENSSL_STATIC_SUFFIX}
|
||||
crypto${_OPENSSL_STATIC_SUFFIX}
|
||||
# When OpenSSL is built with the "-static" option, only the static build is produced,
|
||||
# and it is not suffixed with "_static".
|
||||
libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||
libcrypto${_OPENSSL_MSVC_RT_MODE}
|
||||
libcrypto
|
||||
libeay32${_OPENSSL_MSVC_RT_MODE}
|
||||
libeay32
|
||||
crypto
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES
|
||||
${_OPENSSL_PATH_SUFFIXES}
|
||||
"lib/VC/${_OPENSSL_MSVC_ARCH_DIRECTORY}/${_OPENSSL_MSVC_RT_MODE}"
|
||||
)
|
||||
|
||||
find_library(SSL_EAY_DEBUG
|
||||
NAMES
|
||||
libssl${_OPENSSL_STATIC_SUFFIX}
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES
|
||||
"lib/VC/${_OPENSSL_MSVC_ARCH_DIRECTORY}/${_OPENSSL_MSVC_RT_MODE}d"
|
||||
)
|
||||
|
||||
if(NOT SSL_EAY_DEBUG)
|
||||
find_library(SSL_EAY_DEBUG
|
||||
NAMES
|
||||
# When OpenSSL is built with default options, the static library name is suffixed with "_static".
|
||||
# Looking the "libssl_static.lib" with a higher priority than "libssl.lib" which is the
|
||||
# import library of "libssl.dll".
|
||||
libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||
libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||
libssl${_OPENSSL_STATIC_SUFFIX}d
|
||||
ssleay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||
ssleay32${_OPENSSL_STATIC_SUFFIX}d
|
||||
ssl${_OPENSSL_STATIC_SUFFIX}d
|
||||
# When OpenSSL is built with the "-static" option, only the static build is produced,
|
||||
# and it is not suffixed with "_static".
|
||||
libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||
libssl${_OPENSSL_MSVC_RT_MODE}d
|
||||
libssld
|
||||
ssleay32${_OPENSSL_MSVC_RT_MODE}d
|
||||
ssleay32d
|
||||
ssld
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES
|
||||
${_OPENSSL_PATH_SUFFIXES}
|
||||
)
|
||||
endif()
|
||||
|
||||
find_library(SSL_EAY_RELEASE
|
||||
NAMES
|
||||
# When OpenSSL is built with default options, the static library name is suffixed with "_static".
|
||||
# Looking the "libssl_static.lib" with a higher priority than "libssl.lib" which is the
|
||||
# import library of "libssl.dll".
|
||||
libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||
libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||
libssl${_OPENSSL_STATIC_SUFFIX}
|
||||
ssleay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||
ssleay32${_OPENSSL_STATIC_SUFFIX}
|
||||
ssl${_OPENSSL_STATIC_SUFFIX}
|
||||
# When OpenSSL is built with the "-static" option, only the static build is produced,
|
||||
# and it is not suffixed with "_static".
|
||||
libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||
libssl${_OPENSSL_MSVC_RT_MODE}
|
||||
libssl
|
||||
ssleay32${_OPENSSL_MSVC_RT_MODE}
|
||||
ssleay32
|
||||
ssl
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES
|
||||
${_OPENSSL_PATH_SUFFIXES}
|
||||
"lib/VC/${_OPENSSL_MSVC_ARCH_DIRECTORY}/${_OPENSSL_MSVC_RT_MODE}"
|
||||
)
|
||||
|
||||
set(LIB_EAY_LIBRARY_DEBUG "${LIB_EAY_DEBUG}")
|
||||
set(LIB_EAY_LIBRARY_RELEASE "${LIB_EAY_RELEASE}")
|
||||
set(SSL_EAY_LIBRARY_DEBUG "${SSL_EAY_DEBUG}")
|
||||
set(SSL_EAY_LIBRARY_RELEASE "${SSL_EAY_RELEASE}")
|
||||
|
||||
include(SelectLibraryConfigurations)
|
||||
select_library_configurations(LIB_EAY)
|
||||
select_library_configurations(SSL_EAY)
|
||||
|
||||
mark_as_advanced(LIB_EAY_LIBRARY_DEBUG LIB_EAY_LIBRARY_RELEASE
|
||||
SSL_EAY_LIBRARY_DEBUG SSL_EAY_LIBRARY_RELEASE)
|
||||
set(OPENSSL_SSL_LIBRARY ${SSL_EAY_LIBRARY} )
|
||||
set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY_LIBRARY} )
|
||||
elseif(MINGW)
|
||||
# same player, for MinGW
|
||||
set(LIB_EAY_NAMES crypto libeay32)
|
||||
set(SSL_EAY_NAMES ssl ssleay32)
|
||||
find_library(LIB_EAY
|
||||
NAMES
|
||||
${LIB_EAY_NAMES}
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES
|
||||
"lib/MinGW"
|
||||
"lib"
|
||||
"lib64"
|
||||
)
|
||||
|
||||
find_library(SSL_EAY
|
||||
NAMES
|
||||
${SSL_EAY_NAMES}
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES
|
||||
"lib/MinGW"
|
||||
"lib"
|
||||
"lib64"
|
||||
)
|
||||
|
||||
mark_as_advanced(SSL_EAY LIB_EAY)
|
||||
set(OPENSSL_SSL_LIBRARY ${SSL_EAY} )
|
||||
set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} )
|
||||
unset(LIB_EAY_NAMES)
|
||||
unset(SSL_EAY_NAMES)
|
||||
else()
|
||||
# Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues:
|
||||
find_library(LIB_EAY
|
||||
NAMES
|
||||
libcrypto
|
||||
libeay32
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
HINTS
|
||||
${_OPENSSL_LIBDIR}
|
||||
PATH_SUFFIXES
|
||||
lib
|
||||
)
|
||||
|
||||
find_library(SSL_EAY
|
||||
NAMES
|
||||
libssl
|
||||
ssleay32
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
HINTS
|
||||
${_OPENSSL_LIBDIR}
|
||||
PATH_SUFFIXES
|
||||
lib
|
||||
)
|
||||
|
||||
mark_as_advanced(SSL_EAY LIB_EAY)
|
||||
set(OPENSSL_SSL_LIBRARY ${SSL_EAY} )
|
||||
set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} )
|
||||
endif()
|
||||
else()
|
||||
|
||||
find_library(OPENSSL_SSL_LIBRARY
|
||||
NAMES
|
||||
ssl${_OPENSSL_NAME_POSTFIX}
|
||||
ssleay32
|
||||
ssleay32MD
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
HINTS
|
||||
${_OPENSSL_LIBDIR}
|
||||
${_OPENSSL_LIBRARY_DIRS}
|
||||
PATH_SUFFIXES
|
||||
lib lib64
|
||||
)
|
||||
|
||||
find_library(OPENSSL_CRYPTO_LIBRARY
|
||||
NAMES
|
||||
crypto${_OPENSSL_NAME_POSTFIX}
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
HINTS
|
||||
${_OPENSSL_LIBDIR}
|
||||
${_OPENSSL_LIBRARY_DIRS}
|
||||
PATH_SUFFIXES
|
||||
lib lib64
|
||||
)
|
||||
|
||||
mark_as_advanced(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY)
|
||||
|
||||
endif()
|
||||
|
||||
set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY})
|
||||
set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
||||
set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES} )
|
||||
_OpenSSL_test_and_find_dependencies("${OPENSSL_SSL_LIBRARY}" "${OPENSSL_CRYPTO_LIBRARY}")
|
||||
if(_OpenSSL_has_dependencies)
|
||||
_OpenSSL_add_dependencies( OPENSSL_SSL_LIBRARIES )
|
||||
_OpenSSL_add_dependencies( OPENSSL_CRYPTO_LIBRARIES )
|
||||
_OpenSSL_add_dependencies( OPENSSL_LIBRARIES )
|
||||
endif()
|
||||
|
||||
function(from_hex HEX DEC)
|
||||
string(TOUPPER "${HEX}" HEX)
|
||||
set(_res 0)
|
||||
string(LENGTH "${HEX}" _strlen)
|
||||
|
||||
while (_strlen GREATER 0)
|
||||
math(EXPR _res "${_res} * 16")
|
||||
string(SUBSTRING "${HEX}" 0 1 NIBBLE)
|
||||
string(SUBSTRING "${HEX}" 1 -1 HEX)
|
||||
if (NIBBLE STREQUAL "A")
|
||||
math(EXPR _res "${_res} + 10")
|
||||
elseif (NIBBLE STREQUAL "B")
|
||||
math(EXPR _res "${_res} + 11")
|
||||
elseif (NIBBLE STREQUAL "C")
|
||||
math(EXPR _res "${_res} + 12")
|
||||
elseif (NIBBLE STREQUAL "D")
|
||||
math(EXPR _res "${_res} + 13")
|
||||
elseif (NIBBLE STREQUAL "E")
|
||||
math(EXPR _res "${_res} + 14")
|
||||
elseif (NIBBLE STREQUAL "F")
|
||||
math(EXPR _res "${_res} + 15")
|
||||
else()
|
||||
math(EXPR _res "${_res} + ${NIBBLE}")
|
||||
endif()
|
||||
|
||||
string(LENGTH "${HEX}" _strlen)
|
||||
endwhile()
|
||||
|
||||
set(${DEC} ${_res} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h")
|
||||
file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str
|
||||
REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*")
|
||||
|
||||
if(openssl_version_str)
|
||||
# The version number is encoded as 0xMNNFFPPS: major minor fix patch status
|
||||
# The status gives if this is a developer or prerelease and is ignored here.
|
||||
# Major, minor, and fix directly translate into the version numbers shown in
|
||||
# the string. The patch field translates to the single character suffix that
|
||||
# indicates the bug fix state, which 00 -> nothing, 01 -> a, 02 -> b and so
|
||||
# on.
|
||||
|
||||
string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F]).*$"
|
||||
"\\1;\\2;\\3;\\4;\\5" OPENSSL_VERSION_LIST "${openssl_version_str}")
|
||||
list(GET OPENSSL_VERSION_LIST 0 OPENSSL_VERSION_MAJOR)
|
||||
list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR)
|
||||
from_hex("${OPENSSL_VERSION_MINOR}" OPENSSL_VERSION_MINOR)
|
||||
list(GET OPENSSL_VERSION_LIST 2 OPENSSL_VERSION_FIX)
|
||||
from_hex("${OPENSSL_VERSION_FIX}" OPENSSL_VERSION_FIX)
|
||||
list(GET OPENSSL_VERSION_LIST 3 OPENSSL_VERSION_PATCH)
|
||||
|
||||
if (NOT OPENSSL_VERSION_PATCH STREQUAL "00")
|
||||
from_hex("${OPENSSL_VERSION_PATCH}" _tmp)
|
||||
# 96 is the ASCII code of 'a' minus 1
|
||||
math(EXPR OPENSSL_VERSION_PATCH_ASCII "${_tmp} + 96")
|
||||
unset(_tmp)
|
||||
# Once anyone knows how OpenSSL would call the patch versions beyond 'z'
|
||||
# this should be updated to handle that, too. This has not happened yet
|
||||
# so it is simply ignored here for now.
|
||||
string(ASCII "${OPENSSL_VERSION_PATCH_ASCII}" OPENSSL_VERSION_PATCH_STRING)
|
||||
endif ()
|
||||
|
||||
set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}${OPENSSL_VERSION_PATCH_STRING}")
|
||||
else ()
|
||||
# Since OpenSSL 3.0.0, the new version format is MAJOR.MINOR.PATCH and
|
||||
# a new OPENSSL_VERSION_STR macro contains exactly that
|
||||
file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" OPENSSL_VERSION_STR
|
||||
REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_STR[\t ]+\"([0-9])+\\.([0-9])+\\.([0-9])+\".*")
|
||||
string(REGEX REPLACE "^.*OPENSSL_VERSION_STR[\t ]+\"([0-9]+\\.[0-9]+\\.[0-9]+)\".*$"
|
||||
"\\1" OPENSSL_VERSION_STR "${OPENSSL_VERSION_STR}")
|
||||
|
||||
set(OPENSSL_VERSION "${OPENSSL_VERSION_STR}")
|
||||
|
||||
unset(OPENSSL_VERSION_STR)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
foreach(_comp IN LISTS OpenSSL_FIND_COMPONENTS)
|
||||
if(_comp STREQUAL "Crypto")
|
||||
if(EXISTS "${OPENSSL_INCLUDE_DIR}" AND
|
||||
(EXISTS "${OPENSSL_CRYPTO_LIBRARY}" OR
|
||||
EXISTS "${LIB_EAY_LIBRARY_DEBUG}" OR
|
||||
EXISTS "${LIB_EAY_LIBRARY_RELEASE}")
|
||||
)
|
||||
set(OpenSSL_${_comp}_FOUND TRUE)
|
||||
else()
|
||||
set(OpenSSL_${_comp}_FOUND FALSE)
|
||||
endif()
|
||||
elseif(_comp STREQUAL "SSL")
|
||||
if(EXISTS "${OPENSSL_INCLUDE_DIR}" AND
|
||||
(EXISTS "${OPENSSL_SSL_LIBRARY}" OR
|
||||
EXISTS "${SSL_EAY_LIBRARY_DEBUG}" OR
|
||||
EXISTS "${SSL_EAY_LIBRARY_RELEASE}")
|
||||
)
|
||||
set(OpenSSL_${_comp}_FOUND TRUE)
|
||||
else()
|
||||
set(OpenSSL_${_comp}_FOUND FALSE)
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "${_comp} is not a valid OpenSSL component")
|
||||
set(OpenSSL_${_comp}_FOUND FALSE)
|
||||
endif()
|
||||
endforeach()
|
||||
unset(_comp)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(OpenSSL
|
||||
REQUIRED_VARS
|
||||
OPENSSL_CRYPTO_LIBRARY
|
||||
OPENSSL_INCLUDE_DIR
|
||||
VERSION_VAR
|
||||
OPENSSL_VERSION
|
||||
HANDLE_COMPONENTS
|
||||
FAIL_MESSAGE
|
||||
"Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR"
|
||||
)
|
||||
|
||||
mark_as_advanced(OPENSSL_INCLUDE_DIR)
|
||||
|
||||
if(OPENSSL_FOUND)
|
||||
if(NOT TARGET OpenSSL::Crypto AND
|
||||
(EXISTS "${OPENSSL_CRYPTO_LIBRARY}" OR
|
||||
EXISTS "${LIB_EAY_LIBRARY_DEBUG}" OR
|
||||
EXISTS "${LIB_EAY_LIBRARY_RELEASE}")
|
||||
)
|
||||
add_library(OpenSSL::Crypto UNKNOWN IMPORTED)
|
||||
set_target_properties(OpenSSL::Crypto PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}")
|
||||
if(EXISTS "${OPENSSL_CRYPTO_LIBRARY}")
|
||||
set_target_properties(OpenSSL::Crypto PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${OPENSSL_CRYPTO_LIBRARY}")
|
||||
endif()
|
||||
if(EXISTS "${LIB_EAY_LIBRARY_RELEASE}")
|
||||
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(OpenSSL::Crypto PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
|
||||
IMPORTED_LOCATION_RELEASE "${LIB_EAY_LIBRARY_RELEASE}")
|
||||
endif()
|
||||
if(EXISTS "${LIB_EAY_LIBRARY_DEBUG}")
|
||||
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(OpenSSL::Crypto PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
|
||||
IMPORTED_LOCATION_DEBUG "${LIB_EAY_LIBRARY_DEBUG}")
|
||||
endif()
|
||||
_OpenSSL_target_add_dependencies(OpenSSL::Crypto)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET OpenSSL::SSL AND
|
||||
(EXISTS "${OPENSSL_SSL_LIBRARY}" OR
|
||||
EXISTS "${SSL_EAY_LIBRARY_DEBUG}" OR
|
||||
EXISTS "${SSL_EAY_LIBRARY_RELEASE}")
|
||||
)
|
||||
add_library(OpenSSL::SSL UNKNOWN IMPORTED)
|
||||
set_target_properties(OpenSSL::SSL PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}")
|
||||
if(EXISTS "${OPENSSL_SSL_LIBRARY}")
|
||||
set_target_properties(OpenSSL::SSL PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${OPENSSL_SSL_LIBRARY}")
|
||||
endif()
|
||||
if(EXISTS "${SSL_EAY_LIBRARY_RELEASE}")
|
||||
set_property(TARGET OpenSSL::SSL APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(OpenSSL::SSL PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
|
||||
IMPORTED_LOCATION_RELEASE "${SSL_EAY_LIBRARY_RELEASE}")
|
||||
endif()
|
||||
if(EXISTS "${SSL_EAY_LIBRARY_DEBUG}")
|
||||
set_property(TARGET OpenSSL::SSL APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(OpenSSL::SSL PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
|
||||
IMPORTED_LOCATION_DEBUG "${SSL_EAY_LIBRARY_DEBUG}")
|
||||
endif()
|
||||
if(TARGET OpenSSL::Crypto)
|
||||
set_target_properties(OpenSSL::SSL PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES OpenSSL::Crypto)
|
||||
endif()
|
||||
_OpenSSL_target_add_dependencies(OpenSSL::SSL)
|
||||
endif()
|
||||
|
||||
if("${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}" VERSION_GREATER_EQUAL "0.9.8")
|
||||
if(MSVC)
|
||||
if(EXISTS "${OPENSSL_INCLUDE_DIR}")
|
||||
set(_OPENSSL_applink_paths PATHS ${OPENSSL_INCLUDE_DIR})
|
||||
endif()
|
||||
find_file(OPENSSL_APPLINK_SOURCE
|
||||
NAMES
|
||||
openssl/applink.c
|
||||
${_OPENSSL_applink_paths}
|
||||
NO_DEFAULT_PATH)
|
||||
if(OPENSSL_APPLINK_SOURCE)
|
||||
set(_OPENSSL_applink_interface_srcs ${OPENSSL_APPLINK_SOURCE})
|
||||
endif()
|
||||
endif()
|
||||
if(NOT TARGET OpenSSL::applink)
|
||||
add_library(OpenSSL::applink INTERFACE IMPORTED)
|
||||
set_property(TARGET OpenSSL::applink APPEND
|
||||
PROPERTY INTERFACE_SOURCES
|
||||
${_OPENSSL_applink_interface_srcs})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Restore the original find library ordering
|
||||
if(OPENSSL_USE_STATIC_LIBS)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_openssl_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
endif()
|
||||
|
||||
unset(_OPENSSL_FIND_PATH_SUFFIX)
|
||||
unset(_OPENSSL_NAME_POSTFIX)
|
||||
unset(_OpenSSL_extra_static_deps)
|
||||
unset(_OpenSSL_has_dependency_dl)
|
||||
unset(_OpenSSL_has_dependency_threads)
|
||||
unset(_OpenSSL_has_dependency_zlib)
|
||||
@@ -1,26 +0,0 @@
|
||||
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation; either version 2 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
function(ADD_CXX_PCH TARGET_NAME_LIST PCH_HEADER)
|
||||
foreach(TARGET_NAME ${TARGET_NAME_LIST})
|
||||
target_precompile_headers(${TARGET_NAME} PRIVATE ${PCH_HEADER})
|
||||
endforeach()
|
||||
endfunction(ADD_CXX_PCH)
|
||||
|
||||
function(REUSE_CXX_PCH TARGET_NAME_LIST REUSE_FROM_TARGET_NAME)
|
||||
foreach(TARGET_NAME ${TARGET_NAME_LIST})
|
||||
target_precompile_headers(${TARGET_NAME} REUSE_FROM ${REUSE_FROM_TARGET_NAME})
|
||||
endforeach()
|
||||
endfunction(REUSE_CXX_PCH)
|
||||
@@ -1,111 +0,0 @@
|
||||
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation; either version 2 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindReadline
|
||||
-----------
|
||||
|
||||
Find The GNU Readline Library.
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines the following :prop_tgt:`IMPORTED` targets:
|
||||
|
||||
``Readline::Readline``
|
||||
The Readline library, if found.
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
``READLINE_FOUND``
|
||||
System has The GNU Readline Library.
|
||||
``READLINE_INCLUDE_DIR``
|
||||
The Readline include directory.
|
||||
``READLINE_LIBRARY``
|
||||
The Readline library.
|
||||
|
||||
Hints
|
||||
^^^^^
|
||||
|
||||
Set ``READLINE_ROOT_DIR`` to the root directory of Readline installation.
|
||||
#]=======================================================================]
|
||||
|
||||
set(_READLINE_ROOT_HINTS
|
||||
${READLINE_ROOT_DIR}
|
||||
ENV READLINE_ROOT_DIR
|
||||
)
|
||||
|
||||
if(HOMEBREW_PREFIX)
|
||||
list(APPEND _READLINE_ROOT_HINTS "${HOMEBREW_PREFIX}/opt/readline")
|
||||
endif()
|
||||
|
||||
find_path(READLINE_INCLUDE_DIR
|
||||
NAMES
|
||||
readline/readline.h
|
||||
HINTS
|
||||
${_READLINE_ROOT_HINTS}
|
||||
PATH_SUFFIXES
|
||||
include)
|
||||
|
||||
find_library(READLINE_LIBRARY
|
||||
NAMES
|
||||
readline
|
||||
HINTS
|
||||
${_READLINE_ROOT_HINTS}
|
||||
PATH_SUFFIXES
|
||||
lib)
|
||||
|
||||
if(READLINE_INCLUDE_DIR AND EXISTS "${READLINE_INCLUDE_DIR}/readline/readline.h")
|
||||
file(STRINGS "${READLINE_INCLUDE_DIR}/readline/readline.h" readline_major
|
||||
REGEX "^#[\t ]*define[\t ]+RL_VERSION_MAJOR[\t ]+([0-9])+.*")
|
||||
file(STRINGS "${READLINE_INCLUDE_DIR}/readline/readline.h" readline_minor
|
||||
REGEX "^#[\t ]*define[\t ]+RL_VERSION_MINOR[\t ]+([0-9])+.*")
|
||||
if (readline_major AND readline_minor)
|
||||
string(REGEX REPLACE "^.*RL_VERSION_MAJOR[\t ]+([0-9])+.*$"
|
||||
"\\1" readline_major "${readline_major}")
|
||||
string(REGEX REPLACE "^.*RL_VERSION_MINOR[\t ]+([0-9])+.*$"
|
||||
"\\1" readline_minor "${readline_minor}")
|
||||
set(READLINE_VERSION "${readline_major}.${readline_minor}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Readline
|
||||
REQUIRED_VARS
|
||||
READLINE_LIBRARY
|
||||
READLINE_INCLUDE_DIR
|
||||
VERSION_VAR
|
||||
READLINE_VERSION
|
||||
)
|
||||
|
||||
mark_as_advanced(READLINE_FOUND READLINE_LIBRARY READLINE_INCLUDE_DIR)
|
||||
|
||||
if(READLINE_FOUND)
|
||||
message(STATUS "Found Readline library: ${READLINE_LIBRARY}")
|
||||
message(STATUS "Found Readline headers: ${READLINE_INCLUDE_DIR}")
|
||||
|
||||
if (NOT TARGET Readline::Readline)
|
||||
add_library(Readline::Readline UNKNOWN IMPORTED)
|
||||
set_target_properties(Readline::Readline
|
||||
PROPERTIES
|
||||
IMPORTED_LOCATION
|
||||
"${READLINE_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${READLINE_INCLUDE_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
@@ -1,51 +0,0 @@
|
||||
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
macro(GroupSources dir)
|
||||
# Skip this if WITH_SOURCE_TREE is not set (empty string).
|
||||
if(NOT ${WITH_SOURCE_TREE} STREQUAL "")
|
||||
# Include all header and c files
|
||||
file(GLOB_RECURSE elements RELATIVE ${dir} *.h *.hpp *.c *.cpp *.cc)
|
||||
|
||||
foreach(element ${elements})
|
||||
# Extract filename and directory
|
||||
get_filename_component(element_name ${element} NAME)
|
||||
get_filename_component(element_dir ${element} DIRECTORY)
|
||||
|
||||
if(NOT ${element_dir} STREQUAL "")
|
||||
# If the file is in a subdirectory use it as source group.
|
||||
if(${WITH_SOURCE_TREE} STREQUAL "flat")
|
||||
# Build flat structure by using only the first subdirectory.
|
||||
string(FIND ${element_dir} "/" delemiter_pos)
|
||||
if(NOT ${delemiter_pos} EQUAL -1)
|
||||
string(SUBSTRING ${element_dir} 0 ${delemiter_pos} group_name)
|
||||
source_group("${group_name}" FILES ${dir}/${element})
|
||||
else()
|
||||
# Build hierarchical structure.
|
||||
# File is in root directory.
|
||||
source_group("${element_dir}" FILES ${dir}/${element})
|
||||
endif()
|
||||
else()
|
||||
# Use the full hierarchical structure to build source_groups.
|
||||
string(REPLACE "/" "\\" group_name ${element_dir})
|
||||
source_group("${group_name}" FILES ${dir}/${element})
|
||||
endif()
|
||||
else()
|
||||
# If the file is in the root directory, place it in the root source_group.
|
||||
source_group("\\" FILES ${dir}/${element})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
if(WITH_SOURCE_TREE STREQUAL "hierarchical-folders")
|
||||
# Use folders
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
endif()
|
||||
@@ -1,66 +0,0 @@
|
||||
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
option(SERVERS "Build worldserver and bnetserver" 1)
|
||||
|
||||
set(SCRIPTS_AVAILABLE_OPTIONS none static dynamic minimal-static minimal-dynamic)
|
||||
|
||||
# Log a fatal error when the value of the SCRIPTS variable isn't a valid option.
|
||||
if(SCRIPTS)
|
||||
list(FIND SCRIPTS_AVAILABLE_OPTIONS "${SCRIPTS}" SCRIPTS_INDEX)
|
||||
if(${SCRIPTS_INDEX} EQUAL -1)
|
||||
message(FATAL_ERROR "The value (${SCRIPTS}) of your SCRIPTS variable is invalid! "
|
||||
"Allowed values are: ${SCRIPTS_AVAILABLE_OPTIONS} if you still "
|
||||
"have problems search on forum for TCE00019.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(SCRIPTS "static" CACHE STRING "Build core with scripts")
|
||||
set_property(CACHE SCRIPTS PROPERTY STRINGS ${SCRIPTS_AVAILABLE_OPTIONS})
|
||||
|
||||
# Build a list of all script modules when -DSCRIPT="custom" is selected
|
||||
GetScriptModuleList(SCRIPT_MODULE_LIST)
|
||||
foreach(SCRIPT_MODULE ${SCRIPT_MODULE_LIST})
|
||||
ScriptModuleNameToVariable(${SCRIPT_MODULE} SCRIPT_MODULE_VARIABLE)
|
||||
set(${SCRIPT_MODULE_VARIABLE} "default" CACHE STRING "Build type of the ${SCRIPT_MODULE} module.")
|
||||
set_property(CACHE ${SCRIPT_MODULE_VARIABLE} PROPERTY STRINGS default disabled static dynamic)
|
||||
endforeach()
|
||||
|
||||
option(TOOLS "Build map/vmap/mmap extraction/assembler tools" 1)
|
||||
option(USE_SCRIPTPCH "Use precompiled headers when compiling scripts" 1)
|
||||
option(USE_COREPCH "Use precompiled headers when compiling servers" 1)
|
||||
option(WITH_DYNAMIC_LINKING "Enable dynamic library linking." 0)
|
||||
option(WITH_FILESYSTEM_WATCHER "Include filesystem watcher library" 0)
|
||||
IsDynamicLinkingRequired(WITH_DYNAMIC_LINKING_FORCED)
|
||||
if(WITH_DYNAMIC_LINKING AND WITH_DYNAMIC_LINKING_FORCED)
|
||||
set(WITH_DYNAMIC_LINKING_FORCED OFF)
|
||||
endif()
|
||||
if(WITH_DYNAMIC_LINKING OR WITH_DYNAMIC_LINKING_FORCED)
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
else()
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
endif()
|
||||
if(WITH_FILESYSTEM_WATCHER OR BUILD_SHARED_LIBS)
|
||||
set(BUILD_EFSW ON)
|
||||
endif()
|
||||
option(WITH_WARNINGS "Show all warnings during compile" 0)
|
||||
option(WITH_WARNINGS_AS_ERRORS "Treat warnings as errors" 0)
|
||||
option(WITH_COREDEBUG "Include additional debug-code in core" 0)
|
||||
option(WITHOUT_METRICS "Disable metrics reporting (i.e. InfluxDB and Grafana)" 0)
|
||||
option(WITH_DETAILED_METRICS "Enable detailed metrics reporting (i.e. time each session takes to update)" 0)
|
||||
option(COPY_CONF "Copy authserver and worldserver .conf.dist files to the project dir" 1)
|
||||
set(WITH_SOURCE_TREE "hierarchical" CACHE STRING "Build the source tree for IDE's.")
|
||||
set_property(CACHE WITH_SOURCE_TREE PROPERTY STRINGS no flat hierarchical hierarchical-folders)
|
||||
option(WITHOUT_GIT "Disable the GIT testing routines" 0)
|
||||
option(BUILD_TESTING "Build test suite" 0)
|
||||
|
||||
if(UNIX)
|
||||
option(USE_LD_GOLD "Use GNU gold linker" 0)
|
||||
endif()
|
||||
@@ -1,23 +0,0 @@
|
||||
# from cmake wiki
|
||||
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
|
||||
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
|
||||
FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||
STRING(REGEX REPLACE "\n" ";" files "${files}")
|
||||
FOREACH(file ${files})
|
||||
MESSAGE(STATUS "Uninstalling \"${file}\"")
|
||||
IF(EXISTS "${file}")
|
||||
EXEC_PROGRAM(
|
||||
"@CMAKE_COMMAND@" ARGS "-E remove \"${file}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
IF("${rm_retval}" STREQUAL 0)
|
||||
ELSE("${rm_retval}" STREQUAL 0)
|
||||
MESSAGE(FATAL_ERROR "Problem when removing \"${file}\"")
|
||||
ENDIF("${rm_retval}" STREQUAL 0)
|
||||
ELSE(EXISTS "${file}")
|
||||
MESSAGE(STATUS "File \"${file}\" does not exist.")
|
||||
ENDIF(EXISTS "${file}")
|
||||
ENDFOREACH(file)
|
||||
@@ -1,51 +0,0 @@
|
||||
# set default configuration directory
|
||||
if(NOT CONF_DIR)
|
||||
set(CONF_DIR ${CMAKE_INSTALL_PREFIX}/etc CACHE PATH "Configuration directory")
|
||||
message(STATUS "UNIX: Using default configuration directory")
|
||||
endif()
|
||||
|
||||
# configure uninstaller
|
||||
configure_file(
|
||||
"${CMAKE_SOURCE_DIR}/cmake/platform/cmake_uninstall.in.cmake"
|
||||
"${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
@ONLY
|
||||
)
|
||||
message(STATUS "UNIX: Configuring uninstall target")
|
||||
|
||||
# create uninstaller target (allows for using "make uninstall")
|
||||
add_custom_target(uninstall
|
||||
"${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
)
|
||||
message(STATUS "UNIX: Created uninstall target")
|
||||
|
||||
if(USE_LD_GOLD)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
|
||||
if("${LD_VERSION}" MATCHES "GNU gold")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold")
|
||||
message(STATUS "UNIX: Using GNU gold linker")
|
||||
else()
|
||||
message(WARNING "UNIX: GNU gold linker isn't available, using the default system linker")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "UNIX: Using default system linker")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
find_program(HOMEBREW_EXECUTABLE brew)
|
||||
|
||||
if (HOMEBREW_EXECUTABLE)
|
||||
# setup homebrew paths
|
||||
message(STATUS "Homebrew found at ${HOMEBREW_EXECUTABLE}")
|
||||
execute_process(COMMAND ${HOMEBREW_EXECUTABLE} config OUTPUT_VARIABLE HOMEBREW_STATUS_STR)
|
||||
string(REGEX MATCH "HOMEBREW_PREFIX: ([^\n]*)" HOMEBREW_STATUS_STR ${HOMEBREW_STATUS_STR})
|
||||
set(HOMEBREW_PREFIX ${CMAKE_MATCH_1})
|
||||
message(STATUS "Homebrew installation found at ${HOMEBREW_PREFIX}")
|
||||
set(CMAKE_PREFIX_PATH "${HOMEBREW_PREFIX}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS "UNIX: Detected compiler: ${CMAKE_C_COMPILER}")
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$<CONFIG>/bin")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$<CONFIG>/lib")
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" /> <!-- Windows 10 -->
|
||||
</application>
|
||||
</compatibility>
|
||||
</assembly>
|
||||
@@ -1,15 +0,0 @@
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
_WIN32_WINNT=0x0A00 # Windows 10
|
||||
NTDDI_VERSION=0x0A000007 # 19H1 (1903)
|
||||
WIN32_LEAN_AND_MEAN
|
||||
NOMINMAX
|
||||
TRINITY_REQUIRED_WINDOWS_BUILD=18362)
|
||||
|
||||
# set up output paths for executable binaries (.exe-files, and .dll-files on DLL-capable platforms)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$<CONFIG>")
|
||||
|
||||
# add WindowsSettings.manifest to all executables
|
||||
target_sources(trinity-core-interface
|
||||
INTERFACE
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:${CMAKE_SOURCE_DIR}/cmake/platform/win/WindowsSettings.manifest>)
|
||||
@@ -1,205 +0,0 @@
|
||||
# output generic information about the core and buildtype chosen
|
||||
message("")
|
||||
message("* TrinityCore revision : ${rev_hash} ${rev_date} (${rev_branch} branch)")
|
||||
get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
if(NOT IS_MULTI_CONFIG)
|
||||
message("* TrinityCore buildtype : ${CMAKE_BUILD_TYPE}")
|
||||
endif()
|
||||
message("")
|
||||
|
||||
# output information about installation-directories and locations
|
||||
|
||||
message("* Install core to : ${CMAKE_INSTALL_PREFIX}")
|
||||
if(COPY_CONF)
|
||||
if(UNIX)
|
||||
message("* Install configs to : ${CONF_DIR}")
|
||||
else()
|
||||
message("* Install configs to : ${CMAKE_INSTALL_PREFIX}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message("")
|
||||
|
||||
# Show infomation about the options selected during configuration
|
||||
|
||||
if(SERVERS)
|
||||
message("* Build world/auth : Yes (default)")
|
||||
else()
|
||||
message("* Build world/bnetserver : No")
|
||||
endif()
|
||||
|
||||
if(SCRIPTS AND (NOT SCRIPTS STREQUAL "none"))
|
||||
message("* Build with scripts : Yes (${SCRIPTS})")
|
||||
else()
|
||||
message("* Build with scripts : No")
|
||||
endif()
|
||||
|
||||
if(TOOLS)
|
||||
message("* Build map/vmap tools : Yes (default)")
|
||||
else()
|
||||
message("* Build map/vmap tools : No")
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
message("* Build unit tests : Yes")
|
||||
else()
|
||||
message("* Build unit tests : No (default)")
|
||||
endif()
|
||||
|
||||
if(USE_COREPCH)
|
||||
message("* Build core w/PCH : Yes (default)")
|
||||
else()
|
||||
message("* Build core w/PCH : No")
|
||||
endif()
|
||||
|
||||
if(USE_SCRIPTPCH)
|
||||
message("* Build scripts w/PCH : Yes (default)")
|
||||
else()
|
||||
message("* Build scripts w/PCH : No")
|
||||
endif()
|
||||
|
||||
if(WITH_WARNINGS)
|
||||
message("* Show all warnings : Yes")
|
||||
else()
|
||||
message("* Show all warnings : No (default)")
|
||||
endif()
|
||||
|
||||
if(WITH_WARNINGS_AS_ERRORS)
|
||||
message("* Stop build on warning : Yes")
|
||||
else()
|
||||
message("* Stop build on warning : No (default)")
|
||||
endif()
|
||||
|
||||
if(WITH_COREDEBUG)
|
||||
message("")
|
||||
message(" *** WITH_COREDEBUG - WARNING!")
|
||||
message(" *** additional core debug logs have been enabled!")
|
||||
message(" *** this setting doesn't help to get better crash logs!")
|
||||
message(" *** in case you are searching for better crash logs use")
|
||||
message(" *** -DCMAKE_BUILD_TYPE=RelWithDebInfo")
|
||||
message(" *** DO NOT ENABLE IT UNLESS YOU KNOW WHAT YOU'RE DOING!")
|
||||
message("* Use coreside debug : Yes")
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
TRINITY_DEBUG)
|
||||
else()
|
||||
message("* Use coreside debug : No (default)")
|
||||
endif()
|
||||
|
||||
if(NOT WITH_SOURCE_TREE STREQUAL "no")
|
||||
message("* Show source tree : Yes (${WITH_SOURCE_TREE})")
|
||||
else()
|
||||
message("* Show source tree : No")
|
||||
endif()
|
||||
|
||||
if(WITHOUT_GIT)
|
||||
message("* Use GIT revision hash : No")
|
||||
message("")
|
||||
message(" *** WITHOUT_GIT - WARNING!")
|
||||
message(" *** By choosing the WITHOUT_GIT option you have waived all rights for support,")
|
||||
message(" *** and accept that or all requests for support or assistance sent to the core")
|
||||
message(" *** developers will be rejected. This due to that we will be unable to detect")
|
||||
message(" *** what revision of the codebase you are using in a proper way.")
|
||||
message(" *** We remind you that you need to use the repository codebase and a supported")
|
||||
message(" *** version of git for the revision-hash to work, and be allowede to ask for")
|
||||
message(" *** support if needed.")
|
||||
else()
|
||||
message("* Use GIT revision hash : Yes (default)")
|
||||
endif()
|
||||
|
||||
if(NOJEM)
|
||||
message("")
|
||||
message(" *** NOJEM - WARNING!")
|
||||
message(" *** jemalloc linking has been disabled!")
|
||||
message(" *** Please note that this is for DEBUGGING WITH VALGRIND only!")
|
||||
message(" *** DO NOT DISABLE IT UNLESS YOU KNOW WHAT YOU'RE DOING!")
|
||||
endif()
|
||||
|
||||
if(HELGRIND)
|
||||
message("")
|
||||
message(" *** HELGRIND - WARNING!")
|
||||
message(" *** Please specify the valgrind include directory in VALGRIND_INCLUDE_DIR option if you get build errors")
|
||||
message(" *** Please note that this is for DEBUGGING WITH HELGRIND only!")
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
HELGRIND)
|
||||
endif()
|
||||
|
||||
if(ASAN)
|
||||
message("")
|
||||
message(" *** ASAN - WARNING!")
|
||||
message(" *** Please note that this is for DEBUGGING WITH ADDRESS SANITIZER only!")
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
ASAN)
|
||||
endif()
|
||||
|
||||
if(MSAN)
|
||||
message("")
|
||||
message(" *** MSAN - WARNING!")
|
||||
message(" *** Please note that this is for DEBUGGING WITH MEMORY SANITIZER only!")
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
MSAN)
|
||||
endif()
|
||||
|
||||
if(UBSAN)
|
||||
message("")
|
||||
message(" *** UBSAN - WARNING!")
|
||||
message(" *** Please note that this is for DEBUGGING WITH UNDEFINED BEHAVIOR SANITIZER only!")
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
UBSAN)
|
||||
endif()
|
||||
|
||||
if(TSAN)
|
||||
message("")
|
||||
message(" *** TSAN - WARNING!")
|
||||
message(" *** Please note that this is for DEBUGGING WITH THREAD SANITIZER only!")
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
TSAN)
|
||||
endif()
|
||||
|
||||
if(PERFORMANCE_PROFILING)
|
||||
message("")
|
||||
message(" *** PERFORMANCE_PROFILING - WARNING!")
|
||||
message(" *** Please note that this is for PERFORMANCE PROFILING only! Do NOT report any issue when enabling this configuration!")
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
PERFORMANCE_PROFILING)
|
||||
endif()
|
||||
|
||||
if(WITHOUT_METRICS)
|
||||
message("")
|
||||
message(" *** WITHOUT_METRICS - WARNING!")
|
||||
message(" *** Please note that this will disable all metrics output (i.e. InfluxDB and Grafana)")
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
WITHOUT_METRICS)
|
||||
elseif (WITH_DETAILED_METRICS)
|
||||
message("")
|
||||
message(" *** WITH_DETAILED_METRICS - WARNING!")
|
||||
message(" *** Please note that this will enable detailed metrics output (i.e. time each session takes to update)")
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
WITH_DETAILED_METRICS)
|
||||
endif()
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
message("")
|
||||
message(" *** WITH_DYNAMIC_LINKING - INFO!")
|
||||
message(" *** Will link against shared libraries!")
|
||||
message(" *** Please note that this is an experimental feature!")
|
||||
if(WITH_DYNAMIC_LINKING_FORCED)
|
||||
message("")
|
||||
message(" *** Dynamic linking was enforced through a dynamic script module!")
|
||||
endif()
|
||||
target_compile_definitions(trinity-compile-option-interface
|
||||
INTERFACE
|
||||
TRINITY_API_USE_DYNAMIC_LINKING)
|
||||
|
||||
WarnAboutSpacesInBuildPath()
|
||||
endif()
|
||||
|
||||
message("")
|
||||
@@ -1,31 +0,0 @@
|
||||
/* Copyright (C) 2009 Sun Microsystems, Inc
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
/* Check stack direction (0-down, 1-up) */
|
||||
int f(int *a)
|
||||
{
|
||||
int b;
|
||||
return(&b > a)?1:0;
|
||||
}
|
||||
/*
|
||||
Prevent compiler optimizations by calling function
|
||||
through pointer.
|
||||
*/
|
||||
volatile int (*ptr_f)(int *) = f;
|
||||
int main()
|
||||
{
|
||||
int a;
|
||||
return ptr_f(&a);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
FROM trinitycore/circle-ci:debian-13-runner
|
||||
|
||||
#Setup
|
||||
WORKDIR /home/circleci
|
||||
COPY README.md /
|
||||
COPY --chown=circleci:circleci sql /home/circleci/project/sql
|
||||
COPY bin /usr/local/bin/
|
||||
COPY lib /usr/local/lib/
|
||||
ENTRYPOINT [ "echo", "Check the README.md file for instructions"]
|
||||
@@ -1,80 +0,0 @@
|
||||
# Docker
|
||||
|
||||
The Circle CI Linux pch job uses the Dockerfile contained in the same folder as this README to create an image with the binaries built for Linux, and stores that in the job artifacts. For the 3.3.5 and master branches, it also pushes the images to https://hub.docker.com/r/trinitycore/trinitycore .
|
||||
|
||||
The instructions below expect a basic knowledge of how to configure TrinityCore and how to use Docker.
|
||||
|
||||
## Load the Docker image
|
||||
For the 3.3.5 and master branches, it's possible to pull the images from DockerHub.
|
||||
- For latest 3.3.5, use the following command:
|
||||
```
|
||||
docker pull trinitycore/trinitycore:3.3.5
|
||||
```
|
||||
- For latest master, use the following command:
|
||||
```
|
||||
docker pull trinitycore/trinitycore:master
|
||||
```
|
||||
- For a specific 3.3.5 or master commit, use the following command, replacing "commit_hash" with the hash of the commit:
|
||||
```
|
||||
docker pull trinitycore/trinitycore:commit_hash
|
||||
```
|
||||
|
||||
For Pull Requests or branches other than 3.3.5 or master, follow the steps below to load the image from Circle CI:
|
||||
1. Click the green tick ✔ next to each commit.
|
||||
1. Scroll to "ci/circleci: pch" and click "Details".
|
||||
1. Log in to Circle CI if necessary. You may have to repeat the previous steps after logging in, to reach the correct page.
|
||||
1. Click the "Artifacts" tab in the Circle CI website.
|
||||
1. Download the docker.tar.gz archive containing the docker image.
|
||||
1. Load the image into your Docker host, using the following command:
|
||||
```
|
||||
docker load -i docker.tar.gz
|
||||
```
|
||||
|
||||
## Start bnetserver/worldserver from Docker
|
||||
1. Copy the .conf files from the TrinityCore GitHub repository to a local folder which will be passed on as a mapped volume to Docker.
|
||||
1. Set the MySQL host in the .conf files to use the UNIX socket of MySQL, i.e.: `".;/var/run/mysqld/mysqld.sock;username;password;database"`
|
||||
1. Set the "DataDir" config in worldserver.conf to `"/trinity/data"`
|
||||
1. Start bnetserver or worldserver as desired, mapping the required volumes:
|
||||
|
||||
- bnetserver
|
||||
```
|
||||
docker run --entrypoint=bnetserver -it --volume=/host/path/to/configs:/home/circleci/project/bin/check_install/etc --volume=/var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock -p=1119:1119 -p 8081:8081 "image name"
|
||||
```
|
||||
|
||||
- worldserver
|
||||
```
|
||||
docker run --entrypoint=worldserver -it --volume=/host/path/to/configs:/home/circleci/project/bin/check_install/etc --volume=/var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock --volume=/path/to/data/directory:/trinity/data -p=8085:8085 -p 8086:8086 "image name"
|
||||
```
|
||||
|
||||
Change the ports and other parameters as needed. Consult Docker documentation for additional details about possible configuration settings.
|
||||
|
||||
## Content
|
||||
|
||||
The image contains:
|
||||
- bnetserver
|
||||
- mapextractor
|
||||
- mmaps_generator
|
||||
- vmap4asembler
|
||||
- vmap4extractor
|
||||
- worldserver
|
||||
- README.md
|
||||
|
||||
You can explore the image using
|
||||
```
|
||||
docker run --entrypoint=/bin/bash -it "image name"
|
||||
```
|
||||
|
||||
Note that the WORKDIR is set to /home/circleci and all logs will be saved to that folder by default. You can export the logs from the container with
|
||||
```
|
||||
docker cp "container name":/home/circleci/name.log name.log
|
||||
```
|
||||
|
||||
For more instructions, please check the official docker documentation.
|
||||
|
||||
## Limitations:
|
||||
|
||||
- Database connection: The instructions provided expect MySQL to run on the host machine. Change `docker run` parameters and .conf settings to fit your scenario.
|
||||
- To import TDB using the autoupdater:
|
||||
1. Download the TDB sql file from GitHub.
|
||||
1. Map it with `--volume=/path/to/TDB_full_name.sql:/home/circleci/TDB_full_name.sql` added to the commands specified in the main steps above.
|
||||
1. Run the container.
|
||||
@@ -1,38 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "Codestyle check script:"
|
||||
echo
|
||||
|
||||
declare -A singleLineRegexChecks=(
|
||||
["TC_LOG_.+GetCounter"]="Use ObjectGuid::ToString().c_str() method instead of ObjectGuid::GetCounter() when logging. Check the lines above"
|
||||
["[[:blank:]]$"]="Remove whitespace at the end of the lines above"
|
||||
["\t"]="Replace tabs with 4 spaces in the lines above"
|
||||
)
|
||||
for check in ${!singleLineRegexChecks[@]}; do
|
||||
echo " Checking RegEx: '${check}'"
|
||||
|
||||
if grep -P -r -I -n ${check} src; then
|
||||
echo
|
||||
echo "${singleLineRegexChecks[$check]}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
declare -A multiLineRegexChecks=(
|
||||
["TC_LOG_[^;]+GetCounter"]="Use ObjectGuid::ToString().c_str() method instead of ObjectGuid::GetCounter() when logging. Check the lines above"
|
||||
["\r?\n\r?\n\r?\n"]="Multiple blank lines detected, keep only one. Check the files above"
|
||||
)
|
||||
for check in ${!multiLineRegexChecks[@]}; do
|
||||
echo " Checking RegEx: '${check}'"
|
||||
|
||||
if grep -Pzo -r -I ${check} src; then
|
||||
echo
|
||||
echo
|
||||
echo "${multiLineRegexChecks[$check]}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo
|
||||
echo "Everything looks good"
|
||||
@@ -1,46 +0,0 @@
|
||||
#!/bin/sh
|
||||
name=$1
|
||||
branch=$2
|
||||
database=$3
|
||||
host=$4
|
||||
|
||||
echo "Database Updater check script:"
|
||||
echo " Checking database '${name}' for missing filenames in tables..."
|
||||
echo
|
||||
|
||||
# Select all entries which are in the updates table
|
||||
entries=$(mysql -uroot ${database} -h ${host} -e "SELECT name FROM updates" | grep ".sql")
|
||||
|
||||
cd sql/updates/${name}/${branch}
|
||||
|
||||
error=0
|
||||
updates=0
|
||||
|
||||
for file in *.sql
|
||||
do
|
||||
# Check if the given update is in the `updates` table.
|
||||
if echo "${entries}" | grep -q "^${file}"; then
|
||||
# File is ok
|
||||
updates=$((updates+1))
|
||||
else
|
||||
# The update isn't listed in the updates table of the given database.
|
||||
echo "- \"sql/updates/${name}/${file}\" is missing in the '${name}'.'updates' table."
|
||||
error=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${error} -ne 0 ]
|
||||
then
|
||||
echo
|
||||
echo "Fatal error:"
|
||||
echo " The Database Updater is broken for the '${name}' database,"
|
||||
echo " because the applied update is missing in the '${name}'.'updates' table."
|
||||
echo
|
||||
echo "How to fix:"
|
||||
echo " Insert the missing names of the already applied sql updates"
|
||||
echo " to the 'updates' table of the '${name}' base dump ('sql/base/${name}_database.sql')."
|
||||
exit 1
|
||||
else
|
||||
echo " Everything is OK, finished checking ${updates} updates."
|
||||
exit 0
|
||||
fi
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/bash
|
||||
perl -wpi -e "s/\t/ /g" $1
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/bash
|
||||
perl -wpi -e "s/ +$//g" $1
|
||||
@@ -1,13 +0,0 @@
|
||||
==== PHP merger (index.php + merge.php) ====
|
||||
|
||||
This is a PHP script for merging a new .dist file with your existing .conf file (worldserver.conf.dist and bnetserver.conf.dist)
|
||||
It should also work with mangos dist/conf files as well.
|
||||
|
||||
It uses sessions so it is multi user safe, it adds any options that are removed to the bottom of the file,
|
||||
commented out, just in case it removes something it shouldn't,
|
||||
and, if you add all of your custom patch configs below "# Custom" they will be copied exactly as they are.
|
||||
|
||||
==== Perl merger (tc-conf-merger.pl) ====
|
||||
|
||||
Perl based command line merger script. This script feeds a .conf.dist file with variables that exist in an old .conf file,
|
||||
comments and custom options are ignored.
|
||||
@@ -1,169 +0,0 @@
|
||||
<!--
|
||||
@title Configuration file merger/differ.
|
||||
@about This script allows you to diff two config files and select which value to pick between the two.
|
||||
It will then give you an updated configuration file with the settings you chose.
|
||||
How-to: a) Paste both versions of your config file, submit the form.
|
||||
b) Select values you want to keep in the next form, then submit said form.
|
||||
c) Copy the output'd config file and profit!
|
||||
Note: if either one of your config file has custom values, make sure that it is set to be the NEW
|
||||
config file on the first step (right hand textarea). This will be adressed at a later date.
|
||||
@author Warpten
|
||||
@date 05/17/2014
|
||||
@license GNU GPL v2(GPL)
|
||||
@version 0.0.1
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><world/auth>server.conf diff</title>
|
||||
<style type="text/css">
|
||||
form * { font-family: Verdana; font-size: 11px; }
|
||||
form#step1 { position: relative; width: 800px; }
|
||||
form#step2 { width: 500px; }
|
||||
form > div { position: absolute; width: 50%; height: 500px; }
|
||||
form > div:nth-child(1) { right: 0px; }
|
||||
textarea { width: 90%; height: 500px; }
|
||||
h3 { display: block; margin: 3px; padding: auto; text-align: center; }
|
||||
input.valueName { border: 0px; background-color: white; }
|
||||
form > p { margin: 0; padding: 3px; border-bottom: 1px solid black; }
|
||||
textarea#result { width: 1000px; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
|
||||
function printIndent($string, $indent = 1)
|
||||
{
|
||||
echo str_pad("\r\n" . $string, $indent, " ");
|
||||
}
|
||||
|
||||
if (!isset($_POST['step']))
|
||||
{
|
||||
?>
|
||||
<form action="" method="POST" id="step1">
|
||||
<div>
|
||||
<h3>Paste the new configuration file</h3>
|
||||
<textarea name="leftFile"></textarea>
|
||||
</div><div>
|
||||
<h3>Paste the old configuration file</h3>
|
||||
<textarea name="rightFile"></textarea>
|
||||
<input type="submit" value="Compare files" />
|
||||
</div>
|
||||
<input type="hidden" name="step" value="0" />
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
else if ($_POST['step'] == 0)
|
||||
{
|
||||
if (@empty($_POST['leftFile']) || @empty($_POST['rightFile']))
|
||||
printf("You did not provide either the old or the new configuration file.<br />");
|
||||
|
||||
define('EOL', "\n\n");
|
||||
$settingsData = array();
|
||||
|
||||
// Process them
|
||||
$newFile = explode(EOL, $_POST['leftFile']);
|
||||
$oldFile = explode(EOL, $_POST['rightFile']);
|
||||
|
||||
for ($i = 0, $o = count($oldFile); $i < $o; ++$i)
|
||||
{
|
||||
$oldFile[$i] = explode(PHP_EOL, $oldFile[$i]);
|
||||
for ($j = 0, $p = count($oldFile[$i]); $j < $p; ++$j)
|
||||
{
|
||||
$currentLine = $oldFile[$i][$j];
|
||||
if (preg_match("#^([A-Z.]+) = (?:\"?)(.*)(?:\"?)$#iU", $currentLine, $data) !== false)
|
||||
if (strlen($data[1]) != 0)
|
||||
$settingsData[$data[1]]["oldValue"] = str_replace('"', '', trim($data[2]));
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0, $o = count($newFile); $i < $o; ++$i)
|
||||
{
|
||||
$newFile[$i] = explode(PHP_EOL, $newFile[$i]);
|
||||
for ($j = 0, $p = count($newFile[$i]); $j < $p; ++$j)
|
||||
{
|
||||
$currentLine = $newFile[$i][$j];
|
||||
if (preg_match("#^([A-Z.]+) = (?:\"?)(.*)(?:\"?)$#iU", $currentLine, $data) !== false)
|
||||
if (strlen($data[1]) != 0)
|
||||
$settingsData[$data[1]]["newValue"] = str_replace('"', '', trim($data[2]));
|
||||
}
|
||||
}
|
||||
|
||||
printIndent("<p>Please select values you want to keep. Note the script will default to new values, unless said <i>new</i> value does not exist.<br />You also can take advantage of this form and edit fields.</p>", 1);
|
||||
printIndent('<form action="" method="POST" id="step2">', 1);
|
||||
|
||||
foreach ($settingsData as $itemName => &$values)
|
||||
{
|
||||
$displayOld = isset($values['oldValue']) ? $values['oldValue'] : "Value missing";
|
||||
$displayNew = isset($values['newValue']) ? $values['newValue'] : "Value missing";
|
||||
|
||||
if ($displayOld == $displayNew)
|
||||
continue;
|
||||
|
||||
$line = '<p><input type="text" class="valueName" name="nameCross[]" value="' . $itemName . '" />';
|
||||
$line .= '<input type="radio" name="optionSelector[' . $itemName . ']" value="oldValue" ' . ($displayOld != "Value missing" ? "checked" : "") . '/>';
|
||||
$line .= '<input type="text" name="oldValue[]" value="' . $displayOld . '" /> ';
|
||||
$line .= '<input type="radio" name="optionSelector[' . $itemName . ']" value="newValue" ' . ($displayNew != "Value missing" ? "checked" : "") . '/>';
|
||||
$line .= '<input type="text" name="newValue[]" value="' . $displayNew . '" /></p>';
|
||||
printIndent($line, 2);
|
||||
}
|
||||
printIndent('<input type="hidden" name="step" value="1" />', 2);
|
||||
printIndent('<input type="submit" value="Gief resulting configuration file" />', 2);
|
||||
printIndent('<input type="hidden" name="file" value="' . htmlspecialchars($_POST['rightFile']) . '" />', 2);
|
||||
printIndent('</form>', 1);
|
||||
}
|
||||
else if ($_POST['step'] == 1)
|
||||
{
|
||||
$errors = array();
|
||||
|
||||
$confFile = $_POST['file'];
|
||||
|
||||
foreach ($_POST['optionSelector'] as $valueName => &$keyName)
|
||||
{
|
||||
$definiteValueIndex = -1;
|
||||
foreach ($_POST['nameCross'] as $index => &$key)
|
||||
{
|
||||
if ($key == $valueName)
|
||||
{
|
||||
$definiteValueIndex = $index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($definiteValueIndex == -1)
|
||||
{
|
||||
// TODO: Handle custom values that get lost
|
||||
continue;
|
||||
}
|
||||
|
||||
$newStr = $_POST[$keyName][$definiteValueIndex];
|
||||
$oldStr = $_POST[$keyName == "oldValue" ? "newValue" : "oldValue"][$definiteValueIndex];
|
||||
if (!ctype_digit($newStr))
|
||||
$newStr = '"' . $newStr . '"';
|
||||
if (!ctype_digit($oldStr))
|
||||
$oldStr = '"' . $oldStr . '"';
|
||||
|
||||
$newValueString = $valueName . " = " . $newStr;
|
||||
$oldValueString = $valueName . " = " . $oldStr;
|
||||
$confFile = str_replace($oldValueString, $newValueString, $confFile);
|
||||
}
|
||||
echo "<p>Here is your new configuration file:</p>";
|
||||
echo '<form><textarea id="result">';
|
||||
printf('%s', $confFile);
|
||||
echo '</textarea></form>';
|
||||
|
||||
if (!empty($errors))
|
||||
{
|
||||
echo "<p>The following errors happened during processing:</p><ul><li>";
|
||||
echo implode("</li><li>", $errors);
|
||||
echo "</li>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Project Name: Config File Merge For Mangos/Trinity Server
|
||||
* Date: 01.01.2010 inital version (0.0.1a)
|
||||
* Author: Paradox
|
||||
* Copyright: Paradox
|
||||
* Email: [email protected] (paypal email)
|
||||
* License: GNU General Public License v2(GPL)
|
||||
*/
|
||||
?>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
|
||||
<FORM enctype="multipart/form-data" ACTION="merge.php" METHOD="POST">
|
||||
Dist File
|
||||
<br />
|
||||
<INPUT name="File1" TYPE="file">
|
||||
<br />
|
||||
Current Conf File
|
||||
<br />
|
||||
<INPUT name="File2" TYPE="file">
|
||||
<br />
|
||||
<INPUT TYPE=RADIO NAME="eol" VALUE="0" CHECKED >Win32 -
|
||||
<INPUT TYPE=RADIO NAME="eol" VALUE="1" >UNIX/Linux
|
||||
<br />
|
||||
<INPUT TYPE="submit" VALUE="Submit">
|
||||
<br />
|
||||
If you have any custom settings, such as from patches,
|
||||
<br />
|
||||
make sure they are at the bottom of the file following
|
||||
<br />
|
||||
this block (add it if it's not there)
|
||||
<br />
|
||||
###############################################################################
|
||||
<br />
|
||||
# Custom
|
||||
<br />
|
||||
###############################################################################
|
||||
<br />
|
||||
<br />
|
||||
|
||||
</FORM>
|
||||
@@ -1,159 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Project Name: Config File Merge For Mangos/Trinity Server
|
||||
* Date: 01.01.2010 inital version (0.0.1a)
|
||||
* Author: Paradox
|
||||
* Copyright: Paradox
|
||||
* Email: [email protected] (paypal email)
|
||||
* License: GNU General Public License v2(GPL)
|
||||
*/
|
||||
if (!empty($_FILES['File1']) && !empty($_FILES['File2']))
|
||||
{
|
||||
session_id();
|
||||
session_start();
|
||||
$basedir = "merge";
|
||||
$eol = "\r\n";
|
||||
if ($_POST['eol'])
|
||||
$eol = "\n";
|
||||
else
|
||||
$eol = "\r\n";
|
||||
if (!file_exists($basedir))
|
||||
mkdir($basedir);
|
||||
if (!file_exists($basedir."/".session_id()))
|
||||
mkdir($basedir."/".session_id());
|
||||
$upload1 = $basedir."/".session_id()."/".basename($_FILES['File1']['name']);
|
||||
$upload2 = $basedir."/".session_id()."/".basename($_FILES['File2']['name']);
|
||||
$newconfig = $basedir."/".session_id()."/trinitycore.conf.merged";
|
||||
$out_file = fopen($newconfig, w);
|
||||
$success = false;
|
||||
if (move_uploaded_file($_FILES['File1']['tmp_name'], $upload1))
|
||||
{
|
||||
$success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$success = false;
|
||||
}
|
||||
if (move_uploaded_file($_FILES['File2']['tmp_name'], $upload2))
|
||||
{
|
||||
$success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$success = false;
|
||||
}
|
||||
|
||||
if ($success)
|
||||
{
|
||||
$custom_found = false;
|
||||
$in_file1 = fopen($upload1,r);
|
||||
$in_file2 = fopen($upload2,r);
|
||||
$array1 = array();
|
||||
$array2 = array();
|
||||
$line = trim(fgets($in_file1));
|
||||
while (!feof($in_file1))
|
||||
{
|
||||
if ((substr($line,0,1) != '#' && substr($line,0,1) != ''))
|
||||
{
|
||||
list($key, $val) = explode("=",$line);
|
||||
$key = trim($key);
|
||||
$val = trim($val);
|
||||
$array1[$key] = $val;
|
||||
}
|
||||
$line = trim(fgets($in_file1));
|
||||
}
|
||||
$line = trim(fgets($in_file2));
|
||||
while (!feof($in_file2) && !$custom_found)
|
||||
{
|
||||
if (substr($line,0,1) != '#' && substr($line,0,1) != '')
|
||||
{
|
||||
list($key, $val) = explode("=",$line);
|
||||
$key = trim($key);
|
||||
$val = trim($val);
|
||||
$array2[$key] = $val;
|
||||
}
|
||||
if (strtolower($line) == "# custom")
|
||||
$custom_found = true;
|
||||
else
|
||||
$line = trim(fgets($in_file2));
|
||||
}
|
||||
fclose($in_file1);
|
||||
foreach($array2 as $k => $v)
|
||||
{
|
||||
if (array_key_exists($k, $array1))
|
||||
{
|
||||
$array1[$k] = $v;
|
||||
unset($array2[$k]);
|
||||
}
|
||||
}
|
||||
$in_file1 = fopen($upload1,r);
|
||||
$line = trim(fgets($in_file1));
|
||||
while (!feof($in_file1))
|
||||
{
|
||||
if (substr($line,0,1) != '#' && substr($line,0,1) != '')
|
||||
{
|
||||
$array = array();
|
||||
while (substr($line,0,1) != '#' && substr($line,0,1) != '')
|
||||
{
|
||||
list($key, $val) = explode("=",$line);
|
||||
$key = trim($key);
|
||||
$val = trim($val);
|
||||
$array[$key] = $val;
|
||||
$line = trim(fgets($in_file1));
|
||||
}
|
||||
foreach($array as $k => $v)
|
||||
{
|
||||
if (array_key_exists($k, $array1))
|
||||
fwrite($out_file, $k."=".$array1[$k].$eol);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
unset($array);
|
||||
if (!feof($in_file1))
|
||||
fwrite($out_file, $line.$eol);
|
||||
}
|
||||
else
|
||||
fwrite($out_file, $line.$eol);
|
||||
$line = trim(fgets($in_file1));
|
||||
}
|
||||
if ($custom_found)
|
||||
{
|
||||
fwrite($out_file, $eol);
|
||||
fwrite($out_file, "###############################################################################".$eol);
|
||||
fwrite($out_file, "# Custom".$eol);
|
||||
$line = trim(fgets($in_file2));
|
||||
while (!feof($in_file2))
|
||||
{
|
||||
fwrite($out_file, $line.$eol);
|
||||
$line = trim(fgets($in_file2));
|
||||
}
|
||||
}
|
||||
$first = true;
|
||||
foreach($array2 as $k => $v)
|
||||
{
|
||||
if ($first)
|
||||
{
|
||||
fwrite($out_file, $eol);
|
||||
fwrite($out_file, "###############################################################################".$eol);
|
||||
fwrite($out_file, "# The Following values were removed from the config.".$eol);
|
||||
$first = false;
|
||||
}
|
||||
fwrite($out_file, "# ".$k."=".$v.$eol);
|
||||
}
|
||||
unset($array1);
|
||||
unset($array2);
|
||||
fclose($in_file1);
|
||||
fclose($in_file2);
|
||||
fclose($out_file);
|
||||
unlink($upload1);
|
||||
unlink($upload2);
|
||||
|
||||
echo "Process done";
|
||||
echo "<br /><a href=".$newconfig.">Click here to retrieve your merged conf</a>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "An error has occurred";
|
||||
}
|
||||
?>
|
||||
@@ -1,43 +0,0 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
# Author: leak
|
||||
# Date: 2010-12-06
|
||||
# Note: Based on conf file format of rev 10507
|
||||
|
||||
use strict;
|
||||
|
||||
if (@ARGV != 3)
|
||||
{
|
||||
print("Usage:\ntc-conf-merger.pl <path to new .conf.dist> <path to old .conf> <path to output .conf>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (! -e $ARGV[0])
|
||||
{
|
||||
print("No file found at: ".$ARGV[0]);
|
||||
exit(1);
|
||||
}
|
||||
elsif (! -e $ARGV[1])
|
||||
{
|
||||
print("No file found at: ".$ARGV[1]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
open CONFDIST, "<", $ARGV[0] or die "Error: Could not open ".$ARGV[0]."\n";
|
||||
my $confdist = join "", <CONFDIST>;
|
||||
close CONFDIST;
|
||||
|
||||
open CONFOLD, "<", $ARGV[1] or die "Error: Could not open ".$ARGV[1]."\n";
|
||||
my $confold = join "", <CONFOLD>;
|
||||
close CONFOLD;
|
||||
|
||||
while ($confold =~ m/^(?!#)(.*?)\s+?=\s+?(.*?)$/mg) {
|
||||
my $key = $1, my $value = $2;
|
||||
$confdist =~ s/^(\Q$key\E)(\s+?=\s+?)(.*)/$1$2$value/mg;
|
||||
}
|
||||
|
||||
open OUTPUT, ">", $ARGV[2] or die "Error: Could not open ".$ARGV[2]."\n";
|
||||
binmode(OUTPUT);
|
||||
print OUTPUT $confdist;
|
||||
close OUTPUT;
|
||||
@@ -1,13 +0,0 @@
|
||||
The included crashreport.gdb allows for semiautomated hunting of
|
||||
crashes. The crashlog-file will be named backtrace.log and contains all
|
||||
the commands required to partially automate a crashlog-creation with the
|
||||
proper information.
|
||||
|
||||
Usage: gdb -x crashreport.gdb <executable file>
|
||||
|
||||
For creating an efficient backtrace, use -DCMAKE_BUILD_TYPE=Debug as a
|
||||
parameter to CMake during configuration - this increases the filesize,
|
||||
but includes all the needed information for a decent and efficient
|
||||
crashreport.
|
||||
|
||||
-- Good luck, and happy crashhunting.
|
||||
@@ -1,38 +0,0 @@
|
||||
set logging overwrite on
|
||||
set logging file backtrace.log.temp
|
||||
set style enabled off
|
||||
set height unlimited
|
||||
set width unlimited
|
||||
set disassembly-flavor intel
|
||||
handle SIG33 pass nostop noprint
|
||||
set pagination 0
|
||||
set logging on
|
||||
echo \n--- DEBUG: --- START\n\n
|
||||
run
|
||||
# check if exited normally
|
||||
if $_isvoid($_exitcode)
|
||||
echo \n--- DEBUG: BACKTRACE FULL\n
|
||||
# print assertion message if this is ASSERT crash
|
||||
if TrinityAssertionFailedMessage != 0
|
||||
printf "%s\n", TrinityAssertionFailedMessage
|
||||
end
|
||||
echo \n
|
||||
backtrace full
|
||||
echo \n--- DEBUG: INFO REGISTERS\n\n
|
||||
info registers
|
||||
echo \n--- DEBUG: CALLS (x/16i $pc)\n\n
|
||||
x/16i $pc
|
||||
echo \n--- DEBUG: THREAD APPLY ALL BACKTRACE\n
|
||||
thread apply all backtrace
|
||||
echo \n--- DEBUG: --- STOP\n\n
|
||||
echo Generated by crashreport.gdb script version 1.4\n
|
||||
set logging off
|
||||
|
||||
# rename log file to avoid it getting overwritten by restart scripts
|
||||
shell mv backtrace.log.temp backtrace_$(date +%Y-%m-%d-%T).log
|
||||
else
|
||||
# normal exit, cleanup temp file
|
||||
set logging off
|
||||
shell rm backtrace.log.temp
|
||||
end
|
||||
quit
|
||||
@@ -1,167 +0,0 @@
|
||||
from re import compile, MULTILINE
|
||||
from os import walk, getcwd
|
||||
|
||||
notice = ('''/*
|
||||
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
''')
|
||||
|
||||
if not getcwd().endswith('src'):
|
||||
print('Run this from the src directory!')
|
||||
print('(Invoke as \'python ../contrib/enumutils_describe.py\')')
|
||||
exit(1)
|
||||
|
||||
EnumPattern = compile(r'//\s*EnumUtils: DESCRIBE THIS(?:\s*\(in ([^\)]+)\))?\s+enum\s+(class\s+)?([0-9A-Za-z]+)[^\n]*\s*{([^}]+)};')
|
||||
EnumValuesPattern = compile(r'\s+\S.+?(,|$)[^\n]*')
|
||||
EnumValueNamePattern = compile(r'^\s*([a-zA-Z0-9_]+)', flags=MULTILINE)
|
||||
EnumValueSkipLinePattern = compile(r'^\s*//')
|
||||
EnumValueCommentPattern = compile(r'//,?[ \t]*([^\n]+)$')
|
||||
CommentMatchFormat = compile(r'^(((TITLE +(.+?))|(DESCRIPTION +(.+?))) *){1,2}$')
|
||||
CommentSkipFormat = compile(r'^SKIP *$')
|
||||
|
||||
def strescape(str):
|
||||
res = ''
|
||||
for char in str:
|
||||
if char in ('\\', '"') or not (32 <= ord(char) < 127):
|
||||
res += ('\\%03o' % ord(char))
|
||||
else:
|
||||
res += char
|
||||
return '"' + res + '"'
|
||||
|
||||
def processFile(path, filename):
|
||||
input = open('%s/%s.h' % (path, filename),'r')
|
||||
if input is None:
|
||||
print('Failed to open %s.h' % filename)
|
||||
return
|
||||
|
||||
file = input.read()
|
||||
|
||||
enums = []
|
||||
for enum in EnumPattern.finditer(file):
|
||||
prefix = enum.group(1) or ''
|
||||
name = enum.group(3)
|
||||
values = []
|
||||
# support enum class
|
||||
valuePrefix = ''
|
||||
if enum.group(2) is not None:
|
||||
valuePrefix = name + '::'
|
||||
for value in EnumValuesPattern.finditer(enum.group(4)):
|
||||
valueData = value.group(0)
|
||||
|
||||
valueNameMatch = EnumValueNamePattern.search(valueData)
|
||||
if valueNameMatch is None:
|
||||
if EnumValueSkipLinePattern.search(valueData) is None:
|
||||
print('Name of value not found: %s' % repr(valueData))
|
||||
continue
|
||||
valueName = valueNameMatch.group(1)
|
||||
|
||||
valueCommentMatch = EnumValueCommentPattern.search(valueData)
|
||||
valueComment = None
|
||||
if valueCommentMatch:
|
||||
valueComment = valueCommentMatch.group(1)
|
||||
|
||||
valueTitle = None
|
||||
valueDescription = None
|
||||
|
||||
if valueComment is not None:
|
||||
if CommentSkipFormat.match(valueComment) is not None:
|
||||
continue
|
||||
commentMatch = CommentMatchFormat.match(valueComment)
|
||||
if commentMatch is not None:
|
||||
valueTitle = commentMatch.group(4)
|
||||
valueDescription = commentMatch.group(6)
|
||||
else:
|
||||
valueDescription = valueComment
|
||||
|
||||
if valueTitle is None:
|
||||
valueTitle = valueName
|
||||
if valueDescription is None:
|
||||
valueDescription = ''
|
||||
|
||||
values.append((valueName, valueTitle, valueDescription, valuePrefix))
|
||||
|
||||
enums.append((prefix + name, prefix, values))
|
||||
print('%s.h: Enum %s parsed with %d values' % (filename, name, len(values)))
|
||||
|
||||
if not enums:
|
||||
return
|
||||
|
||||
print('Done parsing %s.h (in %s)\n' % (filename, path))
|
||||
output = open('%s/enuminfo_%s.cpp' % (path, filename), 'w')
|
||||
if output is None:
|
||||
print('Failed to create enuminfo_%s.cpp' % filename)
|
||||
return
|
||||
|
||||
# write output file
|
||||
output.write(notice)
|
||||
output.write('#include "%s.h"\n' % filename)
|
||||
output.write('#include "Define.h"\n')
|
||||
output.write('#include "SmartEnum.h"\n')
|
||||
output.write('#include <stdexcept>\n')
|
||||
output.write('\n')
|
||||
output.write('namespace Trinity::Impl::EnumUtilsImpl\n')
|
||||
output.write('{\n')
|
||||
for name, prefix, values in enums:
|
||||
tag = ('data for enum \'%s\' in \'%s.h\' auto-generated' % (name, filename))
|
||||
output.write('\n')
|
||||
output.write('/*' + ('*'*(len(tag)+2)) + '*\\\n')
|
||||
output.write('|* ' + tag + ' *|\n')
|
||||
output.write('\\*' + ('*'*(len(tag)+2)) + '*/\n')
|
||||
output.write('template <>\n')
|
||||
output.write('TC_API_EXPORT EnumText EnumUtils<%s>::ToString(%s value)\n' % (name, name))
|
||||
output.write('{\n')
|
||||
output.write(' switch (value)\n')
|
||||
output.write(' {\n')
|
||||
for label, title, description, labelPrefix in values:
|
||||
output.write(' case %s: return { %s, %s, %s };\n' % (prefix + labelPrefix + label, strescape(label), strescape(title), strescape(description)))
|
||||
output.write(' default: throw std::out_of_range("value");\n')
|
||||
output.write(' }\n')
|
||||
output.write('}\n')
|
||||
output.write('\n')
|
||||
output.write('template <>\n')
|
||||
output.write('TC_API_EXPORT size_t EnumUtils<%s>::Count() { return %d; }\n' % (name, len(values)))
|
||||
output.write('\n')
|
||||
output.write('template <>\n')
|
||||
output.write('TC_API_EXPORT %s EnumUtils<%s>::FromIndex(size_t index)\n' % (name, name))
|
||||
output.write('{\n')
|
||||
output.write(' switch (index)\n')
|
||||
output.write(' {\n')
|
||||
for (i, (label, title, description, labelPrefix)) in enumerate(values):
|
||||
output.write(' case %d: return %s;\n' % (i, prefix + labelPrefix + label))
|
||||
output.write(' default: throw std::out_of_range("index");\n')
|
||||
output.write(' }\n')
|
||||
output.write('}\n')
|
||||
output.write('\n')
|
||||
output.write('template <>\n')
|
||||
output.write('TC_API_EXPORT size_t EnumUtils<%s>::ToIndex(%s value)\n' % (name, name))
|
||||
output.write('{\n')
|
||||
output.write(' switch (value)\n')
|
||||
output.write(' {\n')
|
||||
for (i, (label, title, description, labelPrefix)) in enumerate(values):
|
||||
output.write(' case %s: return %d;\n' % (prefix + labelPrefix + label, i))
|
||||
output.write(' default: throw std::out_of_range("value");\n')
|
||||
output.write(' }\n')
|
||||
output.write('}\n')
|
||||
|
||||
output.write('}\n')
|
||||
|
||||
FilenamePattern = compile(r'^(.+)\.h$')
|
||||
for root, dirs, files in walk('.'):
|
||||
for n in files:
|
||||
nameMatch = FilenamePattern.match(n)
|
||||
if nameMatch is not None:
|
||||
processFile(root, nameMatch.group(1))
|
||||
@@ -1,106 +0,0 @@
|
||||
@ECHO OFF
|
||||
CLS
|
||||
|
||||
:MENU
|
||||
ECHO.
|
||||
ECHO ====================== Extractor ========================
|
||||
ECHO TrinityCore cameras, dbc, maps, vmaps and mmaps extractor
|
||||
ECHO =========================================================
|
||||
ECHO.
|
||||
ECHO ======================================================
|
||||
ECHO WARNING! When extracting the vmaps extractor will
|
||||
ECHO output the textS below, it's intended and not an error:
|
||||
ECHO ======================================================
|
||||
ECHO Extracting World\Wmo\Band\Final_Stage.wmo
|
||||
ECHO No such file.
|
||||
ECHO Couldn't open RootWmo!!!
|
||||
ECHO Done!
|
||||
ECHO ======================================================
|
||||
ECHO Can't open WDT for map <a number> - <a name> (FileNameID <number>): FILE NOT FOUND
|
||||
ECHO ..........................................
|
||||
ECHO.
|
||||
ECHO 1: Extract base files (NEEDED) and cameras.
|
||||
ECHO 2: Extract vmaps (needs maps to be extracted before you run this)
|
||||
ECHO 3: Extract mmaps (needs vmaps to be extracted before you run this, may take hours) (OPTIONAL, but highly recommended)
|
||||
ECHO 4: Extract all (may take hours)
|
||||
ECHO 5: Extract all with logs (may take hours)
|
||||
ECHO 6: EXIT
|
||||
ECHO.
|
||||
SET /P M=Type 1, 2, 3, 4, 5 or 6 then press ENTER:
|
||||
IF %M%==1 GOTO MAPS
|
||||
IF %M%==2 GOTO VMAPS
|
||||
IF %M%==3 GOTO MMAPS
|
||||
IF %M%==4 GOTO ALL
|
||||
IF %M%==5 GOTO ALLWITHLOGS
|
||||
IF %M%==6 GOTO :EOF
|
||||
|
||||
:MAPS
|
||||
ECHO.
|
||||
START /b /w mapextractor.exe
|
||||
TIMEOUT 5 > NUL
|
||||
CLS
|
||||
GOTO MENU
|
||||
|
||||
:VMAPS
|
||||
ECHO.
|
||||
START /b /w vmap4extractor.exe
|
||||
START /b /w vmap4assembler.exe Buildings vmaps
|
||||
RMDIR Buildings /s /q
|
||||
TIMEOUT 5 > NUL
|
||||
CLS
|
||||
GOTO MENU
|
||||
|
||||
:MMAPS
|
||||
ECHO.
|
||||
ECHO This may take a few hours to complete. Please be patient.
|
||||
TIMEOUT 5 > NUL
|
||||
START /b /w mmaps_generator.exe
|
||||
TIMEOUT 5 > NUL
|
||||
CLS
|
||||
GOTO MENU
|
||||
|
||||
:ALL
|
||||
ECHO.
|
||||
ECHO This may take a few hours to complete. Please be patient.
|
||||
TIMEOUT 5 > NUL
|
||||
START /b /w mapextractor.exe
|
||||
TIMEOUT 5 > NUL
|
||||
START /b /w vmap4extractor.exe
|
||||
TIMEOUT 5 > NUL
|
||||
START /b /w vmap4assembler.exe
|
||||
RMDIR Buildings /s /q
|
||||
TIMEOUT 5 > NUL
|
||||
START /b /w mmaps_generator.exe
|
||||
TIMEOUT 5 > NUL
|
||||
CLS
|
||||
GOTO MENU
|
||||
|
||||
REM "2>&1" merges Standard Error (stderr) with Standard Output (stdout).
|
||||
REM The results are redirected ">" into the log file.
|
||||
:ALLWITHLOGS
|
||||
ECHO.
|
||||
ECHO This may take a few hours to complete. Please be patient.
|
||||
ECHO.
|
||||
TIMEOUT 5 > NUL
|
||||
ECHO Extracting cameras, dbc and maps.
|
||||
START /b /w mapextractor.exe 2>&1 > mapextractor.log
|
||||
ECHO cameras, dbc and maps extracted.
|
||||
ECHO.
|
||||
TIMEOUT 5 > NUL
|
||||
ECHO Extracting Buildings for Vmaps.
|
||||
START /b /w vmap4extractor.exe 2>&1 > vmap4extractor.log
|
||||
ECHO Buildings for Vmaps extracted.
|
||||
ECHO.
|
||||
TIMEOUT 5 > NUL
|
||||
ECHO Assembling Buildings with Vmaps.
|
||||
START /b /w vmap4assembler.exe 2>&1 > vmap4assembler.log
|
||||
RMDIR Buildings /s /q
|
||||
ECHO Buildings with Vmaps Assembled.
|
||||
ECHO.
|
||||
TIMEOUT 5 > NUL
|
||||
ECHO Generating Mmaps (This takes the longest time).
|
||||
START /b /w mmaps_generator.exe 2>&1 > mmaps_generator.log
|
||||
ECHO Mmaps generated.
|
||||
TIMEOUT 5 > NUL
|
||||
CLS
|
||||
GOTO MENU
|
||||
@@ -1,184 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set client and server directories as environment variables
|
||||
# if you don't want to enter them here
|
||||
if [ -z "$CLIENT_DIR" ]; then
|
||||
echo -n "Enter directory where client files are located: "
|
||||
read CLIENT_DIR
|
||||
|
||||
if ! cd "$CLIENT_DIR"; then
|
||||
echo "Cannot access $CLIENT_DIR"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d "$CLIENT_DIR/Data" ]; then
|
||||
echo "Cannot find client files in $CLIENT_DIR"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$SERVER_DIR" ]; then
|
||||
echo -n "Enter directory where server files are located: "
|
||||
read SERVER_DIR
|
||||
|
||||
if ! cd "$SERVER_DIR"; then
|
||||
echo "Cannot access $SERVER_DIR"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# These should all be correct on a standard installation
|
||||
DATA_DIR="${SERVER_DIR}/data"
|
||||
MAPEXTRACTOR="${SERVER_DIR}/bin/mapextractor"
|
||||
VMAP4EXTRACTOR="${SERVER_DIR}/bin/vmap4extractor"
|
||||
VMAP4ASSEMBLER="${SERVER_DIR}/bin/vmap4assembler"
|
||||
MMAPS_GENERATOR="${SERVER_DIR}/bin/mmaps_generator"
|
||||
|
||||
check_files() {
|
||||
for i in "$MAPEXTRACTOR" "$VMAP4EXTRACTOR" "$VMAP4ASSEMBLER" "$MMAPS_GENERATOR"
|
||||
do
|
||||
if [[ ! -x $i ]]
|
||||
then
|
||||
echo "Invalid executable: $i"
|
||||
echo "Check that the extraction tools are installed correctly."
|
||||
exit
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
show_header() {
|
||||
echo "======================================================"
|
||||
echo "Trinitycore (master) DBC, Maps, VMaps & MMaps Extractor"
|
||||
echo "======================================================"
|
||||
echo
|
||||
echo
|
||||
echo "Client directory: ${CLIENT_DIR}"
|
||||
echo "Data directory: ${DATA_DIR}"
|
||||
echo
|
||||
}
|
||||
|
||||
extract_dbc_maps() {
|
||||
echo
|
||||
echo "Extracting DBC, gt, Camera and Maps files"
|
||||
echo
|
||||
echo "-- Using $MAPEXTRACTOR"
|
||||
echo "-- Copying extracted data to ${DATA_DIR}"
|
||||
if [[ ! -d "${DATA_DIR}" ]]
|
||||
then
|
||||
echo "-- Creating ${DATA_DIR}"
|
||||
mkdir "${DATA_DIR}"
|
||||
fi
|
||||
echo "-- Starting in 5 seconds"
|
||||
sleep 5
|
||||
|
||||
cd "${CLIENT_DIR}"
|
||||
"$MAPEXTRACTOR"
|
||||
|
||||
echo "-- Extraction complete, copying dbc, gt and maps files"
|
||||
cp -r dbc gt maps "${DATA_DIR}"
|
||||
if [[ -d "${CLIENT_DIR}/cameras" ]]
|
||||
then
|
||||
echo "-- Camera files found, copying"
|
||||
cp -r cameras "${DATA_DIR}"
|
||||
fi
|
||||
|
||||
echo "-- Done"
|
||||
echo
|
||||
}
|
||||
|
||||
extract_vmaps() {
|
||||
echo
|
||||
echo "Extracting Visual Maps"
|
||||
echo
|
||||
echo "-- Using ${VMAP4EXTRACTOR}"
|
||||
echo "-- Using ${VMAP4ASSEMBLER}"
|
||||
echo "-- Copying extracted data to ${DATA_DIR}/vmaps"
|
||||
echo "-- Starting in 5 seconds"
|
||||
sleep 5
|
||||
|
||||
cd "${CLIENT_DIR}"
|
||||
"$VMAP4EXTRACTOR"
|
||||
mkdir vmaps
|
||||
"$VMAP4ASSEMBLER" Buildings vmaps
|
||||
|
||||
echo "-- Extraction complete, copying files"
|
||||
cp -r vmaps "${DATA_DIR}"
|
||||
echo "-- Done"
|
||||
echo
|
||||
}
|
||||
|
||||
extract_mmaps() {
|
||||
echo
|
||||
echo "Extracting Movement Maps (this may take a while)"
|
||||
echo
|
||||
echo "-- Using ${MMAPS_GENERATOR}"
|
||||
echo "-- Copying extracted data to ${DATA_DIR}/mmaps"
|
||||
echo "-- Starting in 5 seconds"
|
||||
sleep 5
|
||||
|
||||
cd "${CLIENT_DIR}"
|
||||
mkdir mmaps
|
||||
"$MMAPS_GENERATOR"
|
||||
echo "-- Extraction complete, copying files"
|
||||
cp -r mmaps "${DATA_DIR}"
|
||||
echo "-- Done"
|
||||
echo
|
||||
}
|
||||
|
||||
clean_client() {
|
||||
echo
|
||||
echo "Cleaning up extracted client files (copied server files are not removed)"
|
||||
echo
|
||||
echo "Deleting the following directories from ${CLIENT_DIR}"
|
||||
echo "-- Buildings, cameras, dbc, gt, maps, mmaps, vmaps"
|
||||
echo
|
||||
echo "Enter y to continue or anything else to cancel"
|
||||
read a
|
||||
if [[ ${a} = "y" ]]
|
||||
then
|
||||
cd "${CLIENT_DIR}"
|
||||
rm -fr Buildings cameras dbc gt maps mmaps vmaps
|
||||
echo "Done"
|
||||
fi
|
||||
}
|
||||
|
||||
show_menu() {
|
||||
PS3='Enter choice: '
|
||||
options=("Extract DBC and Maps files" "Extract Visual Maps (VMaps)" "Extract Movement Maps (MMaps)"
|
||||
"Extract all files" "Clean up client" "Quit")
|
||||
select opt in "${options[@]}"
|
||||
do
|
||||
case $opt in
|
||||
"Extract DBC and Maps files")
|
||||
extract_dbc_maps
|
||||
show_header
|
||||
;;
|
||||
"Extract Visual Maps (VMaps)")
|
||||
extract_vmaps
|
||||
show_header
|
||||
;;
|
||||
"Extract Movement Maps (MMaps)")
|
||||
extract_mmaps
|
||||
show_header
|
||||
;;
|
||||
"Extract all files")
|
||||
extract_dbc_maps
|
||||
extract_vmaps
|
||||
extract_mmaps
|
||||
echo "All files extracted"
|
||||
break
|
||||
;;
|
||||
"Clean up client")
|
||||
clean_client
|
||||
;;
|
||||
"Quit")
|
||||
echo
|
||||
break
|
||||
;;
|
||||
*) echo "$REPLY is not a valid option";;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
show_header
|
||||
check_files
|
||||
show_menu
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,691 +0,0 @@
|
||||
{
|
||||
"annotations": {
|
||||
"list": [
|
||||
{
|
||||
"builtIn": 1,
|
||||
"datasource": "-- Grafana --",
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations & Alerts",
|
||||
"type": "dashboard"
|
||||
},
|
||||
{
|
||||
"datasource": "Influx",
|
||||
"enable": true,
|
||||
"iconColor": "#C0C6BE",
|
||||
"iconSize": 13,
|
||||
"lineColor": "rgba(255, 96, 96, 0.592157)",
|
||||
"name": "Global Events",
|
||||
"query": "select title, text from events where $timeFilter and realm =~ /$realm$/",
|
||||
"showLine": true,
|
||||
"textColumn": "text",
|
||||
"titleColumn": "title"
|
||||
}
|
||||
]
|
||||
},
|
||||
"editable": true,
|
||||
"gnetId": null,
|
||||
"graphTooltip": 0,
|
||||
"id": 6,
|
||||
"iteration": 1595939001794,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Influx",
|
||||
"editable": true,
|
||||
"error": false,
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"grid": {},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 24,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 2,
|
||||
"isNew": true,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 2,
|
||||
"links": [],
|
||||
"nullPointMode": "connected",
|
||||
"options": {
|
||||
"dataLinks": []
|
||||
},
|
||||
"percentage": false,
|
||||
"pointradius": 5,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [
|
||||
{
|
||||
"alias": "Unload tile",
|
||||
"transform": "negative-Y"
|
||||
}
|
||||
],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"alias": "Load tile",
|
||||
"dsType": "influxdb",
|
||||
"groupBy": [
|
||||
{
|
||||
"params": [
|
||||
"$interval"
|
||||
],
|
||||
"type": "time"
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
"0"
|
||||
],
|
||||
"type": "fill"
|
||||
}
|
||||
],
|
||||
"query": "SELECT count(\"title\") FROM \"map_events\" WHERE \"realm\" =~ /$realm$/ AND \"title\" = 'LoadMapTile' AND $timeFilter GROUP BY time($interval) fill(0)",
|
||||
"rawQuery": true,
|
||||
"refId": "A",
|
||||
"resultFormat": "time_series",
|
||||
"select": [
|
||||
[
|
||||
{
|
||||
"params": [
|
||||
"value"
|
||||
],
|
||||
"type": "field"
|
||||
},
|
||||
{
|
||||
"params": [],
|
||||
"type": "mean"
|
||||
}
|
||||
]
|
||||
],
|
||||
"tags": []
|
||||
},
|
||||
{
|
||||
"alias": "Unload tile",
|
||||
"dsType": "influxdb",
|
||||
"groupBy": [
|
||||
{
|
||||
"params": [
|
||||
"$interval"
|
||||
],
|
||||
"type": "time"
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
"null"
|
||||
],
|
||||
"type": "fill"
|
||||
}
|
||||
],
|
||||
"query": "SELECT count(\"title\") FROM \"map_events\" WHERE \"realm\" =~ /$realm$/ AND \"title\" = 'UnloadMapTile' AND $timeFilter GROUP BY time($interval) fill(0)",
|
||||
"rawQuery": true,
|
||||
"refId": "B",
|
||||
"resultFormat": "time_series",
|
||||
"select": [
|
||||
[
|
||||
{
|
||||
"params": [
|
||||
"value"
|
||||
],
|
||||
"type": "field"
|
||||
},
|
||||
{
|
||||
"params": [],
|
||||
"type": "mean"
|
||||
}
|
||||
]
|
||||
],
|
||||
"tags": []
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Map",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "cumulative"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Influx",
|
||||
"editable": true,
|
||||
"error": false,
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"grid": {},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 24,
|
||||
"x": 0,
|
||||
"y": 7
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 1,
|
||||
"isNew": true,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 2,
|
||||
"links": [],
|
||||
"nullPointMode": "connected",
|
||||
"options": {
|
||||
"dataLinks": []
|
||||
},
|
||||
"percentage": false,
|
||||
"pointradius": 5,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"alias": "Pathfinding queries",
|
||||
"dsType": "influxdb",
|
||||
"groupBy": [
|
||||
{
|
||||
"params": [
|
||||
"$interval"
|
||||
],
|
||||
"type": "time"
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
"null"
|
||||
],
|
||||
"type": "fill"
|
||||
}
|
||||
],
|
||||
"query": "SELECT count(\"title\") FROM \"mmap_events\" WHERE \"realm\" =~ /$realm$/ AND \"title\" = 'CalculatePath' AND $timeFilter GROUP BY time($interval) fill(0)",
|
||||
"rawQuery": true,
|
||||
"refId": "A",
|
||||
"resultFormat": "time_series",
|
||||
"select": [
|
||||
[
|
||||
{
|
||||
"params": [
|
||||
"value"
|
||||
],
|
||||
"type": "field"
|
||||
},
|
||||
{
|
||||
"params": [],
|
||||
"type": "mean"
|
||||
}
|
||||
]
|
||||
],
|
||||
"tags": []
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "MMap",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "cumulative"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": null,
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 5,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 24,
|
||||
"x": 0,
|
||||
"y": 14
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 4,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"hideEmpty": false,
|
||||
"hideZero": true,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"options": {
|
||||
"dataLinks": []
|
||||
},
|
||||
"percentage": false,
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"alias": "Map $tag_map_id Instance $tag_map_instanceid",
|
||||
"groupBy": [
|
||||
{
|
||||
"params": [
|
||||
"$__interval"
|
||||
],
|
||||
"type": "time"
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
"map_id"
|
||||
],
|
||||
"type": "tag"
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
"map_instanceid"
|
||||
],
|
||||
"type": "tag"
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
"none"
|
||||
],
|
||||
"type": "fill"
|
||||
}
|
||||
],
|
||||
"measurement": "map_creatures",
|
||||
"orderByTime": "ASC",
|
||||
"policy": "default",
|
||||
"refId": "A",
|
||||
"resultFormat": "time_series",
|
||||
"select": [
|
||||
[
|
||||
{
|
||||
"params": [
|
||||
"value"
|
||||
],
|
||||
"type": "field"
|
||||
},
|
||||
{
|
||||
"params": [],
|
||||
"type": "mean"
|
||||
}
|
||||
]
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"key": "realm",
|
||||
"operator": "=~",
|
||||
"value": "/^$realm$/"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Creatures",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": null,
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 5,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 24,
|
||||
"x": 0,
|
||||
"y": 22
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 5,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"hideEmpty": false,
|
||||
"hideZero": true,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "null",
|
||||
"options": {
|
||||
"dataLinks": []
|
||||
},
|
||||
"percentage": false,
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"alias": "Map $tag_map_id Instance $tag_map_instanceid",
|
||||
"groupBy": [
|
||||
{
|
||||
"params": [
|
||||
"$__interval"
|
||||
],
|
||||
"type": "time"
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
"map_id"
|
||||
],
|
||||
"type": "tag"
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
"map_instanceid"
|
||||
],
|
||||
"type": "tag"
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
"none"
|
||||
],
|
||||
"type": "fill"
|
||||
}
|
||||
],
|
||||
"measurement": "map_gameobjects",
|
||||
"orderByTime": "ASC",
|
||||
"policy": "default",
|
||||
"refId": "A",
|
||||
"resultFormat": "time_series",
|
||||
"select": [
|
||||
[
|
||||
{
|
||||
"params": [
|
||||
"value"
|
||||
],
|
||||
"type": "field"
|
||||
},
|
||||
{
|
||||
"params": [],
|
||||
"type": "mean"
|
||||
}
|
||||
]
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"key": "realm",
|
||||
"operator": "=~",
|
||||
"value": "/^$realm$/"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Gameobjects",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"refresh": "1m",
|
||||
"schemaVersion": 25,
|
||||
"style": "dark",
|
||||
"tags": [],
|
||||
"templating": {
|
||||
"list": [
|
||||
{
|
||||
"allFormat": "regex values",
|
||||
"allValue": null,
|
||||
"current": {
|
||||
"text": "Trinity",
|
||||
"value": "Trinity"
|
||||
},
|
||||
"datasource": "Influx",
|
||||
"definition": "",
|
||||
"hide": 0,
|
||||
"includeAll": false,
|
||||
"label": null,
|
||||
"multi": false,
|
||||
"multiFormat": "regex values",
|
||||
"name": "realm",
|
||||
"options": [],
|
||||
"query": "show tag values from events with key = realm",
|
||||
"refresh": 1,
|
||||
"regex": "",
|
||||
"skipUrlSync": false,
|
||||
"sort": 0,
|
||||
"tagValuesQuery": "",
|
||||
"tags": [],
|
||||
"tagsQuery": "",
|
||||
"type": "query",
|
||||
"useTags": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"time": {
|
||||
"from": "now-15m",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {
|
||||
"now": true,
|
||||
"refresh_intervals": [
|
||||
"10s",
|
||||
"30s",
|
||||
"1m",
|
||||
"5m",
|
||||
"15m",
|
||||
"30m",
|
||||
"1h",
|
||||
"2h",
|
||||
"1d"
|
||||
],
|
||||
"time_options": [
|
||||
"5m",
|
||||
"15m",
|
||||
"1h",
|
||||
"6h",
|
||||
"12h",
|
||||
"24h",
|
||||
"2d",
|
||||
"7d",
|
||||
"30d"
|
||||
]
|
||||
},
|
||||
"timezone": "browser",
|
||||
"title": "Maps, vmaps and mmaps",
|
||||
"uid": "6IhqWiWGz",
|
||||
"version": 2
|
||||
}
|
||||
@@ -1,280 +0,0 @@
|
||||
{
|
||||
"annotations": {
|
||||
"list": [
|
||||
{
|
||||
"builtIn": 1,
|
||||
"datasource": "-- Grafana --",
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations & Alerts",
|
||||
"type": "dashboard"
|
||||
},
|
||||
{
|
||||
"datasource": "Influx",
|
||||
"enable": true,
|
||||
"iconColor": "#C0C6BE",
|
||||
"iconSize": 13,
|
||||
"lineColor": "rgba(255, 96, 96, 0.592157)",
|
||||
"name": "Global Events",
|
||||
"query": "select title, text from events where $timeFilter and realm =~ /$realm$/",
|
||||
"showLine": true,
|
||||
"textColumn": "text",
|
||||
"titleColumn": "title"
|
||||
}
|
||||
]
|
||||
},
|
||||
"editable": true,
|
||||
"gnetId": null,
|
||||
"graphTooltip": 0,
|
||||
"id": 7,
|
||||
"iteration": 1595939048589,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "Influx",
|
||||
"editable": true,
|
||||
"error": false,
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"custom": {}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"grid": {},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 24,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 1,
|
||||
"isNew": true,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 2,
|
||||
"links": [],
|
||||
"nullPointMode": "connected",
|
||||
"options": {
|
||||
"dataLinks": []
|
||||
},
|
||||
"percentage": false,
|
||||
"pointradius": 5,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"alias": "Processed packets",
|
||||
"dsType": "influxdb",
|
||||
"groupBy": [
|
||||
{
|
||||
"params": [
|
||||
"$interval"
|
||||
],
|
||||
"type": "time"
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
"0"
|
||||
],
|
||||
"type": "fill"
|
||||
}
|
||||
],
|
||||
"measurement": "processed_packets",
|
||||
"query": "SELECT sum(\"value\") FROM \"processed_packets\" WHERE \"realm\" =~ /$realm$/ AND $timeFilter GROUP BY time($interval) fill(0)",
|
||||
"refId": "A",
|
||||
"resultFormat": "time_series",
|
||||
"select": [
|
||||
[
|
||||
{
|
||||
"params": [
|
||||
"value"
|
||||
],
|
||||
"type": "field"
|
||||
},
|
||||
{
|
||||
"params": [],
|
||||
"type": "sum"
|
||||
}
|
||||
]
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"key": "realm",
|
||||
"operator": "=~",
|
||||
"value": "/$realm$/"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"alias": "Processed packets / mean per session",
|
||||
"dsType": "influxdb",
|
||||
"groupBy": [
|
||||
{
|
||||
"params": [
|
||||
"$interval"
|
||||
],
|
||||
"type": "time"
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
"0"
|
||||
],
|
||||
"type": "fill"
|
||||
}
|
||||
],
|
||||
"measurement": "processed_packets",
|
||||
"query": "SELECT mean(\"value\") FROM \"processed_packets\" WHERE \"realm\" =~ /$realm$/ AND $timeFilter GROUP BY time($interval) fill(0)",
|
||||
"refId": "B",
|
||||
"resultFormat": "time_series",
|
||||
"select": [
|
||||
[
|
||||
{
|
||||
"params": [
|
||||
"value"
|
||||
],
|
||||
"type": "field"
|
||||
},
|
||||
{
|
||||
"params": [],
|
||||
"type": "mean"
|
||||
}
|
||||
]
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"key": "realm",
|
||||
"operator": "=~",
|
||||
"value": "/$realm$/"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Processed packets",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "cumulative"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"refresh": "1m",
|
||||
"schemaVersion": 25,
|
||||
"style": "dark",
|
||||
"tags": [],
|
||||
"templating": {
|
||||
"list": [
|
||||
{
|
||||
"allFormat": "regex values",
|
||||
"allValue": null,
|
||||
"current": {
|
||||
"text": "Trinity",
|
||||
"value": "Trinity"
|
||||
},
|
||||
"datasource": "Influx",
|
||||
"definition": "",
|
||||
"hide": 0,
|
||||
"includeAll": false,
|
||||
"label": null,
|
||||
"multi": false,
|
||||
"multiFormat": "regex values",
|
||||
"name": "realm",
|
||||
"options": [],
|
||||
"query": "show tag values from events with key = realm",
|
||||
"refresh": 1,
|
||||
"regex": "",
|
||||
"skipUrlSync": false,
|
||||
"sort": 0,
|
||||
"tagValuesQuery": "",
|
||||
"tags": [],
|
||||
"tagsQuery": "",
|
||||
"type": "query",
|
||||
"useTags": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"time": {
|
||||
"from": "now-15m",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {
|
||||
"now": true,
|
||||
"refresh_intervals": [
|
||||
"10s",
|
||||
"30s",
|
||||
"1m",
|
||||
"5m",
|
||||
"15m",
|
||||
"30m",
|
||||
"1h",
|
||||
"2h",
|
||||
"1d"
|
||||
],
|
||||
"time_options": [
|
||||
"5m",
|
||||
"15m",
|
||||
"1h",
|
||||
"6h",
|
||||
"12h",
|
||||
"24h",
|
||||
"2d",
|
||||
"7d",
|
||||
"30d"
|
||||
]
|
||||
},
|
||||
"timezone": "browser",
|
||||
"title": "Network",
|
||||
"uid": "_QtkMmWMk",
|
||||
"version": 2
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
cat ../sql/updates/world/master/*.sql > world_update.sql
|
||||
cat ../sql/updates/hotfixes/master/*.sql > hotfixes_update.sql
|
||||
@@ -1,2 +0,0 @@
|
||||
copy /a ..\sql\updates\world\master\*.sql /b world_updates.sql
|
||||
copy /a ..\sql\updates\hotfixes\master\*.sql /b hotfixes_updates.sql
|
||||
@@ -1,68 +0,0 @@
|
||||
//
|
||||
// Created by tea on 10.03.16.
|
||||
//
|
||||
|
||||
#include <vector>
|
||||
#include "BnetFileGenerator.h"
|
||||
#include "google/protobuf/compiler/cpp/cpp_helpers.h"
|
||||
#include <google/protobuf/io/printer.h>
|
||||
#include <google/protobuf/io/zero_copy_stream.h>
|
||||
#include <google/protobuf/descriptor.pb.h>
|
||||
|
||||
#include "BnetCodeGenerator.h"
|
||||
|
||||
bool BnetCodeGenerator::Generate(pb::FileDescriptor const* file, std::string const& parameter,
|
||||
pbc::GeneratorContext* generator_context, std::string* error) const
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string>> options;
|
||||
google::protobuf::compiler::ParseGeneratorParameter(parameter, &options);
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// parse generator options
|
||||
|
||||
google::protobuf::compiler::cpp::Options file_options;
|
||||
|
||||
for (int i = 0; i < options.size(); i++)
|
||||
{
|
||||
if (options[i].first == "dllexport_decl")
|
||||
{
|
||||
file_options.dllexport_decl = options[i].second;
|
||||
}
|
||||
else if (options[i].first == "safe_boundary_check")
|
||||
{
|
||||
file_options.safe_boundary_check = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
*error = "Unknown generator option: " + options[i].first;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
|
||||
std::string basename = google::protobuf::compiler::cpp::StripProto(file->name());
|
||||
basename.append(".pb");
|
||||
|
||||
BnetFileGenerator file_generator(file, file_options);
|
||||
|
||||
// Generate header.
|
||||
{
|
||||
pb::scoped_ptr <google::protobuf::io::ZeroCopyOutputStream> output(
|
||||
generator_context->Open(basename + ".h"));
|
||||
google::protobuf::io::Printer printer(output.get(), '$');
|
||||
file_generator.GenerateHeader(&printer);
|
||||
}
|
||||
|
||||
// Generate cc file.
|
||||
{
|
||||
pb::scoped_ptr <google::protobuf::io::ZeroCopyOutputStream> output(
|
||||
generator_context->Open(basename + ".cc"));
|
||||
google::protobuf::io::Printer printer(output.get(), '$');
|
||||
file_generator.GenerateSource(&printer);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
//
|
||||
// Created by tea on 10.03.16.
|
||||
//
|
||||
|
||||
#ifndef PROTOC_BNET_BNETCODEGENERATOR_H
|
||||
#define PROTOC_BNET_BNETCODEGENERATOR_H
|
||||
|
||||
#include <google/protobuf/compiler/code_generator.h>
|
||||
#include <string>
|
||||
|
||||
namespace pb = google::protobuf;
|
||||
namespace pbc = pb::compiler;
|
||||
|
||||
class BnetCodeGenerator : public pbc::CodeGenerator
|
||||
{
|
||||
public:
|
||||
bool Generate(pb::FileDescriptor const* file,
|
||||
std::string const& parameter,
|
||||
pbc::GeneratorContext* generator_context,
|
||||
std::string* error) const override;
|
||||
|
||||
};
|
||||
|
||||
#endif //PROTOC_BNET_BNETCODEGENERATOR_H
|
||||
@@ -1,696 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#include "BnetFileGenerator.h"
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
#include "google/protobuf/compiler/cpp/cpp_enum.h"
|
||||
#include "BnetServiceGenerator.h"
|
||||
#include "BnetCodeGenerator.h"
|
||||
#include "google/protobuf/compiler/cpp/cpp_extension.h"
|
||||
#include "google/protobuf/compiler/cpp/cpp_helpers.h"
|
||||
#include "google/protobuf/compiler/cpp/cpp_message.h"
|
||||
#include "google/protobuf/compiler/cpp/cpp_field.h"
|
||||
#include <google/protobuf/io/printer.h>
|
||||
#include <google/protobuf/descriptor.pb.h>
|
||||
#include "google/protobuf/stubs/strutil.h"
|
||||
|
||||
|
||||
// ===================================================================
|
||||
|
||||
BnetFileGenerator::BnetFileGenerator(const pb::FileDescriptor* file, const pbcpp::Options& options)
|
||||
: file_(file),
|
||||
message_generators_(
|
||||
new pb::scoped_ptr<pbcpp::MessageGenerator>[file->message_type_count()]),
|
||||
enum_generators_(
|
||||
new pb::scoped_ptr<pbcpp::EnumGenerator>[file->enum_type_count()]),
|
||||
service_generators_(
|
||||
new pb::scoped_ptr<BnetServiceGenerator>[file->service_count()]),
|
||||
extension_generators_(
|
||||
new pb::scoped_ptr<pbcpp::ExtensionGenerator>[file->extension_count()]),
|
||||
options_(options)
|
||||
{
|
||||
|
||||
for (int i = 0; i < file->message_type_count(); i++)
|
||||
{
|
||||
message_generators_[i].reset(
|
||||
new pbcpp::MessageGenerator(file->message_type(i), options));
|
||||
}
|
||||
|
||||
for (int i = 0; i < file->enum_type_count(); i++)
|
||||
{
|
||||
enum_generators_[i].reset(
|
||||
new pbcpp::EnumGenerator(file->enum_type(i), options));
|
||||
}
|
||||
|
||||
for (int i = 0; i < file->service_count(); i++)
|
||||
{
|
||||
service_generators_[i].reset(
|
||||
new BnetServiceGenerator(file->service(i), options));
|
||||
}
|
||||
|
||||
for (int i = 0; i < file->extension_count(); i++)
|
||||
{
|
||||
extension_generators_[i].reset(
|
||||
new pbcpp::ExtensionGenerator(file->extension(i), options));
|
||||
}
|
||||
|
||||
pb::SplitStringUsing(file_->package(), ".", &package_parts_);
|
||||
}
|
||||
|
||||
BnetFileGenerator::~BnetFileGenerator() { }
|
||||
|
||||
void BnetFileGenerator::GenerateHeader(pb::io::Printer* printer)
|
||||
{
|
||||
std::string filename_identifier = pbcpp::FilenameIdentifier(file_->name());
|
||||
|
||||
// Generate top of header.
|
||||
printer->Print(
|
||||
"// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
|
||||
"// source: $filename$\n"
|
||||
"\n"
|
||||
"#ifndef PROTOBUF_$filename_identifier$__INCLUDED\n"
|
||||
"#define PROTOBUF_$filename_identifier$__INCLUDED\n"
|
||||
"\n"
|
||||
"#include <string>\n"
|
||||
"\n",
|
||||
"filename", file_->name(),
|
||||
"filename_identifier", filename_identifier);
|
||||
|
||||
printer->Print("#include <google/protobuf/stubs/common.h>\n\n");
|
||||
|
||||
// Verify the protobuf library header version is compatible with the protoc
|
||||
// version before going any further.
|
||||
printer->Print(
|
||||
"#if GOOGLE_PROTOBUF_VERSION < $min_header_version$\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 $protoc_version$ < 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",
|
||||
"min_header_version",
|
||||
pb::SimpleItoa(pb::internal::kMinHeaderVersionForProtoc),
|
||||
"protoc_version", pb::SimpleItoa(GOOGLE_PROTOBUF_VERSION));
|
||||
|
||||
// OK, it's now safe to #include other files.
|
||||
printer->Print("#include <google/protobuf/generated_message_util.h>\n");
|
||||
if (file_->message_type_count() > 0)
|
||||
{
|
||||
if (pbcpp::HasDescriptorMethods(file_))
|
||||
printer->Print("#include <google/protobuf/message.h>\n");
|
||||
else
|
||||
printer->Print("#include <google/protobuf/message_lite.h>\n");
|
||||
}
|
||||
|
||||
printer->Print(
|
||||
"#include <google/protobuf/repeated_field.h>\n"
|
||||
"#include <google/protobuf/extension_set.h>\n");
|
||||
|
||||
if (pbcpp::HasDescriptorMethods(file_) && pbcpp::HasEnumDefinitions(file_))
|
||||
printer->Print("#include <google/protobuf/generated_enum_reflection.h>\n");
|
||||
|
||||
if (pbcpp::UseUnknownFieldSet(file_) && file_->message_type_count() > 0)
|
||||
{
|
||||
printer->Print("#include <google/protobuf/unknown_field_set.h>\n");
|
||||
}
|
||||
|
||||
std::set<std::string> public_import_names;
|
||||
for (int i = 0; i < file_->public_dependency_count(); i++)
|
||||
public_import_names.insert(file_->public_dependency(i)->name());
|
||||
|
||||
for (int i = 0; i < file_->dependency_count(); i++)
|
||||
{
|
||||
const std::string& name = file_->dependency(i)->name();
|
||||
bool public_import = (public_import_names.count(name) != 0);
|
||||
|
||||
printer->Print(
|
||||
"#include \"$dependency$.pb.h\"$iwyu$\n",
|
||||
"dependency", pbcpp::StripProto(name),
|
||||
"iwyu", (public_import) ? " // IWYU pragma: export" : "");
|
||||
}
|
||||
|
||||
if (file_->service_count() > 0)
|
||||
{
|
||||
printer->Print("#include \"ServiceBase.h\"\n");
|
||||
printer->Print("#include \"MessageBuffer.h\"\n");
|
||||
printer->Print("#include <functional>\n");
|
||||
printer->Print("#include <type_traits>\n");
|
||||
}
|
||||
else
|
||||
printer->Print("#include \"Define.h\" // for TC_PROTO_API\n");
|
||||
|
||||
|
||||
printer->Print("// @@protoc_insertion_point(includes)\n");
|
||||
|
||||
// Open namespace.
|
||||
GenerateNamespaceOpeners(printer);
|
||||
|
||||
// Forward-declare the AddDescriptors, AssignDescriptors, and ShutdownFile
|
||||
// functions, so that we can declare them to be friends of each class.
|
||||
printer->Print(
|
||||
"\n"
|
||||
"// Internal implementation detail -- do not call these.\n"
|
||||
"void $dllexport_decl$ $adddescriptorsname$();\n",
|
||||
"adddescriptorsname", pbcpp::GlobalAddDescriptorsName(file_->name()),
|
||||
"dllexport_decl", options_.dllexport_decl);
|
||||
|
||||
printer->Print(
|
||||
// Note that we don't put dllexport_decl on these because they are only
|
||||
// called by the .pb.cc file in which they are defined.
|
||||
"void $assigndescriptorsname$();\n"
|
||||
"void $shutdownfilename$();\n"
|
||||
"\n",
|
||||
"assigndescriptorsname", pbcpp::GlobalAssignDescriptorsName(file_->name()),
|
||||
"shutdownfilename", pbcpp::GlobalShutdownFileName(file_->name()));
|
||||
|
||||
// Generate forward declarations of classes.
|
||||
if (file_->message_type_count() > 0)
|
||||
{
|
||||
for (int i = 0; i < file_->message_type_count(); i++)
|
||||
message_generators_[i]->GenerateForwardDeclaration(printer);
|
||||
|
||||
printer->Print("\n");
|
||||
}
|
||||
|
||||
// Generate enum definitions.
|
||||
for (int i = 0; i < file_->message_type_count(); i++)
|
||||
message_generators_[i]->GenerateEnumDefinitions(printer);
|
||||
|
||||
for (int i = 0; i < file_->enum_type_count(); i++)
|
||||
enum_generators_[i]->GenerateDefinition(printer);
|
||||
|
||||
printer->Print(pbcpp::kThickSeparator);
|
||||
|
||||
// Generate class definitions.
|
||||
for (int i = 0; i < file_->message_type_count(); i++)
|
||||
{
|
||||
printer->Print("\n");
|
||||
if (i > 0)
|
||||
{
|
||||
printer->Print(pbcpp::kThinSeparator);
|
||||
printer->Print("\n");
|
||||
}
|
||||
message_generators_[i]->GenerateClassDefinition(printer);
|
||||
}
|
||||
|
||||
printer->Print("\n");
|
||||
printer->Print(pbcpp::kThickSeparator);
|
||||
|
||||
// Generate service definitions.
|
||||
for (int i = 0; i < file_->service_count(); i++)
|
||||
{
|
||||
printer->Print("\n");
|
||||
if (i > 0)
|
||||
{
|
||||
printer->Print(pbcpp::kThinSeparator);
|
||||
printer->Print("\n");
|
||||
}
|
||||
service_generators_[i]->GenerateDeclarations(printer);
|
||||
}
|
||||
|
||||
printer->Print("\n");
|
||||
printer->Print(pbcpp::kThickSeparator);
|
||||
|
||||
// Declare extension identifiers.
|
||||
if (file_->extension_count() > 0)
|
||||
{
|
||||
printer->Print("\n");
|
||||
for (int i = 0; i < file_->extension_count(); i++)
|
||||
{
|
||||
extension_generators_[i]->GenerateDeclaration(printer);
|
||||
}
|
||||
}
|
||||
|
||||
printer->Print("\n");
|
||||
printer->Print(pbcpp::kThickSeparator);
|
||||
|
||||
// Generate class inline methods.
|
||||
if (file_->message_type_count() > 0)
|
||||
{
|
||||
printer->Print("\n");
|
||||
for (int i = 0; i < file_->message_type_count(); i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
printer->Print(pbcpp::kThinSeparator);
|
||||
printer->Print("\n");
|
||||
}
|
||||
message_generators_[i]->GenerateInlineMethods(printer);
|
||||
}
|
||||
}
|
||||
|
||||
printer->Print(
|
||||
"// @@protoc_insertion_point(namespace_scope)\n");
|
||||
|
||||
// Close up namespace.
|
||||
GenerateNamespaceClosers(printer);
|
||||
|
||||
// Emit GetEnumDescriptor specializations into google::protobuf namespace:
|
||||
if (pbcpp::HasDescriptorMethods(file_))
|
||||
{
|
||||
// The SWIG conditional is to avoid a null-pointer dereference
|
||||
// (bug 1984964) in swig-1.3.21 resulting from the following syntax:
|
||||
// namespace X { void Y<Z::W>(); }
|
||||
// which appears in GetEnumDescriptor() specializations.
|
||||
printer->Print(
|
||||
"\n"
|
||||
"#ifndef SWIG\n"
|
||||
"namespace google {\nnamespace protobuf {\n");
|
||||
for (int i = 0; i < file_->message_type_count(); i++)
|
||||
{
|
||||
message_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer);
|
||||
}
|
||||
for (int i = 0; i < file_->enum_type_count(); i++)
|
||||
{
|
||||
enum_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer);
|
||||
}
|
||||
printer->Print(
|
||||
"} // namespace google\n} // namespace protobuf\n"
|
||||
"#endif // SWIG\n");
|
||||
}
|
||||
|
||||
printer->Print(
|
||||
"\n"
|
||||
"// @@protoc_insertion_point(global_scope)\n"
|
||||
"\n");
|
||||
|
||||
printer->Print(
|
||||
"#endif // PROTOBUF_$filename_identifier$__INCLUDED\n",
|
||||
"filename_identifier", filename_identifier);
|
||||
}
|
||||
|
||||
void BnetFileGenerator::GenerateSource(pb::io::Printer* printer)
|
||||
{
|
||||
printer->Print(
|
||||
"// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
|
||||
"// source: $filename$\n"
|
||||
"\n"
|
||||
|
||||
// The generated code calls accessors that might be deprecated. We don't
|
||||
// want the compiler to warn in generated code.
|
||||
"#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\n"
|
||||
"#include \"$basename$.pb.h\"\n"
|
||||
"\n"
|
||||
"#include <utility>\n" // for swap() and move()
|
||||
"\n"
|
||||
"#include <google/protobuf/stubs/common.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",
|
||||
"filename", file_->name(),
|
||||
"basename", pbcpp::StripProto(file_->name()));
|
||||
|
||||
// Unknown fields implementation in lite mode uses StringOutputStream
|
||||
if (!pbcpp::UseUnknownFieldSet(file_) && file_->message_type_count() > 0)
|
||||
{
|
||||
printer->Print(
|
||||
"#include <google/protobuf/io/zero_copy_stream_impl_lite.h>\n");
|
||||
}
|
||||
|
||||
if (pbcpp::HasDescriptorMethods(file_))
|
||||
{
|
||||
printer->Print(
|
||||
"#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");
|
||||
}
|
||||
|
||||
|
||||
if (file_->service_count() > 0)
|
||||
{
|
||||
printer->Print("#include \"BattlenetRpcErrorCodes.h\"\n");
|
||||
}
|
||||
|
||||
printer->Print(
|
||||
"// @@protoc_insertion_point(includes)\n");
|
||||
|
||||
GenerateNamespaceOpeners(printer);
|
||||
|
||||
if (pbcpp::HasDescriptorMethods(file_)
|
||||
&& (file_->message_type_count() > 0
|
||||
|| file_->enum_type_count() > 0
|
||||
|| file_->service_count() > 0))
|
||||
{
|
||||
printer->Print(
|
||||
"\n"
|
||||
"namespace {\n"
|
||||
"\n");
|
||||
for (int i = 0; i < file_->message_type_count(); i++)
|
||||
{
|
||||
message_generators_[i]->GenerateDescriptorDeclarations(printer);
|
||||
}
|
||||
for (int i = 0; i < file_->enum_type_count(); i++)
|
||||
{
|
||||
printer->Print(
|
||||
"const ::google::protobuf::EnumDescriptor* $name$_descriptor_ = NULL;\n",
|
||||
"name", pbcpp::ClassName(file_->enum_type(i), false));
|
||||
}
|
||||
|
||||
for (int i = 0; i < file_->service_count(); i++)
|
||||
{
|
||||
printer->Print(
|
||||
"const ::google::protobuf::ServiceDescriptor* $name$_descriptor_ = NULL;\n",
|
||||
"name", file_->service(i)->name());
|
||||
}
|
||||
|
||||
printer->Print(
|
||||
"\n"
|
||||
"} // namespace\n");
|
||||
}
|
||||
|
||||
// Define our externally-visible BuildDescriptors() function. (For the lite
|
||||
// library, all this does is initialize default instances.)
|
||||
GenerateBuildDescriptors(printer);
|
||||
|
||||
// Generate enums.
|
||||
for (int i = 0; i < file_->enum_type_count(); i++)
|
||||
{
|
||||
enum_generators_[i]->GenerateMethods(printer);
|
||||
}
|
||||
|
||||
// Generate classes.
|
||||
for (int i = 0; i < file_->message_type_count(); i++)
|
||||
{
|
||||
printer->Print(pbcpp::kThickSeparator);
|
||||
printer->Print("\n");
|
||||
message_generators_[i]->GenerateClassMethods(printer);
|
||||
}
|
||||
|
||||
// Generate services.
|
||||
for (int i = 0; i < file_->service_count(); i++)
|
||||
{
|
||||
printer->Print(pbcpp::kThickSeparator);
|
||||
printer->Print("\n");
|
||||
service_generators_[i]->GenerateImplementation(printer);
|
||||
}
|
||||
|
||||
// Define extensions.
|
||||
for (int i = 0; i < file_->extension_count(); i++)
|
||||
{
|
||||
extension_generators_[i]->GenerateDefinition(printer);
|
||||
}
|
||||
|
||||
printer->Print(
|
||||
"// @@protoc_insertion_point(namespace_scope)\n");
|
||||
|
||||
GenerateNamespaceClosers(printer);
|
||||
|
||||
printer->Print(
|
||||
"\n"
|
||||
"// @@protoc_insertion_point(global_scope)\n");
|
||||
}
|
||||
|
||||
void BnetFileGenerator::GenerateBuildDescriptors(pb::io::Printer* printer)
|
||||
{
|
||||
// AddDescriptors() is a file-level procedure which adds the encoded
|
||||
// FileDescriptorProto for this .proto file to the global DescriptorPool for
|
||||
// generated files (DescriptorPool::generated_pool()). It either runs at
|
||||
// static initialization time (by default) or when default_instance() is
|
||||
// called for the first time (in LITE_RUNTIME mode with
|
||||
// GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER flag enabled). This procedure also
|
||||
// constructs default instances and registers extensions.
|
||||
//
|
||||
// Its sibling, AssignDescriptors(), actually pulls the compiled
|
||||
// FileDescriptor from the DescriptorPool and uses it to populate all of
|
||||
// the global variables which store pointers to the descriptor objects.
|
||||
// It also constructs the reflection objects. It is called the first time
|
||||
// anyone calls descriptor() or GetReflection() on one of the types defined
|
||||
// in the file.
|
||||
|
||||
// In optimize_for = LITE_RUNTIME mode, we don't generate AssignDescriptors()
|
||||
// and we only use AddDescriptors() to allocate default instances.
|
||||
if (pbcpp::HasDescriptorMethods(file_))
|
||||
{
|
||||
printer->Print(
|
||||
"\n"
|
||||
"void $assigndescriptorsname$() {\n",
|
||||
"assigndescriptorsname", pbcpp::GlobalAssignDescriptorsName(file_->name()));
|
||||
printer->Indent();
|
||||
|
||||
// Make sure the file has found its way into the pool. If a descriptor
|
||||
// is requested *during* static init then AddDescriptors() may not have
|
||||
// been called yet, so we call it manually. Note that it's fine if
|
||||
// AddDescriptors() is called multiple times.
|
||||
printer->Print(
|
||||
"$adddescriptorsname$();\n",
|
||||
"adddescriptorsname", pbcpp::GlobalAddDescriptorsName(file_->name()));
|
||||
|
||||
// Get the file's descriptor from the pool.
|
||||
printer->Print(
|
||||
"const ::google::protobuf::FileDescriptor* file =\n"
|
||||
" ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\n"
|
||||
" \"$filename$\");\n"
|
||||
// Note that this GOOGLE_CHECK is necessary to prevent a warning about "file"
|
||||
// being unused when compiling an empty .proto file.
|
||||
"GOOGLE_CHECK(file != NULL);\n",
|
||||
"filename", file_->name());
|
||||
|
||||
// Go through all the stuff defined in this file and generated code to
|
||||
// assign the global descriptor pointers based on the file descriptor.
|
||||
for (int i = 0; i < file_->message_type_count(); i++)
|
||||
{
|
||||
message_generators_[i]->GenerateDescriptorInitializer(printer, i);
|
||||
}
|
||||
for (int i = 0; i < file_->enum_type_count(); i++)
|
||||
{
|
||||
enum_generators_[i]->GenerateDescriptorInitializer(printer, i);
|
||||
}
|
||||
for (int i = 0; i < file_->service_count(); i++)
|
||||
{
|
||||
service_generators_[i]->GenerateDescriptorInitializer(printer, i);
|
||||
}
|
||||
|
||||
printer->Outdent();
|
||||
printer->Print(
|
||||
"}\n"
|
||||
"\n");
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
// protobuf_AssignDescriptorsOnce(): The first time it is called, calls
|
||||
// AssignDescriptors(). All later times, waits for the first call to
|
||||
// complete and then returns.
|
||||
printer->Print(
|
||||
"namespace {\n"
|
||||
"\n"
|
||||
"GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\n"
|
||||
"inline void protobuf_AssignDescriptorsOnce() {\n"
|
||||
" ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n"
|
||||
" &$assigndescriptorsname$);\n"
|
||||
"}\n"
|
||||
"\n",
|
||||
"assigndescriptorsname", pbcpp::GlobalAssignDescriptorsName(file_->name()));
|
||||
|
||||
// protobuf_RegisterTypes(): Calls
|
||||
// MessageFactory::InternalRegisterGeneratedType() for each message type.
|
||||
printer->Print(
|
||||
"void protobuf_RegisterTypes(const ::std::string&) {\n"
|
||||
" protobuf_AssignDescriptorsOnce();\n");
|
||||
printer->Indent();
|
||||
|
||||
for (int i = 0; i < file_->message_type_count(); i++)
|
||||
{
|
||||
message_generators_[i]->GenerateTypeRegistrations(printer);
|
||||
}
|
||||
|
||||
printer->Outdent();
|
||||
printer->Print(
|
||||
"}\n"
|
||||
"\n"
|
||||
"} // namespace\n");
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
// ShutdownFile(): Deletes descriptors, default instances, etc. on shutdown.
|
||||
printer->Print(
|
||||
"\n"
|
||||
"void $shutdownfilename$() {\n",
|
||||
"shutdownfilename", pbcpp::GlobalShutdownFileName(file_->name()));
|
||||
printer->Indent();
|
||||
|
||||
for (int i = 0; i < file_->message_type_count(); i++)
|
||||
{
|
||||
message_generators_[i]->GenerateShutdownCode(printer);
|
||||
}
|
||||
|
||||
printer->Outdent();
|
||||
printer->Print(
|
||||
"}\n\n");
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
// Now generate the AddDescriptors() function.
|
||||
pbcpp::PrintHandlingOptionalStaticInitializers(
|
||||
file_, printer,
|
||||
// With static initializers.
|
||||
// Note that we don't need any special synchronization in the following code
|
||||
// because it is called at static init time before any threads exist.
|
||||
"void $adddescriptorsname$() {\n"
|
||||
" static bool already_here = false;\n"
|
||||
" if (already_here) return;\n"
|
||||
" already_here = true;\n"
|
||||
" GOOGLE_PROTOBUF_VERIFY_VERSION;\n"
|
||||
"\n",
|
||||
// Without.
|
||||
"void $adddescriptorsname$_impl() {\n"
|
||||
" GOOGLE_PROTOBUF_VERIFY_VERSION;\n"
|
||||
"\n",
|
||||
// Vars.
|
||||
"adddescriptorsname", pbcpp::GlobalAddDescriptorsName(file_->name()));
|
||||
|
||||
printer->Indent();
|
||||
|
||||
// Call the AddDescriptors() methods for all of our dependencies, to make
|
||||
// sure they get added first.
|
||||
for (int i = 0; i < file_->dependency_count(); i++)
|
||||
{
|
||||
const pb::FileDescriptor* dependency = file_->dependency(i);
|
||||
// Print the namespace prefix for the dependency.
|
||||
std::string add_desc_name = pbcpp::QualifiedFileLevelSymbol(
|
||||
dependency->package(), pbcpp::GlobalAddDescriptorsName(dependency->name()));
|
||||
// Call its AddDescriptors function.
|
||||
printer->Print(
|
||||
"$name$();\n",
|
||||
"name", add_desc_name);
|
||||
}
|
||||
|
||||
if (pbcpp::HasDescriptorMethods(file_))
|
||||
{
|
||||
// Embed the descriptor. We simply serialize the entire FileDescriptorProto
|
||||
// and embed it as a string literal, which is parsed and built into real
|
||||
// descriptors at initialization time.
|
||||
pb::FileDescriptorProto file_proto;
|
||||
file_->CopyTo(&file_proto);
|
||||
std::string file_data;
|
||||
file_proto.SerializeToString(&file_data);
|
||||
|
||||
printer->Print(
|
||||
"::google::protobuf::DescriptorPool::InternalAddGeneratedFile(");
|
||||
|
||||
// Only write 40 bytes per line.
|
||||
static const int kBytesPerLine = 40;
|
||||
for (int i = 0; i < file_data.size(); i += kBytesPerLine)
|
||||
{
|
||||
printer->Print("\n \"$data$\"",
|
||||
"data",
|
||||
pbcpp::EscapeTrigraphs(
|
||||
pb::CEscape(file_data.substr(i, kBytesPerLine))));
|
||||
}
|
||||
printer->Print(
|
||||
", $size$);\n",
|
||||
"size", pb::SimpleItoa(file_data.size()));
|
||||
|
||||
// Call MessageFactory::InternalRegisterGeneratedFile().
|
||||
printer->Print(
|
||||
"::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(\n"
|
||||
" \"$filename$\", &protobuf_RegisterTypes);\n",
|
||||
"filename", file_->name());
|
||||
}
|
||||
|
||||
// Allocate and initialize default instances. This can't be done lazily
|
||||
// since default instances are returned by simple accessors and are used with
|
||||
// extensions. Speaking of which, we also register extensions at this time.
|
||||
for (int i = 0; i < file_->message_type_count(); i++)
|
||||
{
|
||||
message_generators_[i]->GenerateDefaultInstanceAllocator(printer);
|
||||
}
|
||||
for (int i = 0; i < file_->extension_count(); i++)
|
||||
{
|
||||
extension_generators_[i]->GenerateRegistration(printer);
|
||||
}
|
||||
for (int i = 0; i < file_->message_type_count(); i++)
|
||||
{
|
||||
message_generators_[i]->GenerateDefaultInstanceInitializer(printer);
|
||||
}
|
||||
|
||||
printer->Print(
|
||||
"::google::protobuf::internal::OnShutdown(&$shutdownfilename$);\n",
|
||||
"shutdownfilename", pbcpp::GlobalShutdownFileName(file_->name()));
|
||||
|
||||
printer->Outdent();
|
||||
printer->Print(
|
||||
"}\n"
|
||||
"\n");
|
||||
|
||||
pbcpp::PrintHandlingOptionalStaticInitializers(
|
||||
file_, printer,
|
||||
// With static initializers.
|
||||
"// Force AddDescriptors() to be called at static initialization time.\n"
|
||||
"struct StaticDescriptorInitializer_$filename$ {\n"
|
||||
" StaticDescriptorInitializer_$filename$() {\n"
|
||||
" $adddescriptorsname$();\n"
|
||||
" }\n"
|
||||
"} static_descriptor_initializer_$filename$_;\n",
|
||||
// Without.
|
||||
"GOOGLE_PROTOBUF_DECLARE_ONCE($adddescriptorsname$_once_);\n"
|
||||
"void $adddescriptorsname$() {\n"
|
||||
" ::google::protobuf::GoogleOnceInit(&$adddescriptorsname$_once_,\n"
|
||||
" &$adddescriptorsname$_impl);\n"
|
||||
"}\n",
|
||||
// Vars.
|
||||
"adddescriptorsname", pbcpp::GlobalAddDescriptorsName(file_->name()),
|
||||
"filename", pbcpp::FilenameIdentifier(file_->name()));
|
||||
}
|
||||
|
||||
void BnetFileGenerator::GenerateNamespaceOpeners(pb::io::Printer* printer)
|
||||
{
|
||||
if (package_parts_.size() > 0)
|
||||
printer->Print("\n");
|
||||
|
||||
for (int i = 0; i < package_parts_.size(); i++)
|
||||
{
|
||||
printer->Print("namespace $part$ {\n",
|
||||
"part", package_parts_[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void BnetFileGenerator::GenerateNamespaceClosers(pb::io::Printer* printer)
|
||||
{
|
||||
if (package_parts_.size() > 0)
|
||||
printer->Print("\n");
|
||||
|
||||
for (int i = package_parts_.size() - 1; i >= 0; i--)
|
||||
{
|
||||
printer->Print("} // namespace $part$\n",
|
||||
"part", package_parts_[i]);
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include "google/protobuf/compiler/cpp/cpp_field.h"
|
||||
#include "google/protobuf/compiler/cpp/cpp_options.h"
|
||||
|
||||
class BnetServiceGenerator; // service.h
|
||||
|
||||
namespace google
|
||||
{
|
||||
namespace protobuf
|
||||
{
|
||||
class FileDescriptor; // descriptor.h
|
||||
namespace io
|
||||
{
|
||||
class Printer; // printer.h
|
||||
}
|
||||
}
|
||||
|
||||
namespace protobuf
|
||||
{
|
||||
namespace compiler
|
||||
{
|
||||
namespace cpp
|
||||
{
|
||||
|
||||
class EnumGenerator; // enum.h
|
||||
class MessageGenerator; // message.h
|
||||
class ExtensionGenerator; // extension.h
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace pb = google::protobuf;
|
||||
namespace pbcpp = pb::compiler::cpp;
|
||||
|
||||
class BnetFileGenerator
|
||||
{
|
||||
public:
|
||||
// See generator.cc for the meaning of dllexport_decl.
|
||||
explicit BnetFileGenerator(const pb::FileDescriptor* file,
|
||||
const pbcpp::Options& options);
|
||||
~BnetFileGenerator();
|
||||
|
||||
void GenerateHeader(pb::io::Printer* printer);
|
||||
void GenerateSource(pb::io::Printer* printer);
|
||||
|
||||
private:
|
||||
// Generate the BuildDescriptors() procedure, which builds all descriptors
|
||||
// for types defined in the file.
|
||||
void GenerateBuildDescriptors(pb::io::Printer* printer);
|
||||
|
||||
void GenerateNamespaceOpeners(pb::io::Printer* printer);
|
||||
void GenerateNamespaceClosers(pb::io::Printer* printer);
|
||||
|
||||
const pb::FileDescriptor* file_;
|
||||
|
||||
pb::scoped_array<pb::scoped_ptr<pbcpp::MessageGenerator>> message_generators_;
|
||||
pb::scoped_array<pb::scoped_ptr<pbcpp::EnumGenerator>> enum_generators_;
|
||||
pb::scoped_array<pb::scoped_ptr<BnetServiceGenerator>> service_generators_;
|
||||
pb::scoped_array<pb::scoped_ptr<pbcpp::ExtensionGenerator>> extension_generators_;
|
||||
|
||||
// E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}.
|
||||
std::vector<std::string> package_parts_;
|
||||
const pbcpp::Options options_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(BnetFileGenerator);
|
||||
};
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__
|
||||
@@ -1,389 +0,0 @@
|
||||
//
|
||||
// Created by tea on 10.03.16.
|
||||
//
|
||||
|
||||
#include "BnetServiceGenerator.h"
|
||||
#include "method_options.pb.h"
|
||||
#include "service_options.pb.h"
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include <google/protobuf/io/printer.h>
|
||||
#include <google/protobuf/stubs/strutil.h>
|
||||
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
|
||||
#include "google/protobuf/compiler/cpp/cpp_options.h"
|
||||
|
||||
BnetServiceGenerator::BnetServiceGenerator(pb::ServiceDescriptor const* descriptor, pbcpp::Options const& options) : descriptor_(descriptor)
|
||||
{
|
||||
vars_["classname"] = descriptor_->name();
|
||||
vars_["full_name"] = descriptor_->full_name();
|
||||
if (options.dllexport_decl.empty())
|
||||
vars_["dllexport"] = "";
|
||||
else
|
||||
vars_["dllexport"] = options.dllexport_decl + " ";
|
||||
|
||||
if (descriptor_->options().HasExtension(Battlenet::service_options))
|
||||
vars_["original_hash"] = " typedef std::integral_constant<uint32, 0x" + pb::ToUpper(pb::ToHex(HashServiceName(descriptor_->options().GetExtension(Battlenet::service_options).descriptor_name()))) + "u> OriginalHash;\n";
|
||||
else
|
||||
vars_["original_hash"] = "";
|
||||
vars_["name_hash"] = " typedef std::integral_constant<uint32, 0x" + pb::ToUpper(pb::ToHex(HashServiceName(descriptor_->full_name()))) + "u> NameHash;\n";
|
||||
}
|
||||
|
||||
BnetServiceGenerator::~BnetServiceGenerator() = default;
|
||||
|
||||
void BnetServiceGenerator::GenerateDeclarations(pb::io::Printer* printer)
|
||||
{
|
||||
GenerateInterface(printer);
|
||||
}
|
||||
|
||||
void BnetServiceGenerator::GenerateInterface(pb::io::Printer* printer)
|
||||
{
|
||||
printer->Print(vars_,
|
||||
"class $dllexport$$classname$ : public ServiceBase\n"
|
||||
"{\n"
|
||||
" public:\n"
|
||||
"\n"
|
||||
" explicit $classname$(bool use_original_hash);\n"
|
||||
" $classname$($classname$ const&) = delete;\n"
|
||||
" $classname$($classname$&&) = delete;\n"
|
||||
" $classname$& operator=($classname$ const&) = delete;\n"
|
||||
" $classname$& operator=($classname$&&) = delete;\n"
|
||||
" virtual ~$classname$();\n"
|
||||
"\n"
|
||||
"$original_hash$"
|
||||
"$name_hash$");
|
||||
|
||||
printer->Indent();
|
||||
|
||||
printer->Print(vars_,
|
||||
"\n"
|
||||
"static google::protobuf::ServiceDescriptor const* descriptor();\n"
|
||||
"\n");
|
||||
|
||||
if (!descriptor_->options().HasExtension(Battlenet::sdk_service_options) || descriptor_->options().GetExtension(Battlenet::sdk_service_options).inbound())
|
||||
{
|
||||
printer->Print(vars_,
|
||||
"// client methods --------------------------------------------------\n");
|
||||
|
||||
GenerateClientMethodSignatures(printer);
|
||||
|
||||
printer->Print(vars_, "\n");
|
||||
}
|
||||
|
||||
printer->Print("void CallServerMethod(uint32 token, uint32 methodId, MessageBuffer buffer) final;\n");
|
||||
|
||||
if (!descriptor_->options().HasExtension(Battlenet::sdk_service_options) || descriptor_->options().GetExtension(Battlenet::sdk_service_options).outbound())
|
||||
{
|
||||
printer->Outdent();
|
||||
|
||||
printer->Print(
|
||||
"\n"
|
||||
" protected:\n ");
|
||||
|
||||
printer->Indent();
|
||||
|
||||
printer->Print("// server methods --------------------------------------------------\n");
|
||||
|
||||
GenerateServerMethodSignatures(printer);
|
||||
|
||||
printer->Outdent();
|
||||
|
||||
printer->Print(
|
||||
"\n"
|
||||
" private:\n");
|
||||
|
||||
printer->Indent();
|
||||
|
||||
GenerateServerMethodParserSignatures(printer);
|
||||
}
|
||||
|
||||
printer->Outdent();
|
||||
|
||||
printer->Print(vars_,
|
||||
"};\n");
|
||||
}
|
||||
|
||||
void BnetServiceGenerator::GenerateClientMethodSignatures(pb::io::Printer* printer)
|
||||
{
|
||||
for (int i = 0; i < descriptor_->method_count(); i++)
|
||||
{
|
||||
pb::MethodDescriptor const* method = descriptor_->method(i);
|
||||
if (!method->options().HasExtension(Battlenet::method_options))
|
||||
continue;
|
||||
|
||||
std::map<std::string, std::string> sub_vars;
|
||||
sub_vars["name"] = method->name();
|
||||
sub_vars["full_name"] = descriptor_->name() + "." + method->name();
|
||||
sub_vars["method_id"] = pb::SimpleItoa(method->options().GetExtension(Battlenet::method_options).id());
|
||||
sub_vars["input_type"] = pbcpp::ClassName(method->input_type(), true);
|
||||
sub_vars["output_type"] = pbcpp::ClassName(method->output_type(), true);
|
||||
sub_vars["input_type_name"] = method->input_type()->full_name();
|
||||
|
||||
if (method->output_type()->name() != "NO_RESPONSE")
|
||||
printer->Print(sub_vars, "void $name$($input_type$ const* request, std::function<void($output_type$ const*)> responseCallback, bool client = false, bool server = false);\n");
|
||||
else
|
||||
printer->Print(sub_vars, "void $name$($input_type$ const* request, bool client = false, bool server = false);\n");
|
||||
}
|
||||
}
|
||||
|
||||
void BnetServiceGenerator::GenerateServerMethodSignatures(pb::io::Printer* printer)
|
||||
{
|
||||
for (int i = 0; i < descriptor_->method_count(); i++)
|
||||
{
|
||||
pb::MethodDescriptor const* method = descriptor_->method(i);
|
||||
if (!method->options().HasExtension(Battlenet::method_options))
|
||||
continue;
|
||||
|
||||
std::map<std::string, std::string> sub_vars;
|
||||
sub_vars["name"] = method->name();
|
||||
sub_vars["input_type"] = pbcpp::ClassName(method->input_type(), true);
|
||||
sub_vars["output_type"] = pbcpp::ClassName(method->output_type(), true);
|
||||
|
||||
if (method->output_type()->name() != "NO_RESPONSE")
|
||||
printer->Print(sub_vars, "virtual uint32 Handle$name$($input_type$ const* request, $output_type$* response, std::function<void(ServiceBase*, uint32, ::google::protobuf::Message const*)>& continuation);\n");
|
||||
else
|
||||
printer->Print(sub_vars, "virtual uint32 Handle$name$($input_type$ const* request);\n");
|
||||
}
|
||||
}
|
||||
|
||||
void BnetServiceGenerator::GenerateServerMethodParserSignatures(pb::io::Printer* printer)
|
||||
{
|
||||
for (int i = 0; i < descriptor_->method_count(); i++)
|
||||
{
|
||||
pb::MethodDescriptor const* method = descriptor_->method(i);
|
||||
if (!method->options().HasExtension(Battlenet::method_options))
|
||||
continue;
|
||||
|
||||
std::map<std::string, std::string> sub_vars;
|
||||
sub_vars["name"] = method->name();
|
||||
sub_vars["input_type"] = pbcpp::ClassName(method->input_type(), true);
|
||||
sub_vars["output_type"] = pbcpp::ClassName(method->output_type(), true);
|
||||
|
||||
printer->Print(sub_vars, "void ParseAndHandle$name$(uint32 token, uint32 methodId, MessageBuffer& buffer);\n");
|
||||
}
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
void BnetServiceGenerator::GenerateDescriptorInitializer(pb::io::Printer* printer, int index)
|
||||
{
|
||||
std::map<std::string, std::string> vars;
|
||||
vars["classname"] = descriptor_->name();
|
||||
vars["index"] = pb::SimpleItoa(index);
|
||||
|
||||
printer->Print(vars, "$classname$_descriptor_ = file->service($index$);\n");
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
void BnetServiceGenerator::GenerateImplementation(pb::io::Printer* printer)
|
||||
{
|
||||
printer->Print(vars_,
|
||||
"$classname$::$classname$(bool use_original_hash) : ServiceBase(use_original_hash ? OriginalHash::value : NameHash::value) {\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"$classname$::~$classname$() {\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"google::protobuf::ServiceDescriptor const* $classname$::descriptor() {\n"
|
||||
" protobuf_AssignDescriptorsOnce();\n"
|
||||
" return $classname$_descriptor_;\n"
|
||||
"}\n"
|
||||
"\n");
|
||||
|
||||
if (!descriptor_->options().HasExtension(Battlenet::sdk_service_options) || descriptor_->options().GetExtension(Battlenet::sdk_service_options).inbound())
|
||||
GenerateClientMethodImplementations(printer);
|
||||
|
||||
if (!descriptor_->options().HasExtension(Battlenet::sdk_service_options) || descriptor_->options().GetExtension(Battlenet::sdk_service_options).outbound())
|
||||
{
|
||||
GenerateServerCallMethod(printer);
|
||||
GenerateServerImplementations(printer);
|
||||
GenerateServerMethodParserImplementations(printer);
|
||||
}
|
||||
else
|
||||
{
|
||||
printer->Print(vars_,
|
||||
"void $classname$::CallServerMethod(uint32 /*token*/, uint32 methodId, MessageBuffer /*buffer*/) {\n"
|
||||
" LogDisallowedMethod(methodId);\n"
|
||||
"}\n"
|
||||
"\n");
|
||||
}
|
||||
}
|
||||
|
||||
void BnetServiceGenerator::GenerateClientMethodImplementations(pb::io::Printer* printer)
|
||||
{
|
||||
for (int i = 0; i < descriptor_->method_count(); i++)
|
||||
{
|
||||
pb::MethodDescriptor const* method = descriptor_->method(i);
|
||||
if (!method->options().HasExtension(Battlenet::method_options))
|
||||
continue;
|
||||
|
||||
std::map<std::string, std::string> sub_vars;
|
||||
sub_vars["classname"] = vars_["classname"];
|
||||
sub_vars["name"] = method->name();
|
||||
sub_vars["full_name"] = descriptor_->name() + "." + method->name();
|
||||
sub_vars["method_id"] = pb::SimpleItoa(method->options().GetExtension(Battlenet::method_options).id());
|
||||
sub_vars["input_type"] = pbcpp::ClassName(method->input_type(), true);
|
||||
sub_vars["output_type"] = pbcpp::ClassName(method->output_type(), true);
|
||||
sub_vars["input_type_name"] = method->input_type()->full_name();
|
||||
|
||||
if (method->output_type()->name() != "NO_RESPONSE")
|
||||
{
|
||||
printer->Print(sub_vars,
|
||||
"void $classname$::$name$($input_type$ const* request, std::function<void($output_type$ const*)> responseCallback, bool client /*= false*/, bool server /*= false*/) {\n"
|
||||
" LogCallClientMethod(\"$full_name$\", \"$input_type_name$\", request);\n"
|
||||
" std::function<void(MessageBuffer)> callback = [responseCallback](MessageBuffer buffer) -> void {\n"
|
||||
" $output_type$ response;\n"
|
||||
" if (response.ParseFromArray(buffer.GetReadPointer(), buffer.GetActiveSize()))\n"
|
||||
" responseCallback(&response);\n"
|
||||
" };\n"
|
||||
" SendRequest(service_hash_, $method_id$ | (client ? 0x40000000 : 0) | (server ? 0x80000000 : 0), request, std::move(callback));\n"
|
||||
"}\n"
|
||||
"\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printer->Print(sub_vars,
|
||||
"void $classname$::$name$($input_type$ const* request, bool client /*= false*/, bool server /*= false*/) {\n"
|
||||
" LogCallClientMethod(\"$full_name$\", \"$input_type_name$\", request);\n"
|
||||
" SendRequest(service_hash_, $method_id$ | (client ? 0x40000000 : 0) | (server ? 0x80000000 : 0), request);\n"
|
||||
"}\n"
|
||||
"\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BnetServiceGenerator::GenerateServerCallMethod(pb::io::Printer* printer)
|
||||
{
|
||||
printer->Print(vars_,
|
||||
"void $classname$::CallServerMethod(uint32 token, uint32 methodId, MessageBuffer buffer) {\n"
|
||||
" switch(methodId & 0x3FFFFFFF) {\n");
|
||||
|
||||
for (int i = 0; i < descriptor_->method_count(); i++)
|
||||
{
|
||||
pb::MethodDescriptor const* method = descriptor_->method(i);
|
||||
if (!method->options().HasExtension(Battlenet::method_options))
|
||||
continue;
|
||||
|
||||
std::map<std::string, std::string> sub_vars;
|
||||
sub_vars["classname"] = vars_["classname"];
|
||||
sub_vars["name"] = method->name();
|
||||
sub_vars["full_name"] = descriptor_->name() + "." + method->name();
|
||||
sub_vars["method_id"] = pb::SimpleItoa(method->options().GetExtension(Battlenet::method_options).id());
|
||||
sub_vars["input_type"] = pbcpp::ClassName(method->input_type(), true);
|
||||
sub_vars["output_type"] = pbcpp::ClassName(method->output_type(), true);
|
||||
sub_vars["input_type_name"] = method->input_type()->full_name();
|
||||
sub_vars["output_type_name"] = method->output_type()->full_name();
|
||||
|
||||
printer->Print(sub_vars,
|
||||
" case $method_id$:\n"
|
||||
" ParseAndHandle$name$(token, methodId, buffer);\n"
|
||||
" break;\n");
|
||||
}
|
||||
|
||||
printer->Print(vars_,
|
||||
" default:\n"
|
||||
" LogInvalidMethod(methodId);\n"
|
||||
" SendResponse(service_hash_, methodId, token, ERROR_RPC_INVALID_METHOD);\n"
|
||||
" break;\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n");
|
||||
}
|
||||
|
||||
void BnetServiceGenerator::GenerateServerImplementations(pb::io::Printer* printer)
|
||||
{
|
||||
for (int i = 0; i < descriptor_->method_count(); i++)
|
||||
{
|
||||
pb::MethodDescriptor const* method = descriptor_->method(i);
|
||||
if (!method->options().HasExtension(Battlenet::method_options))
|
||||
continue;
|
||||
|
||||
std::map<std::string, std::string> sub_vars;
|
||||
sub_vars["classname"] = vars_["classname"];
|
||||
sub_vars["name"] = method->name();
|
||||
sub_vars["full_name"] = descriptor_->name() + "." + method->name();
|
||||
sub_vars["input_type"] = pbcpp::ClassName(method->input_type(), true);
|
||||
sub_vars["output_type"] = pbcpp::ClassName(method->output_type(), true);
|
||||
|
||||
if (method->output_type()->name() != "NO_RESPONSE")
|
||||
{
|
||||
printer->Print(sub_vars, "uint32 $classname$::Handle$name$($input_type$ const* request, $output_type$* /*response*/, std::function<void(ServiceBase*, uint32, ::google::protobuf::Message const*)>& /*continuation*/) {\n"
|
||||
" LogUnimplementedServerMethod(\"$full_name$\", request);\n"
|
||||
" return ERROR_RPC_NOT_IMPLEMENTED;\n"
|
||||
"}\n"
|
||||
"\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printer->Print(sub_vars, "uint32 $classname$::Handle$name$($input_type$ const* request) {\n"
|
||||
" LogUnimplementedServerMethod(\"$full_name$\", request);\n"
|
||||
" return ERROR_RPC_NOT_IMPLEMENTED;\n"
|
||||
"}\n"
|
||||
"\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BnetServiceGenerator::GenerateServerMethodParserImplementations(pb::io::Printer* printer)
|
||||
{
|
||||
for (int i = 0; i < descriptor_->method_count(); i++)
|
||||
{
|
||||
pb::MethodDescriptor const* method = descriptor_->method(i);
|
||||
if (!method->options().HasExtension(Battlenet::method_options))
|
||||
continue;
|
||||
|
||||
std::map<std::string, std::string> sub_vars;
|
||||
sub_vars["classname"] = vars_["classname"];
|
||||
sub_vars["name"] = method->name();
|
||||
sub_vars["full_name"] = descriptor_->name() + "." + method->name();
|
||||
sub_vars["input_type"] = pbcpp::ClassName(method->input_type(), true);
|
||||
sub_vars["output_type"] = pbcpp::ClassName(method->output_type(), true);
|
||||
sub_vars["input_type_name"] = method->input_type()->full_name();
|
||||
sub_vars["output_type_name"] = method->output_type()->full_name();
|
||||
|
||||
printer->Print(sub_vars,
|
||||
"void $classname$::ParseAndHandle$name$(uint32 token, uint32 methodId, MessageBuffer& buffer) {\n"
|
||||
" $input_type$ request;\n"
|
||||
" if (!request.ParseFromArray(buffer.GetReadPointer(), buffer.GetActiveSize())) {\n"
|
||||
" LogFailedParsingRequest(\"$full_name$\");\n"
|
||||
" SendResponse(service_hash_, methodId, token, ERROR_RPC_MALFORMED_REQUEST);\n"
|
||||
" return;\n"
|
||||
" }\n"
|
||||
);
|
||||
|
||||
if (method->output_type()->name() != "NO_RESPONSE")
|
||||
{
|
||||
printer->Print(sub_vars,
|
||||
" LogCallServerMethod(\"$full_name$\", \"$input_type_name$\", &request);\n"
|
||||
" std::function<void(ServiceBase*, uint32, ::google::protobuf::Message const*)> continuation = CreateServerContinuation(token, methodId, \"$full_name$\", $output_type$::descriptor());\n"
|
||||
" $output_type$ response;\n"
|
||||
" uint32 status = Handle$name$(&request, &response, continuation);\n"
|
||||
" if (continuation)\n"
|
||||
" continuation(this, status, &response);\n"
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
printer->Print(sub_vars,
|
||||
" uint32 status = Handle$name$(&request);\n"
|
||||
" LogCallServerMethod(\"$full_name$\", \"$input_type_name$\", &request);\n"
|
||||
" if (status)\n"
|
||||
" SendResponse(service_hash_, methodId, token, status);\n");
|
||||
}
|
||||
|
||||
printer->Print(sub_vars,
|
||||
"}\n"
|
||||
"\n");
|
||||
}
|
||||
}
|
||||
|
||||
std::uint32_t BnetServiceGenerator::HashServiceName(std::string const& name)
|
||||
{
|
||||
std::uint32_t hash = 0x811C9DC5;
|
||||
for (std::size_t i = 0; i < name.length(); ++i)
|
||||
{
|
||||
hash ^= name[i];
|
||||
hash *= 0x1000193;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
//
|
||||
// Created by tea on 10.03.16.
|
||||
//
|
||||
|
||||
#ifndef PROTOC_BNET_BNETSERVICEGENERATOR_H
|
||||
#define PROTOC_BNET_BNETSERVICEGENERATOR_H
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace google
|
||||
{
|
||||
namespace protobuf
|
||||
{
|
||||
class ServiceDescriptor;
|
||||
|
||||
namespace io
|
||||
{
|
||||
class Printer;
|
||||
}
|
||||
|
||||
namespace compiler
|
||||
{
|
||||
namespace cpp
|
||||
{
|
||||
struct Options;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace pb = google::protobuf;
|
||||
namespace pbcpp = pb::compiler::cpp;
|
||||
|
||||
class BnetServiceGenerator
|
||||
{
|
||||
public:
|
||||
// See generator.cc for the meaning of dllexport_decl.
|
||||
BnetServiceGenerator(const pb::ServiceDescriptor* descriptor,
|
||||
const pbcpp::Options& options);
|
||||
~BnetServiceGenerator();
|
||||
|
||||
// Header stuff.
|
||||
|
||||
// Generate the class definitions for the service's interface and the
|
||||
// stub implementation.
|
||||
void GenerateDeclarations(pb::io::Printer* printer);
|
||||
|
||||
// Source file stuff.
|
||||
|
||||
// Generate code that initializes the global variable storing the service's
|
||||
// descriptor.
|
||||
void GenerateDescriptorInitializer(pb::io::Printer* printer, int index);
|
||||
|
||||
// Generate implementations of everything declared by GenerateDeclarations().
|
||||
void GenerateImplementation(pb::io::Printer* printer);
|
||||
|
||||
private:
|
||||
// Header stuff.
|
||||
|
||||
// Generate the service abstract interface.
|
||||
void GenerateInterface(pb::io::Printer* printer);
|
||||
|
||||
// Prints signatures for all methods in the
|
||||
void GenerateClientMethodSignatures(pb::io::Printer* printer);
|
||||
void GenerateServerMethodSignatures(pb::io::Printer* printer);
|
||||
void GenerateServerMethodParserSignatures(pb::io::Printer* printer);
|
||||
|
||||
// Source file stuff.
|
||||
|
||||
void GenerateClientMethodImplementations(pb::io::Printer* printer);
|
||||
|
||||
// Generate the CallMethod() method of the service.
|
||||
void GenerateServerCallMethod(pb::io::Printer* printer);
|
||||
void GenerateServerImplementations(pb::io::Printer* printer);
|
||||
void GenerateServerMethodParserImplementations(pb::io::Printer* printer);
|
||||
|
||||
std::uint32_t HashServiceName(std::string const& name);
|
||||
|
||||
const pb::ServiceDescriptor* descriptor_;
|
||||
std::map<std::string, std::string> vars_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(BnetServiceGenerator);
|
||||
};
|
||||
|
||||
#endif //PROTOC_BNET_BNETSERVICEGENERATOR_H
|
||||
@@ -1,30 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
project(protoc_bnet)
|
||||
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
find_package(Protobuf REQUIRED)
|
||||
|
||||
file(GLOB_RECURSE SOURCE_PROTOBUF_CPP google/protobuf/*.cc)
|
||||
|
||||
set(SOURCE_FILES
|
||||
main.cpp
|
||||
BnetCodeGenerator.cpp
|
||||
BnetFileGenerator.cpp
|
||||
BnetServiceGenerator.cpp
|
||||
method_options.pb.cc
|
||||
service_options.pb.cc
|
||||
${SOURCE_PROTOBUF_CPP})
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR} ${PROTOBUF_INCLUDE_DIRS})
|
||||
|
||||
add_executable(protoc-gen-bnet ${SOURCE_FILES})
|
||||
target_compile_features(protoc-gen-bnet
|
||||
PUBLIC
|
||||
cxx_std_17)
|
||||
|
||||
target_link_libraries(protoc-gen-bnet ${PROTOBUF_PROTOC_LIBRARIES} ${PROTOBUF_LIBRARIES})
|
||||
|
||||
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR})
|
||||
|
||||
install(TARGETS protoc-gen-bnet DESTINATION bin)
|
||||
@@ -1,31 +0,0 @@
|
||||
/* protobuf config.h for MSVC. On other platforms, this is generated
|
||||
* automatically by autoheader / autoconf / configure. */
|
||||
|
||||
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
|
||||
|
||||
/* the location of <hash_map> */
|
||||
#define HASH_MAP_H <hash_map>
|
||||
|
||||
/* the namespace of hash_map/hash_set */
|
||||
// Apparently Microsoft decided to move hash_map *back* to the std namespace
|
||||
// in MSVC 2010:
|
||||
// http://blogs.msdn.com/vcblog/archive/2009/05/25/stl-breaking-changes-in-visual-studio-2010-beta-1.aspx
|
||||
// TODO(kenton): Use unordered_map instead, which is available in MSVC 2010.
|
||||
#if _MSC_VER < 1310 || _MSC_VER >= 1600
|
||||
#define HASH_NAMESPACE std
|
||||
#else
|
||||
#define HASH_NAMESPACE stdext
|
||||
#endif
|
||||
|
||||
/* the location of <hash_set> */
|
||||
#define HASH_SET_H <hash_set>
|
||||
|
||||
/* define if the compiler has hash_map */
|
||||
#define HAVE_HASH_MAP 1
|
||||
|
||||
/* define if the compiler has hash_set */
|
||||
#define HAVE_HASH_SET 1
|
||||
|
||||
/* define if you want to use zlib. See readme.txt for additional
|
||||
* requirements. */
|
||||
// #define HAVE_ZLIB 1
|
||||
@@ -1,6 +0,0 @@
|
||||
FOR %%P IN (proto\global_extensions\*.proto) DO (
|
||||
protoc.exe --plugin=protoc-gen-bnet=protoc-gen-bnet.exe --bnet_out=dllexport_decl=TC_PROTO_API:buildproto -Iproto %%P
|
||||
)
|
||||
FOR %%P IN (proto\*.proto) DO (
|
||||
protoc.exe --plugin=protoc-gen-bnet=protoc-gen-bnet.exe --bnet_out=dllexport_decl=TC_PROTO_API:buildproto -Iproto %%P
|
||||
)
|
||||
@@ -1,288 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
#include "google/protobuf/compiler/cpp/cpp_enum.h"
|
||||
#include "google/protobuf/compiler/cpp/cpp_helpers.h"
|
||||
#include <google/protobuf/io/printer.h>
|
||||
#include "google/protobuf/stubs/strutil.h"
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
namespace {
|
||||
// The GOOGLE_ARRAYSIZE constant is the max enum value plus 1. If the max enum value
|
||||
// is kint32max, GOOGLE_ARRAYSIZE will overflow. In such cases we should omit the
|
||||
// generation of the GOOGLE_ARRAYSIZE constant.
|
||||
bool ShouldGenerateArraySize(const EnumDescriptor* descriptor) {
|
||||
int32 max_value = descriptor->value(0)->number();
|
||||
for (int i = 0; i < descriptor->value_count(); i++) {
|
||||
if (descriptor->value(i)->number() > max_value) {
|
||||
max_value = descriptor->value(i)->number();
|
||||
}
|
||||
}
|
||||
return max_value != kint32max;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor,
|
||||
const Options& options)
|
||||
: descriptor_(descriptor),
|
||||
classname_(ClassName(descriptor, false)),
|
||||
options_(options),
|
||||
generate_array_size_(ShouldGenerateArraySize(descriptor)) {
|
||||
}
|
||||
|
||||
EnumGenerator::~EnumGenerator() {}
|
||||
|
||||
void EnumGenerator::GenerateDefinition(io::Printer* printer) {
|
||||
map<string, string> vars;
|
||||
vars["classname"] = classname_;
|
||||
vars["short_name"] = descriptor_->name();
|
||||
|
||||
printer->Print(vars, "enum $classname$ {\n");
|
||||
printer->Indent();
|
||||
|
||||
const EnumValueDescriptor* min_value = descriptor_->value(0);
|
||||
const EnumValueDescriptor* max_value = descriptor_->value(0);
|
||||
|
||||
for (int i = 0; i < descriptor_->value_count(); i++) {
|
||||
vars["name"] = descriptor_->value(i)->name();
|
||||
// In C++, an value of -2147483648 gets interpreted as the negative of
|
||||
// 2147483648, and since 2147483648 can't fit in an integer, this produces a
|
||||
// compiler warning. This works around that issue.
|
||||
vars["number"] = Int32ToString(descriptor_->value(i)->number());
|
||||
vars["prefix"] = (descriptor_->containing_type() == NULL) ?
|
||||
"" : classname_ + "_";
|
||||
|
||||
if (i > 0) printer->Print(",\n");
|
||||
printer->Print(vars, "$prefix$$name$ = $number$");
|
||||
|
||||
if (descriptor_->value(i)->number() < min_value->number()) {
|
||||
min_value = descriptor_->value(i);
|
||||
}
|
||||
if (descriptor_->value(i)->number() > max_value->number()) {
|
||||
max_value = descriptor_->value(i);
|
||||
}
|
||||
}
|
||||
|
||||
printer->Outdent();
|
||||
printer->Print("\n};\n");
|
||||
|
||||
vars["min_name"] = min_value->name();
|
||||
vars["max_name"] = max_value->name();
|
||||
|
||||
if (options_.dllexport_decl.empty()) {
|
||||
vars["dllexport"] = "";
|
||||
} else {
|
||||
vars["dllexport"] = options_.dllexport_decl + " ";
|
||||
}
|
||||
|
||||
printer->Print(vars,
|
||||
"$dllexport$bool $classname$_IsValid(int value);\n"
|
||||
"const $classname$ $prefix$$short_name$_MIN = $prefix$$min_name$;\n"
|
||||
"const $classname$ $prefix$$short_name$_MAX = $prefix$$max_name$;\n");
|
||||
|
||||
if (generate_array_size_) {
|
||||
printer->Print(vars,
|
||||
"const int $prefix$$short_name$_ARRAYSIZE = "
|
||||
"$prefix$$short_name$_MAX + 1;\n\n");
|
||||
}
|
||||
|
||||
if (HasDescriptorMethods(descriptor_->file())) {
|
||||
printer->Print(vars,
|
||||
"$dllexport$const ::google::protobuf::EnumDescriptor* $classname$_descriptor();\n");
|
||||
// The _Name and _Parse methods
|
||||
printer->Print(vars,
|
||||
"inline const ::std::string& $classname$_Name($classname$ value) {\n"
|
||||
" return ::google::protobuf::internal::NameOfEnum(\n"
|
||||
" $classname$_descriptor(), value);\n"
|
||||
"}\n");
|
||||
printer->Print(vars,
|
||||
"inline bool $classname$_Parse(\n"
|
||||
" const ::std::string& name, $classname$* value) {\n"
|
||||
" return ::google::protobuf::internal::ParseNamedEnum<$classname$>(\n"
|
||||
" $classname$_descriptor(), name, value);\n"
|
||||
"}\n");
|
||||
}
|
||||
}
|
||||
|
||||
void EnumGenerator::
|
||||
GenerateGetEnumDescriptorSpecializations(io::Printer* printer) {
|
||||
if (HasDescriptorMethods(descriptor_->file())) {
|
||||
printer->Print(
|
||||
"template <> struct is_proto_enum< $classname$> : ::google::protobuf::internal::true_type {};\n"
|
||||
"template <>\n"
|
||||
"inline const EnumDescriptor* GetEnumDescriptor< $classname$>() {\n"
|
||||
" return $classname$_descriptor();\n"
|
||||
"}\n",
|
||||
"classname", ClassName(descriptor_, true));
|
||||
}
|
||||
}
|
||||
|
||||
void EnumGenerator::GenerateSymbolImports(io::Printer* printer) {
|
||||
map<string, string> vars;
|
||||
vars["nested_name"] = descriptor_->name();
|
||||
vars["classname"] = classname_;
|
||||
printer->Print(vars, "typedef $classname$ $nested_name$;\n");
|
||||
|
||||
for (int j = 0; j < descriptor_->value_count(); j++) {
|
||||
vars["tag"] = descriptor_->value(j)->name();
|
||||
printer->Print(vars,
|
||||
"static const $nested_name$ $tag$ = $classname$_$tag$;\n");
|
||||
}
|
||||
|
||||
printer->Print(vars,
|
||||
"static inline bool $nested_name$_IsValid(int value) {\n"
|
||||
" return $classname$_IsValid(value);\n"
|
||||
"}\n"
|
||||
"static const $nested_name$ $nested_name$_MIN =\n"
|
||||
" $classname$_$nested_name$_MIN;\n"
|
||||
"static const $nested_name$ $nested_name$_MAX =\n"
|
||||
" $classname$_$nested_name$_MAX;\n");
|
||||
if (generate_array_size_) {
|
||||
printer->Print(vars,
|
||||
"static const int $nested_name$_ARRAYSIZE =\n"
|
||||
" $classname$_$nested_name$_ARRAYSIZE;\n");
|
||||
}
|
||||
|
||||
if (HasDescriptorMethods(descriptor_->file())) {
|
||||
printer->Print(vars,
|
||||
"static inline const ::google::protobuf::EnumDescriptor*\n"
|
||||
"$nested_name$_descriptor() {\n"
|
||||
" return $classname$_descriptor();\n"
|
||||
"}\n");
|
||||
printer->Print(vars,
|
||||
"static inline const ::std::string& $nested_name$_Name($nested_name$ value) {\n"
|
||||
" return $classname$_Name(value);\n"
|
||||
"}\n");
|
||||
printer->Print(vars,
|
||||
"static inline bool $nested_name$_Parse(const ::std::string& name,\n"
|
||||
" $nested_name$* value) {\n"
|
||||
" return $classname$_Parse(name, value);\n"
|
||||
"}\n");
|
||||
}
|
||||
}
|
||||
|
||||
void EnumGenerator::GenerateDescriptorInitializer(
|
||||
io::Printer* printer, int index) {
|
||||
map<string, string> vars;
|
||||
vars["classname"] = classname_;
|
||||
vars["index"] = SimpleItoa(index);
|
||||
|
||||
if (descriptor_->containing_type() == NULL) {
|
||||
printer->Print(vars,
|
||||
"$classname$_descriptor_ = file->enum_type($index$);\n");
|
||||
} else {
|
||||
vars["parent"] = ClassName(descriptor_->containing_type(), false);
|
||||
printer->Print(vars,
|
||||
"$classname$_descriptor_ = $parent$_descriptor_->enum_type($index$);\n");
|
||||
}
|
||||
}
|
||||
|
||||
void EnumGenerator::GenerateMethods(io::Printer* printer) {
|
||||
map<string, string> vars;
|
||||
vars["classname"] = classname_;
|
||||
|
||||
if (HasDescriptorMethods(descriptor_->file())) {
|
||||
printer->Print(vars,
|
||||
"const ::google::protobuf::EnumDescriptor* $classname$_descriptor() {\n"
|
||||
" protobuf_AssignDescriptorsOnce();\n"
|
||||
" return $classname$_descriptor_;\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
printer->Print(vars,
|
||||
"bool $classname$_IsValid(int value) {\n"
|
||||
" switch(value) {\n");
|
||||
|
||||
// Multiple values may have the same number. Make sure we only cover
|
||||
// each number once by first constructing a set containing all valid
|
||||
// numbers, then printing a case statement for each element.
|
||||
|
||||
set<int> numbers;
|
||||
for (int j = 0; j < descriptor_->value_count(); j++) {
|
||||
const EnumValueDescriptor* value = descriptor_->value(j);
|
||||
numbers.insert(value->number());
|
||||
}
|
||||
|
||||
for (set<int>::iterator iter = numbers.begin();
|
||||
iter != numbers.end(); ++iter) {
|
||||
printer->Print(
|
||||
" case $number$:\n",
|
||||
"number", Int32ToString(*iter));
|
||||
}
|
||||
|
||||
printer->Print(vars,
|
||||
" return true;\n"
|
||||
" default:\n"
|
||||
" return false;\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n");
|
||||
|
||||
if (descriptor_->containing_type() != NULL) {
|
||||
// We need to "define" the static constants which were declared in the
|
||||
// header, to give the linker a place to put them. Or at least the C++
|
||||
// standard says we have to. MSVC actually insists tha we do _not_ define
|
||||
// them again in the .cc file.
|
||||
printer->Print("#ifndef _MSC_VER\n");
|
||||
|
||||
vars["parent"] = ClassName(descriptor_->containing_type(), false);
|
||||
vars["nested_name"] = descriptor_->name();
|
||||
for (int i = 0; i < descriptor_->value_count(); i++) {
|
||||
vars["value"] = descriptor_->value(i)->name();
|
||||
printer->Print(vars,
|
||||
"const $classname$ $parent$::$value$;\n");
|
||||
}
|
||||
printer->Print(vars,
|
||||
"const $classname$ $parent$::$nested_name$_MIN;\n"
|
||||
"const $classname$ $parent$::$nested_name$_MAX;\n");
|
||||
if (generate_array_size_) {
|
||||
printer->Print(vars,
|
||||
"const int $parent$::$nested_name$_ARRAYSIZE;\n");
|
||||
}
|
||||
|
||||
printer->Print("#endif // _MSC_VER\n");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
@@ -1,103 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__
|
||||
|
||||
#include <string>
|
||||
#include "google/protobuf/compiler/cpp/cpp_options.h"
|
||||
#include <google/protobuf/descriptor.h>
|
||||
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace io {
|
||||
class Printer; // printer.h
|
||||
}
|
||||
}
|
||||
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
class EnumGenerator {
|
||||
public:
|
||||
// See generator.cc for the meaning of dllexport_decl.
|
||||
explicit EnumGenerator(const EnumDescriptor* descriptor,
|
||||
const Options& options);
|
||||
~EnumGenerator();
|
||||
|
||||
// Header stuff.
|
||||
|
||||
// Generate header code defining the enum. This code should be placed
|
||||
// within the enum's package namespace, but NOT within any class, even for
|
||||
// nested enums.
|
||||
void GenerateDefinition(io::Printer* printer);
|
||||
|
||||
// Generate specialization of GetEnumDescriptor<MyEnum>().
|
||||
// Precondition: in ::google::protobuf namespace.
|
||||
void GenerateGetEnumDescriptorSpecializations(io::Printer* printer);
|
||||
|
||||
// For enums nested within a message, generate code to import all the enum's
|
||||
// symbols (e.g. the enum type name, all its values, etc.) into the class's
|
||||
// namespace. This should be placed inside the class definition in the
|
||||
// header.
|
||||
void GenerateSymbolImports(io::Printer* printer);
|
||||
|
||||
// Source file stuff.
|
||||
|
||||
// Generate code that initializes the global variable storing the enum's
|
||||
// descriptor.
|
||||
void GenerateDescriptorInitializer(io::Printer* printer, int index);
|
||||
|
||||
// Generate non-inline methods related to the enum, such as IsValidValue().
|
||||
// Goes in the .cc file.
|
||||
void GenerateMethods(io::Printer* printer);
|
||||
|
||||
private:
|
||||
const EnumDescriptor* descriptor_;
|
||||
string classname_;
|
||||
Options options_;
|
||||
// whether to generate the *_ARRAYSIZE constant.
|
||||
bool generate_array_size_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator);
|
||||
};
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__
|
||||
@@ -1,434 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#include "google/protobuf/compiler/cpp/cpp_enum_field.h"
|
||||
#include "google/protobuf/compiler/cpp/cpp_helpers.h"
|
||||
#include <google/protobuf/io/printer.h>
|
||||
#include <google/protobuf/descriptor.pb.h>
|
||||
#include "google/protobuf/stubs/strutil.h"
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
namespace {
|
||||
|
||||
void SetEnumVariables(const FieldDescriptor* descriptor,
|
||||
map<string, string>* variables,
|
||||
const Options& options) {
|
||||
SetCommonFieldVariables(descriptor, variables, options);
|
||||
const EnumValueDescriptor* default_value = descriptor->default_value_enum();
|
||||
(*variables)["type"] = ClassName(descriptor->enum_type(), true);
|
||||
(*variables)["default"] = Int32ToString(default_value->number());
|
||||
(*variables)["full_name"] = descriptor->full_name();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// ===================================================================
|
||||
|
||||
EnumFieldGenerator::
|
||||
EnumFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options)
|
||||
: descriptor_(descriptor) {
|
||||
SetEnumVariables(descriptor, &variables_, options);
|
||||
}
|
||||
|
||||
EnumFieldGenerator::~EnumFieldGenerator() {}
|
||||
|
||||
void EnumFieldGenerator::
|
||||
GeneratePrivateMembers(io::Printer* printer) const {
|
||||
printer->Print(variables_, "int $name$_;\n");
|
||||
}
|
||||
|
||||
void EnumFieldGenerator::
|
||||
GenerateAccessorDeclarations(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline $type$ $name$() const$deprecation$;\n"
|
||||
"inline void set_$name$($type$ value)$deprecation$;\n");
|
||||
}
|
||||
|
||||
void EnumFieldGenerator::
|
||||
GenerateInlineAccessorDefinitions(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline $type$ $classname$::$name$() const {\n"
|
||||
" // @@protoc_insertion_point(field_get:$full_name$)\n"
|
||||
" return static_cast< $type$ >($name$_);\n"
|
||||
"}\n"
|
||||
"inline void $classname$::set_$name$($type$ value) {\n"
|
||||
" assert($type$_IsValid(value));\n"
|
||||
" set_has_$name$();\n"
|
||||
" $name$_ = value;\n"
|
||||
" // @@protoc_insertion_point(field_set:$full_name$)\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void EnumFieldGenerator::
|
||||
GenerateClearingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$name$_ = $default$;\n");
|
||||
}
|
||||
|
||||
void EnumFieldGenerator::
|
||||
GenerateMergingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "set_$name$(from.$name$());\n");
|
||||
}
|
||||
|
||||
void EnumFieldGenerator::
|
||||
GenerateSwappingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "std::swap($name$_, other->$name$_);\n");
|
||||
}
|
||||
|
||||
void EnumFieldGenerator::
|
||||
GenerateConstructorCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$name$_ = $default$;\n");
|
||||
}
|
||||
|
||||
void EnumFieldGenerator::
|
||||
GenerateMergeFromCodedStream(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"int value;\n"
|
||||
"DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n"
|
||||
" int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n"
|
||||
" input, &value)));\n"
|
||||
"if ($type$_IsValid(value)) {\n"
|
||||
" set_$name$(static_cast< $type$ >(value));\n");
|
||||
if (UseUnknownFieldSet(descriptor_->file())) {
|
||||
printer->Print(variables_,
|
||||
"} else {\n"
|
||||
" mutable_unknown_fields()->AddVarint($number$, value);\n");
|
||||
} else {
|
||||
printer->Print(
|
||||
"} else {\n"
|
||||
" unknown_fields_stream.WriteVarint32(tag);\n"
|
||||
" unknown_fields_stream.WriteVarint32(value);\n");
|
||||
}
|
||||
printer->Print(variables_,
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void EnumFieldGenerator::
|
||||
GenerateSerializeWithCachedSizes(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"::google::protobuf::internal::WireFormatLite::WriteEnum(\n"
|
||||
" $number$, this->$name$(), output);\n");
|
||||
}
|
||||
|
||||
void EnumFieldGenerator::
|
||||
GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n"
|
||||
" $number$, this->$name$(), target);\n");
|
||||
}
|
||||
|
||||
void EnumFieldGenerator::
|
||||
GenerateByteSize(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"total_size += $tag_size$ +\n"
|
||||
" ::google::protobuf::internal::WireFormatLite::EnumSize(this->$name$());\n");
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
EnumOneofFieldGenerator::
|
||||
EnumOneofFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options)
|
||||
: EnumFieldGenerator(descriptor, options) {
|
||||
SetCommonOneofFieldVariables(descriptor, &variables_);
|
||||
}
|
||||
|
||||
EnumOneofFieldGenerator::~EnumOneofFieldGenerator() {}
|
||||
|
||||
void EnumOneofFieldGenerator::
|
||||
GenerateInlineAccessorDefinitions(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline $type$ $classname$::$name$() const {\n"
|
||||
" if (has_$name$()) {\n"
|
||||
" return static_cast< $type$ >($oneof_prefix$$name$_);\n"
|
||||
" }\n"
|
||||
" return static_cast< $type$ >($default$);\n"
|
||||
"}\n"
|
||||
"inline void $classname$::set_$name$($type$ value) {\n"
|
||||
" assert($type$_IsValid(value));\n"
|
||||
" if (!has_$name$()) {\n"
|
||||
" clear_$oneof_name$();\n"
|
||||
" set_has_$name$();\n"
|
||||
" }\n"
|
||||
" $oneof_prefix$$name$_ = value;\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void EnumOneofFieldGenerator::
|
||||
GenerateClearingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$oneof_prefix$$name$_ = $default$;\n");
|
||||
}
|
||||
|
||||
void EnumOneofFieldGenerator::
|
||||
GenerateSwappingCode(io::Printer* printer) const {
|
||||
// Don't print any swapping code. Swapping the union will swap this field.
|
||||
}
|
||||
|
||||
void EnumOneofFieldGenerator::
|
||||
GenerateConstructorCode(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
" $classname$_default_oneof_instance_->$name$_ = $default$;\n");
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
RepeatedEnumFieldGenerator::
|
||||
RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options)
|
||||
: descriptor_(descriptor) {
|
||||
SetEnumVariables(descriptor, &variables_, options);
|
||||
}
|
||||
|
||||
RepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() {}
|
||||
|
||||
void RepeatedEnumFieldGenerator::
|
||||
GeneratePrivateMembers(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"::google::protobuf::RepeatedField<int> $name$_;\n");
|
||||
if (descriptor_->options().packed()
|
||||
&& HasGeneratedMethods(descriptor_->file())) {
|
||||
printer->Print(variables_,
|
||||
"mutable int _$name$_cached_byte_size_;\n");
|
||||
}
|
||||
}
|
||||
|
||||
void RepeatedEnumFieldGenerator::
|
||||
GenerateAccessorDeclarations(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline $type$ $name$(int index) const$deprecation$;\n"
|
||||
"inline void set_$name$(int index, $type$ value)$deprecation$;\n"
|
||||
"inline void add_$name$($type$ value)$deprecation$;\n");
|
||||
printer->Print(variables_,
|
||||
"inline const ::google::protobuf::RepeatedField<int>& $name$() const$deprecation$;\n"
|
||||
"inline ::google::protobuf::RepeatedField<int>* mutable_$name$()$deprecation$;\n");
|
||||
}
|
||||
|
||||
void RepeatedEnumFieldGenerator::
|
||||
GenerateInlineAccessorDefinitions(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline $type$ $classname$::$name$(int index) const {\n"
|
||||
" // @@protoc_insertion_point(field_get:$full_name$)\n"
|
||||
" return static_cast< $type$ >($name$_.Get(index));\n"
|
||||
"}\n"
|
||||
"inline void $classname$::set_$name$(int index, $type$ value) {\n"
|
||||
" assert($type$_IsValid(value));\n"
|
||||
" $name$_.Set(index, value);\n"
|
||||
" // @@protoc_insertion_point(field_set:$full_name$)\n"
|
||||
"}\n"
|
||||
"inline void $classname$::add_$name$($type$ value) {\n"
|
||||
" assert($type$_IsValid(value));\n"
|
||||
" $name$_.Add(value);\n"
|
||||
" // @@protoc_insertion_point(field_add:$full_name$)\n"
|
||||
"}\n");
|
||||
printer->Print(variables_,
|
||||
"inline const ::google::protobuf::RepeatedField<int>&\n"
|
||||
"$classname$::$name$() const {\n"
|
||||
" // @@protoc_insertion_point(field_list:$full_name$)\n"
|
||||
" return $name$_;\n"
|
||||
"}\n"
|
||||
"inline ::google::protobuf::RepeatedField<int>*\n"
|
||||
"$classname$::mutable_$name$() {\n"
|
||||
" // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
|
||||
" return &$name$_;\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void RepeatedEnumFieldGenerator::
|
||||
GenerateClearingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$name$_.Clear();\n");
|
||||
}
|
||||
|
||||
void RepeatedEnumFieldGenerator::
|
||||
GenerateMergingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$name$_.MergeFrom(from.$name$_);\n");
|
||||
}
|
||||
|
||||
void RepeatedEnumFieldGenerator::
|
||||
GenerateSwappingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$name$_.Swap(&other->$name$_);\n");
|
||||
}
|
||||
|
||||
void RepeatedEnumFieldGenerator::
|
||||
GenerateConstructorCode(io::Printer* printer) const {
|
||||
if (descriptor_->options().packed()
|
||||
&& HasGeneratedMethods(descriptor_->file())) {
|
||||
printer->Print(variables_, "_$name$_cached_byte_size_ = 0;\n");
|
||||
}
|
||||
}
|
||||
|
||||
void RepeatedEnumFieldGenerator::
|
||||
GenerateMergeFromCodedStream(io::Printer* printer) const {
|
||||
// Don't use ReadRepeatedPrimitive here so that the enum can be validated.
|
||||
printer->Print(variables_,
|
||||
"int value;\n"
|
||||
"DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n"
|
||||
" int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n"
|
||||
" input, &value)));\n"
|
||||
"if ($type$_IsValid(value)) {\n"
|
||||
" add_$name$(static_cast< $type$ >(value));\n");
|
||||
if (UseUnknownFieldSet(descriptor_->file())) {
|
||||
printer->Print(variables_,
|
||||
"} else {\n"
|
||||
" mutable_unknown_fields()->AddVarint($number$, value);\n");
|
||||
} else {
|
||||
printer->Print(
|
||||
"} else {\n"
|
||||
" unknown_fields_stream.WriteVarint32(tag);\n"
|
||||
" unknown_fields_stream.WriteVarint32(value);\n");
|
||||
}
|
||||
printer->Print("}\n");
|
||||
}
|
||||
|
||||
void RepeatedEnumFieldGenerator::
|
||||
GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const {
|
||||
if (!descriptor_->options().packed()) {
|
||||
// We use a non-inlined implementation in this case, since this path will
|
||||
// rarely be executed.
|
||||
printer->Print(variables_,
|
||||
"DO_((::google::protobuf::internal::WireFormatLite::ReadPackedEnumNoInline(\n"
|
||||
" input,\n"
|
||||
" &$type$_IsValid,\n"
|
||||
" this->mutable_$name$())));\n");
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
"::google::protobuf::uint32 length;\n"
|
||||
"DO_(input->ReadVarint32(&length));\n"
|
||||
"::google::protobuf::io::CodedInputStream::Limit limit = "
|
||||
"input->PushLimit(length);\n"
|
||||
"while (input->BytesUntilLimit() > 0) {\n"
|
||||
" int value;\n"
|
||||
" DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n"
|
||||
" int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n"
|
||||
" input, &value)));\n"
|
||||
" if ($type$_IsValid(value)) {\n"
|
||||
" add_$name$(static_cast< $type$ >(value));\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"input->PopLimit(limit);\n");
|
||||
}
|
||||
}
|
||||
|
||||
void RepeatedEnumFieldGenerator::
|
||||
GenerateSerializeWithCachedSizes(io::Printer* printer) const {
|
||||
if (descriptor_->options().packed()) {
|
||||
// Write the tag and the size.
|
||||
printer->Print(variables_,
|
||||
"if (this->$name$_size() > 0) {\n"
|
||||
" ::google::protobuf::internal::WireFormatLite::WriteTag(\n"
|
||||
" $number$,\n"
|
||||
" ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n"
|
||||
" output);\n"
|
||||
" output->WriteVarint32(_$name$_cached_byte_size_);\n"
|
||||
"}\n");
|
||||
}
|
||||
printer->Print(variables_,
|
||||
"for (int i = 0; i < this->$name$_size(); i++) {\n");
|
||||
if (descriptor_->options().packed()) {
|
||||
printer->Print(variables_,
|
||||
" ::google::protobuf::internal::WireFormatLite::WriteEnumNoTag(\n"
|
||||
" this->$name$(i), output);\n");
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
" ::google::protobuf::internal::WireFormatLite::WriteEnum(\n"
|
||||
" $number$, this->$name$(i), output);\n");
|
||||
}
|
||||
printer->Print("}\n");
|
||||
}
|
||||
|
||||
void RepeatedEnumFieldGenerator::
|
||||
GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
|
||||
if (descriptor_->options().packed()) {
|
||||
// Write the tag and the size.
|
||||
printer->Print(variables_,
|
||||
"if (this->$name$_size() > 0) {\n"
|
||||
" target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(\n"
|
||||
" $number$,\n"
|
||||
" ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n"
|
||||
" target);\n"
|
||||
" target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray("
|
||||
" _$name$_cached_byte_size_, target);\n"
|
||||
"}\n");
|
||||
}
|
||||
printer->Print(variables_,
|
||||
"for (int i = 0; i < this->$name$_size(); i++) {\n");
|
||||
if (descriptor_->options().packed()) {
|
||||
printer->Print(variables_,
|
||||
" target = ::google::protobuf::internal::WireFormatLite::WriteEnumNoTagToArray(\n"
|
||||
" this->$name$(i), target);\n");
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
" target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n"
|
||||
" $number$, this->$name$(i), target);\n");
|
||||
}
|
||||
printer->Print("}\n");
|
||||
}
|
||||
|
||||
void RepeatedEnumFieldGenerator::
|
||||
GenerateByteSize(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"{\n"
|
||||
" int data_size = 0;\n");
|
||||
printer->Indent();
|
||||
printer->Print(variables_,
|
||||
"for (int i = 0; i < this->$name$_size(); i++) {\n"
|
||||
" data_size += ::google::protobuf::internal::WireFormatLite::EnumSize(\n"
|
||||
" this->$name$(i));\n"
|
||||
"}\n");
|
||||
|
||||
if (descriptor_->options().packed()) {
|
||||
printer->Print(variables_,
|
||||
"if (data_size > 0) {\n"
|
||||
" total_size += $tag_size$ +\n"
|
||||
" ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n"
|
||||
"}\n"
|
||||
"GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n"
|
||||
"_$name$_cached_byte_size_ = data_size;\n"
|
||||
"GOOGLE_SAFE_CONCURRENT_WRITES_END();\n"
|
||||
"total_size += data_size;\n");
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
"total_size += $tag_size$ * this->$name$_size() + data_size;\n");
|
||||
}
|
||||
printer->Outdent();
|
||||
printer->Print("}\n");
|
||||
}
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
@@ -1,122 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "google/protobuf/compiler/cpp/cpp_field.h"
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
class EnumFieldGenerator : public FieldGenerator {
|
||||
public:
|
||||
explicit EnumFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options);
|
||||
~EnumFieldGenerator();
|
||||
|
||||
// implements FieldGenerator ---------------------------------------
|
||||
void GeneratePrivateMembers(io::Printer* printer) const;
|
||||
void GenerateAccessorDeclarations(io::Printer* printer) const;
|
||||
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
|
||||
void GenerateClearingCode(io::Printer* printer) const;
|
||||
void GenerateMergingCode(io::Printer* printer) const;
|
||||
void GenerateSwappingCode(io::Printer* printer) const;
|
||||
void GenerateConstructorCode(io::Printer* printer) const;
|
||||
void GenerateMergeFromCodedStream(io::Printer* printer) const;
|
||||
void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
|
||||
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
|
||||
void GenerateByteSize(io::Printer* printer) const;
|
||||
|
||||
protected:
|
||||
const FieldDescriptor* descriptor_;
|
||||
map<string, string> variables_;
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator);
|
||||
};
|
||||
|
||||
class EnumOneofFieldGenerator : public EnumFieldGenerator {
|
||||
public:
|
||||
explicit EnumOneofFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options);
|
||||
~EnumOneofFieldGenerator();
|
||||
|
||||
// implements FieldGenerator ---------------------------------------
|
||||
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
|
||||
void GenerateClearingCode(io::Printer* printer) const;
|
||||
void GenerateSwappingCode(io::Printer* printer) const;
|
||||
void GenerateConstructorCode(io::Printer* printer) const;
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumOneofFieldGenerator);
|
||||
};
|
||||
|
||||
class RepeatedEnumFieldGenerator : public FieldGenerator {
|
||||
public:
|
||||
explicit RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options);
|
||||
~RepeatedEnumFieldGenerator();
|
||||
|
||||
// implements FieldGenerator ---------------------------------------
|
||||
void GeneratePrivateMembers(io::Printer* printer) const;
|
||||
void GenerateAccessorDeclarations(io::Printer* printer) const;
|
||||
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
|
||||
void GenerateClearingCode(io::Printer* printer) const;
|
||||
void GenerateMergingCode(io::Printer* printer) const;
|
||||
void GenerateSwappingCode(io::Printer* printer) const;
|
||||
void GenerateConstructorCode(io::Printer* printer) const;
|
||||
void GenerateMergeFromCodedStream(io::Printer* printer) const;
|
||||
void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const;
|
||||
void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
|
||||
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
|
||||
void GenerateByteSize(io::Printer* printer) const;
|
||||
|
||||
private:
|
||||
const FieldDescriptor* descriptor_;
|
||||
map<string, string> variables_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator);
|
||||
};
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__
|
||||
@@ -1,210 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#include "google/protobuf/compiler/cpp/cpp_extension.h"
|
||||
#include <map>
|
||||
#include "google/protobuf/compiler/cpp/cpp_helpers.h"
|
||||
#include "google/protobuf/stubs/strutil.h"
|
||||
#include <google/protobuf/io/printer.h>
|
||||
#include <google/protobuf/descriptor.pb.h>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
namespace {
|
||||
|
||||
// Returns the fully-qualified class name of the message that this field
|
||||
// extends. This function is used in the Google-internal code to handle some
|
||||
// legacy cases.
|
||||
string ExtendeeClassName(const FieldDescriptor* descriptor) {
|
||||
const Descriptor* extendee = descriptor->containing_type();
|
||||
return ClassName(extendee, true);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options)
|
||||
: descriptor_(descriptor),
|
||||
options_(options) {
|
||||
// Construct type_traits_.
|
||||
if (descriptor_->is_repeated()) {
|
||||
type_traits_ = "Repeated";
|
||||
}
|
||||
|
||||
switch (descriptor_->cpp_type()) {
|
||||
case FieldDescriptor::CPPTYPE_ENUM:
|
||||
type_traits_.append("EnumTypeTraits< ");
|
||||
type_traits_.append(ClassName(descriptor_->enum_type(), true));
|
||||
type_traits_.append(", ");
|
||||
type_traits_.append(ClassName(descriptor_->enum_type(), true));
|
||||
type_traits_.append("_IsValid>");
|
||||
break;
|
||||
case FieldDescriptor::CPPTYPE_STRING:
|
||||
type_traits_.append("StringTypeTraits");
|
||||
break;
|
||||
case FieldDescriptor::CPPTYPE_MESSAGE:
|
||||
type_traits_.append("MessageTypeTraits< ");
|
||||
type_traits_.append(ClassName(descriptor_->message_type(), true));
|
||||
type_traits_.append(" >");
|
||||
break;
|
||||
default:
|
||||
type_traits_.append("PrimitiveTypeTraits< ");
|
||||
type_traits_.append(PrimitiveTypeName(descriptor_->cpp_type()));
|
||||
type_traits_.append(" >");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ExtensionGenerator::~ExtensionGenerator() {}
|
||||
|
||||
void ExtensionGenerator::GenerateDeclaration(io::Printer* printer) {
|
||||
map<string, string> vars;
|
||||
vars["extendee" ] = ExtendeeClassName(descriptor_);
|
||||
vars["number" ] = SimpleItoa(descriptor_->number());
|
||||
vars["type_traits" ] = type_traits_;
|
||||
vars["name" ] = descriptor_->name();
|
||||
vars["field_type" ] = SimpleItoa(static_cast<int>(descriptor_->type()));
|
||||
vars["packed" ] = descriptor_->options().packed() ? "true" : "false";
|
||||
vars["constant_name"] = FieldConstantName(descriptor_);
|
||||
|
||||
// If this is a class member, it needs to be declared "static". Otherwise,
|
||||
// it needs to be "extern". In the latter case, it also needs the DLL
|
||||
// export/import specifier.
|
||||
if (descriptor_->extension_scope() == NULL) {
|
||||
vars["qualifier"] = "extern";
|
||||
if (!options_.dllexport_decl.empty()) {
|
||||
vars["qualifier"] = options_.dllexport_decl + " " + vars["qualifier"];
|
||||
}
|
||||
} else {
|
||||
vars["qualifier"] = "static";
|
||||
}
|
||||
|
||||
printer->Print(vars,
|
||||
"static const int $constant_name$ = $number$;\n"
|
||||
"$qualifier$ ::google::protobuf::internal::ExtensionIdentifier< $extendee$,\n"
|
||||
" ::google::protobuf::internal::$type_traits$, $field_type$, $packed$ >\n"
|
||||
" $name$;\n"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
void ExtensionGenerator::GenerateDefinition(io::Printer* printer) {
|
||||
// If this is a class member, it needs to be declared in its class scope.
|
||||
string scope = (descriptor_->extension_scope() == NULL) ? "" :
|
||||
ClassName(descriptor_->extension_scope(), false) + "::";
|
||||
string name = scope + descriptor_->name();
|
||||
|
||||
map<string, string> vars;
|
||||
vars["extendee" ] = ExtendeeClassName(descriptor_);
|
||||
vars["type_traits" ] = type_traits_;
|
||||
vars["name" ] = name;
|
||||
vars["constant_name"] = FieldConstantName(descriptor_);
|
||||
vars["default" ] = DefaultValue(descriptor_);
|
||||
vars["field_type" ] = SimpleItoa(static_cast<int>(descriptor_->type()));
|
||||
vars["packed" ] = descriptor_->options().packed() ? "true" : "false";
|
||||
vars["scope" ] = scope;
|
||||
|
||||
if (descriptor_->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
|
||||
// We need to declare a global string which will contain the default value.
|
||||
// We cannot declare it at class scope because that would require exposing
|
||||
// it in the header which would be annoying for other reasons. So we
|
||||
// replace :: with _ in the name and declare it as a global.
|
||||
string global_name = StringReplace(name, "::", "_", true);
|
||||
vars["global_name"] = global_name;
|
||||
printer->Print(vars,
|
||||
"const ::std::string $global_name$_default($default$);\n");
|
||||
|
||||
// Update the default to refer to the string global.
|
||||
vars["default"] = global_name + "_default";
|
||||
}
|
||||
|
||||
// Likewise, class members need to declare the field constant variable.
|
||||
if (descriptor_->extension_scope() != NULL) {
|
||||
printer->Print(vars,
|
||||
"#ifndef _MSC_VER\n"
|
||||
"const int $scope$$constant_name$;\n"
|
||||
"#endif\n");
|
||||
}
|
||||
|
||||
printer->Print(vars,
|
||||
"::google::protobuf::internal::ExtensionIdentifier< $extendee$,\n"
|
||||
" ::google::protobuf::internal::$type_traits$, $field_type$, $packed$ >\n"
|
||||
" $name$($constant_name$, $default$);\n");
|
||||
}
|
||||
|
||||
void ExtensionGenerator::GenerateRegistration(io::Printer* printer) {
|
||||
map<string, string> vars;
|
||||
vars["extendee" ] = ExtendeeClassName(descriptor_);
|
||||
vars["number" ] = SimpleItoa(descriptor_->number());
|
||||
vars["field_type" ] = SimpleItoa(static_cast<int>(descriptor_->type()));
|
||||
vars["is_repeated"] = descriptor_->is_repeated() ? "true" : "false";
|
||||
vars["is_packed" ] = (descriptor_->is_repeated() &&
|
||||
descriptor_->options().packed())
|
||||
? "true" : "false";
|
||||
|
||||
switch (descriptor_->cpp_type()) {
|
||||
case FieldDescriptor::CPPTYPE_ENUM:
|
||||
printer->Print(vars,
|
||||
"::google::protobuf::internal::ExtensionSet::RegisterEnumExtension(\n"
|
||||
" &$extendee$::default_instance(),\n"
|
||||
" $number$, $field_type$, $is_repeated$, $is_packed$,\n");
|
||||
printer->Print(
|
||||
" &$type$_IsValid);\n",
|
||||
"type", ClassName(descriptor_->enum_type(), true));
|
||||
break;
|
||||
case FieldDescriptor::CPPTYPE_MESSAGE:
|
||||
printer->Print(vars,
|
||||
"::google::protobuf::internal::ExtensionSet::RegisterMessageExtension(\n"
|
||||
" &$extendee$::default_instance(),\n"
|
||||
" $number$, $field_type$, $is_repeated$, $is_packed$,\n");
|
||||
printer->Print(
|
||||
" &$type$::default_instance());\n",
|
||||
"type", ClassName(descriptor_->message_type(), true));
|
||||
break;
|
||||
default:
|
||||
printer->Print(vars,
|
||||
"::google::protobuf::internal::ExtensionSet::RegisterExtension(\n"
|
||||
" &$extendee$::default_instance(),\n"
|
||||
" $number$, $field_type$, $is_repeated$, $is_packed$);\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
@@ -1,86 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_EXTENSION_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_CPP_EXTENSION_H__
|
||||
|
||||
#include <string>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include "google/protobuf/compiler/cpp/cpp_options.h"
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
class FieldDescriptor; // descriptor.h
|
||||
namespace io {
|
||||
class Printer; // printer.h
|
||||
}
|
||||
}
|
||||
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
// Generates code for an extension, which may be within the scope of some
|
||||
// message or may be at file scope. This is much simpler than FieldGenerator
|
||||
// since extensions are just simple identifiers with interesting types.
|
||||
class ExtensionGenerator {
|
||||
public:
|
||||
// See generator.cc for the meaning of dllexport_decl.
|
||||
explicit ExtensionGenerator(const FieldDescriptor* desycriptor,
|
||||
const Options& options);
|
||||
~ExtensionGenerator();
|
||||
|
||||
// Header stuff.
|
||||
void GenerateDeclaration(io::Printer* printer);
|
||||
|
||||
// Source file stuff.
|
||||
void GenerateDefinition(io::Printer* printer);
|
||||
|
||||
// Generate code to register the extension.
|
||||
void GenerateRegistration(io::Printer* printer);
|
||||
|
||||
private:
|
||||
const FieldDescriptor* descriptor_;
|
||||
string type_traits_;
|
||||
Options options_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);
|
||||
};
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__
|
||||
@@ -1,166 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#include "google/protobuf/compiler/cpp/cpp_field.h"
|
||||
#include <memory>
|
||||
|
||||
#include "google/protobuf/compiler/cpp/cpp_helpers.h"
|
||||
#include "google/protobuf/compiler/cpp/cpp_primitive_field.h"
|
||||
#include "google/protobuf/compiler/cpp/cpp_string_field.h"
|
||||
#include "google/protobuf/compiler/cpp/cpp_enum_field.h"
|
||||
#include "google/protobuf/compiler/cpp/cpp_message_field.h"
|
||||
#include <google/protobuf/descriptor.pb.h>
|
||||
#include <google/protobuf/wire_format.h>
|
||||
#include <google/protobuf/io/printer.h>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include "google/protobuf/stubs/strutil.h"
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
using internal::WireFormat;
|
||||
|
||||
void SetCommonFieldVariables(const FieldDescriptor* descriptor,
|
||||
map<string, string>* variables,
|
||||
const Options& options) {
|
||||
(*variables)["name"] = FieldName(descriptor);
|
||||
(*variables)["index"] = SimpleItoa(descriptor->index());
|
||||
(*variables)["number"] = SimpleItoa(descriptor->number());
|
||||
(*variables)["classname"] = ClassName(FieldScope(descriptor), false);
|
||||
(*variables)["declared_type"] = DeclaredTypeMethodName(descriptor->type());
|
||||
|
||||
(*variables)["tag_size"] = SimpleItoa(
|
||||
WireFormat::TagSize(descriptor->number(), descriptor->type()));
|
||||
(*variables)["deprecation"] = descriptor->options().deprecated()
|
||||
? " PROTOBUF_DEPRECATED" : "";
|
||||
|
||||
(*variables)["cppget"] = "Get";
|
||||
}
|
||||
|
||||
void SetCommonOneofFieldVariables(const FieldDescriptor* descriptor,
|
||||
map<string, string>* variables) {
|
||||
(*variables)["oneof_prefix"] = descriptor->containing_oneof()->name() + "_.";
|
||||
(*variables)["oneof_name"] = descriptor->containing_oneof()->name();
|
||||
}
|
||||
|
||||
FieldGenerator::~FieldGenerator() {}
|
||||
|
||||
void FieldGenerator::
|
||||
GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const {
|
||||
// Reaching here indicates a bug. Cases are:
|
||||
// - This FieldGenerator should support packing, but this method should be
|
||||
// overridden.
|
||||
// - This FieldGenerator doesn't support packing, and this method should
|
||||
// never have been called.
|
||||
GOOGLE_LOG(FATAL) << "GenerateMergeFromCodedStreamWithPacking() "
|
||||
<< "called on field generator that does not support packing.";
|
||||
|
||||
}
|
||||
|
||||
FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor,
|
||||
const Options& options)
|
||||
: descriptor_(descriptor),
|
||||
field_generators_(
|
||||
new scoped_ptr<FieldGenerator>[descriptor->field_count()]) {
|
||||
// Construct all the FieldGenerators.
|
||||
for (int i = 0; i < descriptor->field_count(); i++) {
|
||||
field_generators_[i].reset(MakeGenerator(descriptor->field(i), options));
|
||||
}
|
||||
}
|
||||
|
||||
FieldGenerator* FieldGeneratorMap::MakeGenerator(const FieldDescriptor* field,
|
||||
const Options& options) {
|
||||
if (field->is_repeated()) {
|
||||
switch (field->cpp_type()) {
|
||||
case FieldDescriptor::CPPTYPE_MESSAGE:
|
||||
return new RepeatedMessageFieldGenerator(field, options);
|
||||
case FieldDescriptor::CPPTYPE_STRING:
|
||||
switch (field->options().ctype()) {
|
||||
default: // RepeatedStringFieldGenerator handles unknown ctypes.
|
||||
case FieldOptions::STRING:
|
||||
return new RepeatedStringFieldGenerator(field, options);
|
||||
}
|
||||
case FieldDescriptor::CPPTYPE_ENUM:
|
||||
return new RepeatedEnumFieldGenerator(field, options);
|
||||
default:
|
||||
return new RepeatedPrimitiveFieldGenerator(field, options);
|
||||
}
|
||||
} else if (field->containing_oneof()) {
|
||||
switch (field->cpp_type()) {
|
||||
case FieldDescriptor::CPPTYPE_MESSAGE:
|
||||
return new MessageOneofFieldGenerator(field, options);
|
||||
case FieldDescriptor::CPPTYPE_STRING:
|
||||
switch (field->options().ctype()) {
|
||||
default: // StringOneofFieldGenerator handles unknown ctypes.
|
||||
case FieldOptions::STRING:
|
||||
return new StringOneofFieldGenerator(field, options);
|
||||
}
|
||||
case FieldDescriptor::CPPTYPE_ENUM:
|
||||
return new EnumOneofFieldGenerator(field, options);
|
||||
default:
|
||||
return new PrimitiveOneofFieldGenerator(field, options);
|
||||
}
|
||||
} else {
|
||||
switch (field->cpp_type()) {
|
||||
case FieldDescriptor::CPPTYPE_MESSAGE:
|
||||
return new MessageFieldGenerator(field, options);
|
||||
case FieldDescriptor::CPPTYPE_STRING:
|
||||
switch (field->options().ctype()) {
|
||||
default: // StringFieldGenerator handles unknown ctypes.
|
||||
case FieldOptions::STRING:
|
||||
return new StringFieldGenerator(field, options);
|
||||
}
|
||||
case FieldDescriptor::CPPTYPE_ENUM:
|
||||
return new EnumFieldGenerator(field, options);
|
||||
default:
|
||||
return new PrimitiveFieldGenerator(field, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FieldGeneratorMap::~FieldGeneratorMap() {}
|
||||
|
||||
const FieldGenerator& FieldGeneratorMap::get(
|
||||
const FieldDescriptor* field) const {
|
||||
GOOGLE_CHECK_EQ(field->containing_type(), descriptor_);
|
||||
return *field_generators_[field->index()];
|
||||
}
|
||||
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
@@ -1,185 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include "google/protobuf/compiler/cpp/cpp_options.h"
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace io {
|
||||
class Printer; // printer.h
|
||||
}
|
||||
}
|
||||
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
// Helper function: set variables in the map that are the same for all
|
||||
// field code generators.
|
||||
// ['name', 'index', 'number', 'classname', 'declared_type', 'tag_size',
|
||||
// 'deprecation'].
|
||||
void SetCommonFieldVariables(const FieldDescriptor* descriptor,
|
||||
map<string, string>* variables,
|
||||
const Options& options);
|
||||
|
||||
void SetCommonOneofFieldVariables(const FieldDescriptor* descriptor,
|
||||
map<string, string>* variables);
|
||||
|
||||
class FieldGenerator {
|
||||
public:
|
||||
FieldGenerator() {}
|
||||
virtual ~FieldGenerator();
|
||||
|
||||
// Generate lines of code declaring members fields of the message class
|
||||
// needed to represent this field. These are placed inside the message
|
||||
// class.
|
||||
virtual void GeneratePrivateMembers(io::Printer* printer) const = 0;
|
||||
|
||||
// Generate static default variable for this field. These are placed inside
|
||||
// the message class. Most field types don't need this, so the default
|
||||
// implementation is empty.
|
||||
virtual void GenerateStaticMembers(io::Printer* printer) const {}
|
||||
|
||||
// Generate prototypes for all of the accessor functions related to this
|
||||
// field. These are placed inside the class definition.
|
||||
virtual void GenerateAccessorDeclarations(io::Printer* printer) const = 0;
|
||||
|
||||
// Generate inline definitions of accessor functions for this field.
|
||||
// These are placed inside the header after all class definitions.
|
||||
virtual void GenerateInlineAccessorDefinitions(
|
||||
io::Printer* printer) const = 0;
|
||||
|
||||
// Generate definitions of accessors that aren't inlined. These are
|
||||
// placed somewhere in the .cc file.
|
||||
// Most field types don't need this, so the default implementation is empty.
|
||||
virtual void GenerateNonInlineAccessorDefinitions(
|
||||
io::Printer* printer) const {}
|
||||
|
||||
// Generate lines of code (statements, not declarations) which clear the
|
||||
// field. This is used to define the clear_$name$() method as well as
|
||||
// the Clear() method for the whole message.
|
||||
virtual void GenerateClearingCode(io::Printer* printer) const = 0;
|
||||
|
||||
// Generate lines of code (statements, not declarations) which merges the
|
||||
// contents of the field from the current message to the target message,
|
||||
// which is stored in the generated code variable "from".
|
||||
// This is used to fill in the MergeFrom method for the whole message.
|
||||
// Details of this usage can be found in message.cc under the
|
||||
// GenerateMergeFrom method.
|
||||
virtual void GenerateMergingCode(io::Printer* printer) const = 0;
|
||||
|
||||
// Generate lines of code (statements, not declarations) which swaps
|
||||
// this field and the corresponding field of another message, which
|
||||
// is stored in the generated code variable "other". This is used to
|
||||
// define the Swap method. Details of usage can be found in
|
||||
// message.cc under the GenerateSwap method.
|
||||
virtual void GenerateSwappingCode(io::Printer* printer) const = 0;
|
||||
|
||||
// Generate initialization code for private members declared by
|
||||
// GeneratePrivateMembers(). These go into the message class's SharedCtor()
|
||||
// method, invoked by each of the generated constructors.
|
||||
virtual void GenerateConstructorCode(io::Printer* printer) const = 0;
|
||||
|
||||
// Generate any code that needs to go in the class's SharedDtor() method,
|
||||
// invoked by the destructor.
|
||||
// Most field types don't need this, so the default implementation is empty.
|
||||
virtual void GenerateDestructorCode(io::Printer* printer) const {}
|
||||
|
||||
// Generate code that allocates the fields's default instance.
|
||||
virtual void GenerateDefaultInstanceAllocator(io::Printer* printer) const {}
|
||||
|
||||
// Generate code that should be run when ShutdownProtobufLibrary() is called,
|
||||
// to delete all dynamically-allocated objects.
|
||||
virtual void GenerateShutdownCode(io::Printer* printer) const {}
|
||||
|
||||
// Generate lines to decode this field, which will be placed inside the
|
||||
// message's MergeFromCodedStream() method.
|
||||
virtual void GenerateMergeFromCodedStream(io::Printer* printer) const = 0;
|
||||
|
||||
// Generate lines to decode this field from a packed value, which will be
|
||||
// placed inside the message's MergeFromCodedStream() method.
|
||||
virtual void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer)
|
||||
const;
|
||||
|
||||
// Generate lines to serialize this field, which are placed within the
|
||||
// message's SerializeWithCachedSizes() method.
|
||||
virtual void GenerateSerializeWithCachedSizes(io::Printer* printer) const = 0;
|
||||
|
||||
// Generate lines to serialize this field directly to the array "target",
|
||||
// which are placed within the message's SerializeWithCachedSizesToArray()
|
||||
// method. This must also advance "target" past the written bytes.
|
||||
virtual void GenerateSerializeWithCachedSizesToArray(
|
||||
io::Printer* printer) const = 0;
|
||||
|
||||
// Generate lines to compute the serialized size of this field, which
|
||||
// are placed in the message's ByteSize() method.
|
||||
virtual void GenerateByteSize(io::Printer* printer) const = 0;
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator);
|
||||
};
|
||||
|
||||
// Convenience class which constructs FieldGenerators for a Descriptor.
|
||||
class FieldGeneratorMap {
|
||||
public:
|
||||
explicit FieldGeneratorMap(const Descriptor* descriptor, const Options& options);
|
||||
~FieldGeneratorMap();
|
||||
|
||||
const FieldGenerator& get(const FieldDescriptor* field) const;
|
||||
|
||||
private:
|
||||
const Descriptor* descriptor_;
|
||||
scoped_array<scoped_ptr<FieldGenerator> > field_generators_;
|
||||
|
||||
static FieldGenerator* MakeGenerator(const FieldDescriptor* field,
|
||||
const Options& options);
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap);
|
||||
};
|
||||
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__
|
||||
@@ -1,494 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <google/protobuf/stubs/hash.h>
|
||||
|
||||
#include "google/protobuf/compiler/cpp/cpp_helpers.h"
|
||||
#include <google/protobuf/io/printer.h>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include "google/protobuf/stubs/strutil.h"
|
||||
#include <google/protobuf/stubs/substitute.h>
|
||||
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
namespace {
|
||||
|
||||
string DotsToUnderscores(const string& name) {
|
||||
return StringReplace(name, ".", "_", true);
|
||||
}
|
||||
|
||||
string DotsToColons(const string& name) {
|
||||
return StringReplace(name, ".", "::", true);
|
||||
}
|
||||
|
||||
const char* const kKeywordList[] = {
|
||||
"and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break", "case",
|
||||
"catch", "char", "class", "compl", "const", "const_cast", "continue",
|
||||
"default", "delete", "do", "double", "dynamic_cast", "else", "enum",
|
||||
"explicit", "extern", "false", "float", "for", "friend", "goto", "if",
|
||||
"inline", "int", "long", "mutable", "namespace", "new", "not", "not_eq",
|
||||
"operator", "or", "or_eq", "private", "protected", "public", "register",
|
||||
"reinterpret_cast", "return", "short", "signed", "sizeof", "static",
|
||||
"static_cast", "struct", "switch", "template", "this", "throw", "true", "try",
|
||||
"typedef", "typeid", "typename", "union", "unsigned", "using", "virtual",
|
||||
"void", "volatile", "wchar_t", "while", "xor", "xor_eq"
|
||||
};
|
||||
|
||||
hash_set<string> MakeKeywordsMap() {
|
||||
hash_set<string> result;
|
||||
for (int i = 0; i < GOOGLE_ARRAYSIZE(kKeywordList); i++) {
|
||||
result.insert(kKeywordList[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
hash_set<string> kKeywords = MakeKeywordsMap();
|
||||
|
||||
// Returns whether the provided descriptor has an extension. This includes its
|
||||
// nested types.
|
||||
bool HasExtension(const Descriptor* descriptor) {
|
||||
if (descriptor->extension_count() > 0) {
|
||||
return true;
|
||||
}
|
||||
for (int i = 0; i < descriptor->nested_type_count(); ++i) {
|
||||
if (HasExtension(descriptor->nested_type(i))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
string UnderscoresToCamelCase(const string& input, bool cap_next_letter) {
|
||||
string result;
|
||||
// Note: I distrust ctype.h due to locales.
|
||||
for (int i = 0; i < input.size(); i++) {
|
||||
if ('a' <= input[i] && input[i] <= 'z') {
|
||||
if (cap_next_letter) {
|
||||
result += input[i] + ('A' - 'a');
|
||||
} else {
|
||||
result += input[i];
|
||||
}
|
||||
cap_next_letter = false;
|
||||
} else if ('A' <= input[i] && input[i] <= 'Z') {
|
||||
// Capital letters are left as-is.
|
||||
result += input[i];
|
||||
cap_next_letter = false;
|
||||
} else if ('0' <= input[i] && input[i] <= '9') {
|
||||
result += input[i];
|
||||
cap_next_letter = true;
|
||||
} else {
|
||||
cap_next_letter = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const char kThickSeparator[] =
|
||||
"// ===================================================================\n";
|
||||
const char kThinSeparator[] =
|
||||
"// -------------------------------------------------------------------\n";
|
||||
|
||||
string ClassName(const Descriptor* descriptor, bool qualified) {
|
||||
|
||||
// Find "outer", the descriptor of the top-level message in which
|
||||
// "descriptor" is embedded.
|
||||
const Descriptor* outer = descriptor;
|
||||
while (outer->containing_type() != NULL) outer = outer->containing_type();
|
||||
|
||||
const string& outer_name = outer->full_name();
|
||||
string inner_name = descriptor->full_name().substr(outer_name.size());
|
||||
|
||||
if (qualified) {
|
||||
return "::" + DotsToColons(outer_name) + DotsToUnderscores(inner_name);
|
||||
} else {
|
||||
return outer->name() + DotsToUnderscores(inner_name);
|
||||
}
|
||||
}
|
||||
|
||||
string ClassName(const EnumDescriptor* enum_descriptor, bool qualified) {
|
||||
if (enum_descriptor->containing_type() == NULL) {
|
||||
if (qualified) {
|
||||
return "::" + DotsToColons(enum_descriptor->full_name());
|
||||
} else {
|
||||
return enum_descriptor->name();
|
||||
}
|
||||
} else {
|
||||
string result = ClassName(enum_descriptor->containing_type(), qualified);
|
||||
result += '_';
|
||||
result += enum_descriptor->name();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string SuperClassName(const Descriptor* descriptor) {
|
||||
return HasDescriptorMethods(descriptor->file()) ?
|
||||
"::google::protobuf::Message" : "::google::protobuf::MessageLite";
|
||||
}
|
||||
|
||||
string FieldName(const FieldDescriptor* field) {
|
||||
string result = field->name();
|
||||
LowerString(&result);
|
||||
if (kKeywords.count(result) > 0) {
|
||||
result.append("_");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
string FieldConstantName(const FieldDescriptor *field) {
|
||||
string field_name = UnderscoresToCamelCase(field->name(), true);
|
||||
string result = "k" + field_name + "FieldNumber";
|
||||
|
||||
if (!field->is_extension() &&
|
||||
field->containing_type()->FindFieldByCamelcaseName(
|
||||
field->camelcase_name()) != field) {
|
||||
// This field's camelcase name is not unique. As a hack, add the field
|
||||
// number to the constant name. This makes the constant rather useless,
|
||||
// but what can we do?
|
||||
result += "_" + SimpleItoa(field->number());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
string FieldMessageTypeName(const FieldDescriptor* field) {
|
||||
// Note: The Google-internal version of Protocol Buffers uses this function
|
||||
// as a hook point for hacks to support legacy code.
|
||||
return ClassName(field->message_type(), true);
|
||||
}
|
||||
|
||||
string StripProto(const string& filename) {
|
||||
if (HasSuffixString(filename, ".protodevel")) {
|
||||
return StripSuffixString(filename, ".protodevel");
|
||||
} else {
|
||||
return StripSuffixString(filename, ".proto");
|
||||
}
|
||||
}
|
||||
|
||||
const char* PrimitiveTypeName(FieldDescriptor::CppType type) {
|
||||
switch (type) {
|
||||
case FieldDescriptor::CPPTYPE_INT32 : return "::google::protobuf::int32";
|
||||
case FieldDescriptor::CPPTYPE_INT64 : return "::google::protobuf::int64";
|
||||
case FieldDescriptor::CPPTYPE_UINT32 : return "::google::protobuf::uint32";
|
||||
case FieldDescriptor::CPPTYPE_UINT64 : return "::google::protobuf::uint64";
|
||||
case FieldDescriptor::CPPTYPE_DOUBLE : return "double";
|
||||
case FieldDescriptor::CPPTYPE_FLOAT : return "float";
|
||||
case FieldDescriptor::CPPTYPE_BOOL : return "bool";
|
||||
case FieldDescriptor::CPPTYPE_ENUM : return "int";
|
||||
case FieldDescriptor::CPPTYPE_STRING : return "::std::string";
|
||||
case FieldDescriptor::CPPTYPE_MESSAGE: return NULL;
|
||||
|
||||
// No default because we want the compiler to complain if any new
|
||||
// CppTypes are added.
|
||||
}
|
||||
|
||||
GOOGLE_LOG(FATAL) << "Can't get here.";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* DeclaredTypeMethodName(FieldDescriptor::Type type) {
|
||||
switch (type) {
|
||||
case FieldDescriptor::TYPE_INT32 : return "Int32";
|
||||
case FieldDescriptor::TYPE_INT64 : return "Int64";
|
||||
case FieldDescriptor::TYPE_UINT32 : return "UInt32";
|
||||
case FieldDescriptor::TYPE_UINT64 : return "UInt64";
|
||||
case FieldDescriptor::TYPE_SINT32 : return "SInt32";
|
||||
case FieldDescriptor::TYPE_SINT64 : return "SInt64";
|
||||
case FieldDescriptor::TYPE_FIXED32 : return "Fixed32";
|
||||
case FieldDescriptor::TYPE_FIXED64 : return "Fixed64";
|
||||
case FieldDescriptor::TYPE_SFIXED32: return "SFixed32";
|
||||
case FieldDescriptor::TYPE_SFIXED64: return "SFixed64";
|
||||
case FieldDescriptor::TYPE_FLOAT : return "Float";
|
||||
case FieldDescriptor::TYPE_DOUBLE : return "Double";
|
||||
|
||||
case FieldDescriptor::TYPE_BOOL : return "Bool";
|
||||
case FieldDescriptor::TYPE_ENUM : return "Enum";
|
||||
|
||||
case FieldDescriptor::TYPE_STRING : return "String";
|
||||
case FieldDescriptor::TYPE_BYTES : return "Bytes";
|
||||
case FieldDescriptor::TYPE_GROUP : return "Group";
|
||||
case FieldDescriptor::TYPE_MESSAGE : return "Message";
|
||||
|
||||
// No default because we want the compiler to complain if any new
|
||||
// types are added.
|
||||
}
|
||||
GOOGLE_LOG(FATAL) << "Can't get here.";
|
||||
return "";
|
||||
}
|
||||
|
||||
string Int32ToString(int number) {
|
||||
// gcc rejects the decimal form of kint32min.
|
||||
if (number == kint32min) {
|
||||
GOOGLE_COMPILE_ASSERT(kint32min == (~0x7fffffff), kint32min_value_error);
|
||||
return "(~0x7fffffff)";
|
||||
} else {
|
||||
return SimpleItoa(number);
|
||||
}
|
||||
}
|
||||
|
||||
string Int64ToString(int64 number) {
|
||||
// gcc rejects the decimal form of kint64min
|
||||
if (number == kint64min) {
|
||||
// Make sure we are in a 2's complement system.
|
||||
GOOGLE_COMPILE_ASSERT(kint64min == GOOGLE_LONGLONG(~0x7fffffffffffffff),
|
||||
kint64min_value_error);
|
||||
return "GOOGLE_LONGLONG(~0x7fffffffffffffff)";
|
||||
}
|
||||
return "GOOGLE_LONGLONG(" + SimpleItoa(number) + ")";
|
||||
}
|
||||
|
||||
string DefaultValue(const FieldDescriptor* field) {
|
||||
switch (field->cpp_type()) {
|
||||
case FieldDescriptor::CPPTYPE_INT32:
|
||||
return Int32ToString(field->default_value_int32());
|
||||
case FieldDescriptor::CPPTYPE_UINT32:
|
||||
return SimpleItoa(field->default_value_uint32()) + "u";
|
||||
case FieldDescriptor::CPPTYPE_INT64:
|
||||
return Int64ToString(field->default_value_int64());
|
||||
case FieldDescriptor::CPPTYPE_UINT64:
|
||||
return "GOOGLE_ULONGLONG(" + SimpleItoa(field->default_value_uint64())+ ")";
|
||||
case FieldDescriptor::CPPTYPE_DOUBLE: {
|
||||
double value = field->default_value_double();
|
||||
if (value == numeric_limits<double>::infinity()) {
|
||||
return "::google::protobuf::internal::Infinity()";
|
||||
} else if (value == -numeric_limits<double>::infinity()) {
|
||||
return "-::google::protobuf::internal::Infinity()";
|
||||
} else if (value != value) {
|
||||
return "::google::protobuf::internal::NaN()";
|
||||
} else {
|
||||
return SimpleDtoa(value);
|
||||
}
|
||||
}
|
||||
case FieldDescriptor::CPPTYPE_FLOAT:
|
||||
{
|
||||
float value = field->default_value_float();
|
||||
if (value == numeric_limits<float>::infinity()) {
|
||||
return "static_cast<float>(::google::protobuf::internal::Infinity())";
|
||||
} else if (value == -numeric_limits<float>::infinity()) {
|
||||
return "static_cast<float>(-::google::protobuf::internal::Infinity())";
|
||||
} else if (value != value) {
|
||||
return "static_cast<float>(::google::protobuf::internal::NaN())";
|
||||
} else {
|
||||
string float_value = SimpleFtoa(value);
|
||||
// If floating point value contains a period (.) or an exponent
|
||||
// (either E or e), then append suffix 'f' to make it a float
|
||||
// literal.
|
||||
if (float_value.find_first_of(".eE") != string::npos) {
|
||||
float_value.push_back('f');
|
||||
}
|
||||
return float_value;
|
||||
}
|
||||
}
|
||||
case FieldDescriptor::CPPTYPE_BOOL:
|
||||
return field->default_value_bool() ? "true" : "false";
|
||||
case FieldDescriptor::CPPTYPE_ENUM:
|
||||
// Lazy: Generate a static_cast because we don't have a helper function
|
||||
// that constructs the full name of an enum value.
|
||||
return strings::Substitute(
|
||||
"static_cast< $0 >($1)",
|
||||
ClassName(field->enum_type(), true),
|
||||
Int32ToString(field->default_value_enum()->number()));
|
||||
case FieldDescriptor::CPPTYPE_STRING:
|
||||
return "\"" + EscapeTrigraphs(
|
||||
CEscape(field->default_value_string())) +
|
||||
"\"";
|
||||
case FieldDescriptor::CPPTYPE_MESSAGE:
|
||||
return FieldMessageTypeName(field) + "::default_instance()";
|
||||
}
|
||||
// Can't actually get here; make compiler happy. (We could add a default
|
||||
// case above but then we wouldn't get the nice compiler warning when a
|
||||
// new type is added.)
|
||||
GOOGLE_LOG(FATAL) << "Can't get here.";
|
||||
return "";
|
||||
}
|
||||
|
||||
// Convert a file name into a valid identifier.
|
||||
string FilenameIdentifier(const string& filename) {
|
||||
string result;
|
||||
for (int i = 0; i < filename.size(); i++) {
|
||||
if (ascii_isalnum(filename[i])) {
|
||||
result.push_back(filename[i]);
|
||||
} else {
|
||||
// Not alphanumeric. To avoid any possibility of name conflicts we
|
||||
// use the hex code for the character.
|
||||
result.push_back('_');
|
||||
char buffer[kFastToBufferSize];
|
||||
result.append(FastHexToBuffer(static_cast<uint8>(filename[i]), buffer));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Return the name of the AddDescriptors() function for a given file.
|
||||
string GlobalAddDescriptorsName(const string& filename) {
|
||||
return "protobuf_AddDesc_" + FilenameIdentifier(filename);
|
||||
}
|
||||
|
||||
// Return the name of the AssignDescriptors() function for a given file.
|
||||
string GlobalAssignDescriptorsName(const string& filename) {
|
||||
return "protobuf_AssignDesc_" + FilenameIdentifier(filename);
|
||||
}
|
||||
|
||||
// Return the name of the ShutdownFile() function for a given file.
|
||||
string GlobalShutdownFileName(const string& filename) {
|
||||
return "protobuf_ShutdownFile_" + FilenameIdentifier(filename);
|
||||
}
|
||||
|
||||
// Return the qualified C++ name for a file level symbol.
|
||||
string QualifiedFileLevelSymbol(const string& package, const string& name) {
|
||||
if (package.empty()) {
|
||||
return StrCat("::", name);
|
||||
}
|
||||
return StrCat("::", DotsToColons(package), "::", name);
|
||||
}
|
||||
|
||||
// Escape C++ trigraphs by escaping question marks to \?
|
||||
string EscapeTrigraphs(const string& to_escape) {
|
||||
return StringReplace(to_escape, "?", "\\?", true);
|
||||
}
|
||||
|
||||
// Escaped function name to eliminate naming conflict.
|
||||
string SafeFunctionName(const Descriptor* descriptor,
|
||||
const FieldDescriptor* field,
|
||||
const string& prefix) {
|
||||
// Do not use FieldName() since it will escape keywords.
|
||||
string name = field->name();
|
||||
LowerString(&name);
|
||||
string function_name = prefix + name;
|
||||
if (descriptor->FindFieldByName(function_name)) {
|
||||
// Single underscore will also make it conflicting with the private data
|
||||
// member. We use double underscore to escape function names.
|
||||
function_name.append("__");
|
||||
} else if (kKeywords.count(name) > 0) {
|
||||
// If the field name is a keyword, we append the underscore back to keep it
|
||||
// consistent with other function names.
|
||||
function_name.append("_");
|
||||
}
|
||||
return function_name;
|
||||
}
|
||||
|
||||
bool StaticInitializersForced(const FileDescriptor* file) {
|
||||
if (HasDescriptorMethods(file) || file->extension_count() > 0) {
|
||||
return true;
|
||||
}
|
||||
for (int i = 0; i < file->message_type_count(); ++i) {
|
||||
if (HasExtension(file->message_type(i))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void PrintHandlingOptionalStaticInitializers(
|
||||
const FileDescriptor* file, io::Printer* printer,
|
||||
const char* with_static_init, const char* without_static_init,
|
||||
const char* var1, const string& val1,
|
||||
const char* var2, const string& val2) {
|
||||
map<string, string> vars;
|
||||
if (var1) {
|
||||
vars[var1] = val1;
|
||||
}
|
||||
if (var2) {
|
||||
vars[var2] = val2;
|
||||
}
|
||||
PrintHandlingOptionalStaticInitializers(
|
||||
vars, file, printer, with_static_init, without_static_init);
|
||||
}
|
||||
|
||||
void PrintHandlingOptionalStaticInitializers(
|
||||
const map<string, string>& vars, const FileDescriptor* file,
|
||||
io::Printer* printer, const char* with_static_init,
|
||||
const char* without_static_init) {
|
||||
if (StaticInitializersForced(file)) {
|
||||
printer->Print(vars, with_static_init);
|
||||
} else {
|
||||
printer->Print(vars, (string(
|
||||
"#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n") +
|
||||
without_static_init +
|
||||
"#else\n" +
|
||||
with_static_init +
|
||||
"#endif\n").c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static bool HasEnumDefinitions(const Descriptor* message_type) {
|
||||
if (message_type->enum_type_count() > 0) return true;
|
||||
for (int i = 0; i < message_type->nested_type_count(); ++i) {
|
||||
if (HasEnumDefinitions(message_type->nested_type(i))) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HasEnumDefinitions(const FileDescriptor* file) {
|
||||
if (file->enum_type_count() > 0) return true;
|
||||
for (int i = 0; i < file->message_type_count(); ++i) {
|
||||
if (HasEnumDefinitions(file->message_type(i))) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsStringOrMessage(const FieldDescriptor* field) {
|
||||
switch (field->cpp_type()) {
|
||||
case FieldDescriptor::CPPTYPE_INT32:
|
||||
case FieldDescriptor::CPPTYPE_INT64:
|
||||
case FieldDescriptor::CPPTYPE_UINT32:
|
||||
case FieldDescriptor::CPPTYPE_UINT64:
|
||||
case FieldDescriptor::CPPTYPE_DOUBLE:
|
||||
case FieldDescriptor::CPPTYPE_FLOAT:
|
||||
case FieldDescriptor::CPPTYPE_BOOL:
|
||||
case FieldDescriptor::CPPTYPE_ENUM:
|
||||
return false;
|
||||
case FieldDescriptor::CPPTYPE_STRING:
|
||||
case FieldDescriptor::CPPTYPE_MESSAGE:
|
||||
return true;
|
||||
}
|
||||
|
||||
GOOGLE_LOG(FATAL) << "Can't get here.";
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
@@ -1,206 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include <google/protobuf/descriptor.pb.h>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
namespace io {
|
||||
class Printer;
|
||||
}
|
||||
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
// Commonly-used separator comments. Thick is a line of '=', thin is a line
|
||||
// of '-'.
|
||||
extern const char kThickSeparator[];
|
||||
extern const char kThinSeparator[];
|
||||
|
||||
// Returns the non-nested type name for the given type. If "qualified" is
|
||||
// true, prefix the type with the full namespace. For example, if you had:
|
||||
// package foo.bar;
|
||||
// message Baz { message Qux {} }
|
||||
// Then the qualified ClassName for Qux would be:
|
||||
// ::foo::bar::Baz_Qux
|
||||
// While the non-qualified version would be:
|
||||
// Baz_Qux
|
||||
string ClassName(const Descriptor* descriptor, bool qualified);
|
||||
string ClassName(const EnumDescriptor* enum_descriptor, bool qualified);
|
||||
|
||||
string SuperClassName(const Descriptor* descriptor);
|
||||
|
||||
// Get the (unqualified) name that should be used for this field in C++ code.
|
||||
// The name is coerced to lower-case to emulate proto1 behavior. People
|
||||
// should be using lowercase-with-underscores style for proto field names
|
||||
// anyway, so normally this just returns field->name().
|
||||
string FieldName(const FieldDescriptor* field);
|
||||
|
||||
// Get the unqualified name that should be used for a field's field
|
||||
// number constant.
|
||||
string FieldConstantName(const FieldDescriptor *field);
|
||||
|
||||
// Returns the scope where the field was defined (for extensions, this is
|
||||
// different from the message type to which the field applies).
|
||||
inline const Descriptor* FieldScope(const FieldDescriptor* field) {
|
||||
return field->is_extension() ?
|
||||
field->extension_scope() : field->containing_type();
|
||||
}
|
||||
|
||||
// Returns the fully-qualified type name field->message_type(). Usually this
|
||||
// is just ClassName(field->message_type(), true);
|
||||
string FieldMessageTypeName(const FieldDescriptor* field);
|
||||
|
||||
// Strips ".proto" or ".protodevel" from the end of a filename.
|
||||
string StripProto(const string& filename);
|
||||
|
||||
// Get the C++ type name for a primitive type (e.g. "double", "::google::protobuf::int32", etc.).
|
||||
// Note: non-built-in type names will be qualified, meaning they will start
|
||||
// with a ::. If you are using the type as a template parameter, you will
|
||||
// need to insure there is a space between the < and the ::, because the
|
||||
// ridiculous C++ standard defines "<:" to be a synonym for "[".
|
||||
const char* PrimitiveTypeName(FieldDescriptor::CppType type);
|
||||
|
||||
// Get the declared type name in CamelCase format, as is used e.g. for the
|
||||
// methods of WireFormat. For example, TYPE_INT32 becomes "Int32".
|
||||
const char* DeclaredTypeMethodName(FieldDescriptor::Type type);
|
||||
|
||||
// Return the code that evaluates to the number when compiled.
|
||||
string Int32ToString(int number);
|
||||
|
||||
// Return the code that evaluates to the number when compiled.
|
||||
string Int64ToString(int64 number);
|
||||
|
||||
// Get code that evaluates to the field's default value.
|
||||
string DefaultValue(const FieldDescriptor* field);
|
||||
|
||||
// Convert a file name into a valid identifier.
|
||||
string FilenameIdentifier(const string& filename);
|
||||
|
||||
// Return the name of the AddDescriptors() function for a given file.
|
||||
string GlobalAddDescriptorsName(const string& filename);
|
||||
|
||||
// Return the name of the AssignDescriptors() function for a given file.
|
||||
string GlobalAssignDescriptorsName(const string& filename);
|
||||
|
||||
// Return the qualified C++ name for a file level symbol.
|
||||
string QualifiedFileLevelSymbol(const string& package, const string& name);
|
||||
|
||||
// Return the name of the ShutdownFile() function for a given file.
|
||||
string GlobalShutdownFileName(const string& filename);
|
||||
|
||||
// Escape C++ trigraphs by escaping question marks to \?
|
||||
string EscapeTrigraphs(const string& to_escape);
|
||||
|
||||
// Escaped function name to eliminate naming conflict.
|
||||
string SafeFunctionName(const Descriptor* descriptor,
|
||||
const FieldDescriptor* field,
|
||||
const string& prefix);
|
||||
|
||||
// Do message classes in this file use UnknownFieldSet?
|
||||
// Otherwise, messages will store unknown fields in a string
|
||||
inline bool UseUnknownFieldSet(const FileDescriptor* file) {
|
||||
return file->options().optimize_for() != FileOptions::LITE_RUNTIME;
|
||||
}
|
||||
|
||||
|
||||
// Does this file have any enum type definitions?
|
||||
bool HasEnumDefinitions(const FileDescriptor* file);
|
||||
|
||||
// Does this file have generated parsing, serialization, and other
|
||||
// standard methods for which reflection-based fallback implementations exist?
|
||||
inline bool HasGeneratedMethods(const FileDescriptor* file) {
|
||||
return file->options().optimize_for() != FileOptions::CODE_SIZE;
|
||||
}
|
||||
|
||||
// Do message classes in this file have descriptor and reflection methods?
|
||||
inline bool HasDescriptorMethods(const FileDescriptor* file) {
|
||||
return file->options().optimize_for() != FileOptions::LITE_RUNTIME;
|
||||
}
|
||||
|
||||
// Should we generate generic services for this file?
|
||||
inline bool HasGenericServices(const FileDescriptor* file) {
|
||||
return file->service_count() > 0 &&
|
||||
file->options().optimize_for() != FileOptions::LITE_RUNTIME &&
|
||||
file->options().cc_generic_services();
|
||||
}
|
||||
|
||||
// Should string fields in this file verify that their contents are UTF-8?
|
||||
inline bool HasUtf8Verification(const FileDescriptor* file) {
|
||||
return file->options().optimize_for() != FileOptions::LITE_RUNTIME;
|
||||
}
|
||||
|
||||
// Should we generate a separate, super-optimized code path for serializing to
|
||||
// flat arrays? We don't do this in Lite mode because we'd rather reduce code
|
||||
// size.
|
||||
inline bool HasFastArraySerialization(const FileDescriptor* file) {
|
||||
return file->options().optimize_for() == FileOptions::SPEED;
|
||||
}
|
||||
|
||||
// Returns whether we have to generate code with static initializers.
|
||||
bool StaticInitializersForced(const FileDescriptor* file);
|
||||
|
||||
// Prints 'with_static_init' if static initializers have to be used for the
|
||||
// provided file. Otherwise emits both 'with_static_init' and
|
||||
// 'without_static_init' using #ifdef.
|
||||
void PrintHandlingOptionalStaticInitializers(
|
||||
const FileDescriptor* file, io::Printer* printer,
|
||||
const char* with_static_init, const char* without_static_init,
|
||||
const char* var1 = NULL, const string& val1 = "",
|
||||
const char* var2 = NULL, const string& val2 = "");
|
||||
|
||||
void PrintHandlingOptionalStaticInitializers(
|
||||
const map<string, string>& vars, const FileDescriptor* file,
|
||||
io::Printer* printer, const char* with_static_init,
|
||||
const char* without_static_init);
|
||||
|
||||
|
||||
// Returns true if the field's CPPTYPE is string or message.
|
||||
bool IsStringOrMessage(const FieldDescriptor* field);
|
||||
|
||||
string UnderscoresToCamelCase(const string& input, bool cap_next_letter);
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,175 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "google/protobuf/compiler/cpp/cpp_field.h"
|
||||
#include "google/protobuf/compiler/cpp/cpp_options.h"
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace io {
|
||||
class Printer; // printer.h
|
||||
}
|
||||
}
|
||||
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
class EnumGenerator; // enum.h
|
||||
class ExtensionGenerator; // extension.h
|
||||
|
||||
class MessageGenerator {
|
||||
public:
|
||||
// See generator.cc for the meaning of dllexport_decl.
|
||||
explicit MessageGenerator(const Descriptor* descriptor,
|
||||
const Options& options);
|
||||
~MessageGenerator();
|
||||
|
||||
// Header stuff.
|
||||
|
||||
// Generate foward declarations for this class and all its nested types.
|
||||
void GenerateForwardDeclaration(io::Printer* printer);
|
||||
|
||||
// Generate definitions of all nested enums (must come before class
|
||||
// definitions because those classes use the enums definitions).
|
||||
void GenerateEnumDefinitions(io::Printer* printer);
|
||||
|
||||
// Generate specializations of GetEnumDescriptor<MyEnum>().
|
||||
// Precondition: in ::google::protobuf namespace.
|
||||
void GenerateGetEnumDescriptorSpecializations(io::Printer* printer);
|
||||
|
||||
// Generate definitions for this class and all its nested types.
|
||||
void GenerateClassDefinition(io::Printer* printer);
|
||||
|
||||
// Generate definitions of inline methods (placed at the end of the header
|
||||
// file).
|
||||
void GenerateInlineMethods(io::Printer* printer);
|
||||
|
||||
// Source file stuff.
|
||||
|
||||
// Generate code which declares all the global descriptor pointers which
|
||||
// will be initialized by the methods below.
|
||||
void GenerateDescriptorDeclarations(io::Printer* printer);
|
||||
|
||||
// Generate code that initializes the global variable storing the message's
|
||||
// descriptor.
|
||||
void GenerateDescriptorInitializer(io::Printer* printer, int index);
|
||||
|
||||
// Generate code that calls MessageFactory::InternalRegisterGeneratedMessage()
|
||||
// for all types.
|
||||
void GenerateTypeRegistrations(io::Printer* printer);
|
||||
|
||||
// Generates code that allocates the message's default instance.
|
||||
void GenerateDefaultInstanceAllocator(io::Printer* printer);
|
||||
|
||||
// Generates code that initializes the message's default instance. This
|
||||
// is separate from allocating because all default instances must be
|
||||
// allocated before any can be initialized.
|
||||
void GenerateDefaultInstanceInitializer(io::Printer* printer);
|
||||
|
||||
// Generates code that should be run when ShutdownProtobufLibrary() is called,
|
||||
// to delete all dynamically-allocated objects.
|
||||
void GenerateShutdownCode(io::Printer* printer);
|
||||
|
||||
// Generate all non-inline methods for this class.
|
||||
void GenerateClassMethods(io::Printer* printer);
|
||||
|
||||
private:
|
||||
// Generate declarations and definitions of accessors for fields.
|
||||
void GenerateFieldAccessorDeclarations(io::Printer* printer);
|
||||
void GenerateFieldAccessorDefinitions(io::Printer* printer);
|
||||
|
||||
// Generate the field offsets array.
|
||||
void GenerateOffsets(io::Printer* printer);
|
||||
|
||||
// Generate constructors and destructor.
|
||||
void GenerateStructors(io::Printer* printer);
|
||||
|
||||
// The compiler typically generates multiple copies of each constructor and
|
||||
// destructor: http://gcc.gnu.org/bugs.html#nonbugs_cxx
|
||||
// Placing common code in a separate method reduces the generated code size.
|
||||
//
|
||||
// Generate the shared constructor code.
|
||||
void GenerateSharedConstructorCode(io::Printer* printer);
|
||||
// Generate the shared destructor code.
|
||||
void GenerateSharedDestructorCode(io::Printer* printer);
|
||||
|
||||
// Generate standard Message methods.
|
||||
void GenerateClear(io::Printer* printer);
|
||||
void GenerateOneofClear(io::Printer* printer);
|
||||
void GenerateMergeFromCodedStream(io::Printer* printer);
|
||||
void GenerateSerializeWithCachedSizes(io::Printer* printer);
|
||||
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer);
|
||||
void GenerateSerializeWithCachedSizesBody(io::Printer* printer,
|
||||
bool to_array);
|
||||
void GenerateByteSize(io::Printer* printer);
|
||||
void GenerateMergeFrom(io::Printer* printer);
|
||||
void GenerateCopyFrom(io::Printer* printer);
|
||||
void GenerateSwap(io::Printer* printer);
|
||||
void GenerateIsInitialized(io::Printer* printer);
|
||||
|
||||
// Helpers for GenerateSerializeWithCachedSizes().
|
||||
void GenerateSerializeOneField(io::Printer* printer,
|
||||
const FieldDescriptor* field,
|
||||
bool unbounded);
|
||||
void GenerateSerializeOneExtensionRange(
|
||||
io::Printer* printer, const Descriptor::ExtensionRange* range,
|
||||
bool unbounded);
|
||||
|
||||
|
||||
const Descriptor* descriptor_;
|
||||
string classname_;
|
||||
Options options_;
|
||||
FieldGeneratorMap field_generators_;
|
||||
vector< vector<string> > runs_of_fields_; // that might be trivially cleared
|
||||
scoped_array<scoped_ptr<MessageGenerator> > nested_generators_;
|
||||
scoped_array<scoped_ptr<EnumGenerator> > enum_generators_;
|
||||
scoped_array<scoped_ptr<ExtensionGenerator> > extension_generators_;
|
||||
bool uses_string_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
|
||||
};
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__
|
||||
@@ -1,375 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#include "google/protobuf/compiler/cpp/cpp_message_field.h"
|
||||
#include "google/protobuf/compiler/cpp/cpp_helpers.h"
|
||||
#include <google/protobuf/io/printer.h>
|
||||
#include "google/protobuf/stubs/strutil.h"
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
namespace {
|
||||
|
||||
void SetMessageVariables(const FieldDescriptor* descriptor,
|
||||
map<string, string>* variables,
|
||||
const Options& options) {
|
||||
SetCommonFieldVariables(descriptor, variables, options);
|
||||
(*variables)["type"] = FieldMessageTypeName(descriptor);
|
||||
(*variables)["stream_writer"] = (*variables)["declared_type"] +
|
||||
(HasFastArraySerialization(descriptor->message_type()->file()) ?
|
||||
"MaybeToArray" :
|
||||
"");
|
||||
// NOTE: Escaped here to unblock proto1->proto2 migration.
|
||||
// TODO(liujisi): Extend this to apply for other conflicting methods.
|
||||
(*variables)["release_name"] =
|
||||
SafeFunctionName(descriptor->containing_type(),
|
||||
descriptor, "release_");
|
||||
(*variables)["full_name"] = descriptor->full_name();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// ===================================================================
|
||||
|
||||
MessageFieldGenerator::
|
||||
MessageFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options)
|
||||
: descriptor_(descriptor) {
|
||||
SetMessageVariables(descriptor, &variables_, options);
|
||||
}
|
||||
|
||||
MessageFieldGenerator::~MessageFieldGenerator() {}
|
||||
|
||||
void MessageFieldGenerator::
|
||||
GeneratePrivateMembers(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$type$* $name$_;\n");
|
||||
}
|
||||
|
||||
void MessageFieldGenerator::
|
||||
GenerateAccessorDeclarations(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline const $type$& $name$() const$deprecation$;\n"
|
||||
"inline $type$* mutable_$name$()$deprecation$;\n"
|
||||
"inline $type$* $release_name$()$deprecation$;\n"
|
||||
"inline void set_allocated_$name$($type$* $name$)$deprecation$;\n");
|
||||
}
|
||||
|
||||
void MessageFieldGenerator::
|
||||
GenerateInlineAccessorDefinitions(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline const $type$& $classname$::$name$() const {\n"
|
||||
" // @@protoc_insertion_point(field_get:$full_name$)\n");
|
||||
|
||||
PrintHandlingOptionalStaticInitializers(
|
||||
variables_, descriptor_->file(), printer,
|
||||
// With static initializers.
|
||||
" return $name$_ != NULL ? *$name$_ : *default_instance_->$name$_;\n",
|
||||
// Without.
|
||||
" return $name$_ != NULL ? *$name$_ : *default_instance().$name$_;\n");
|
||||
|
||||
printer->Print(variables_,
|
||||
"}\n"
|
||||
"inline $type$* $classname$::mutable_$name$() {\n"
|
||||
" set_has_$name$();\n"
|
||||
" if ($name$_ == NULL) $name$_ = new $type$;\n"
|
||||
" // @@protoc_insertion_point(field_mutable:$full_name$)\n"
|
||||
" return $name$_;\n"
|
||||
"}\n"
|
||||
"inline $type$* $classname$::$release_name$() {\n"
|
||||
" clear_has_$name$();\n"
|
||||
" $type$* temp = $name$_;\n"
|
||||
" $name$_ = NULL;\n"
|
||||
" return temp;\n"
|
||||
"}\n"
|
||||
"inline void $classname$::set_allocated_$name$($type$* $name$) {\n"
|
||||
" delete $name$_;\n"
|
||||
" $name$_ = $name$;\n"
|
||||
" if ($name$) {\n"
|
||||
" set_has_$name$();\n"
|
||||
" } else {\n"
|
||||
" clear_has_$name$();\n"
|
||||
" }\n"
|
||||
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void MessageFieldGenerator::
|
||||
GenerateClearingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"if ($name$_ != NULL) $name$_->$type$::Clear();\n");
|
||||
}
|
||||
|
||||
void MessageFieldGenerator::
|
||||
GenerateMergingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"mutable_$name$()->$type$::MergeFrom(from.$name$());\n");
|
||||
}
|
||||
|
||||
void MessageFieldGenerator::
|
||||
GenerateSwappingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "std::swap($name$_, other->$name$_);\n");
|
||||
}
|
||||
|
||||
void MessageFieldGenerator::
|
||||
GenerateConstructorCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$name$_ = NULL;\n");
|
||||
}
|
||||
|
||||
void MessageFieldGenerator::
|
||||
GenerateMergeFromCodedStream(io::Printer* printer) const {
|
||||
if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) {
|
||||
printer->Print(variables_,
|
||||
"DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n"
|
||||
" input, mutable_$name$()));\n");
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
"DO_(::google::protobuf::internal::WireFormatLite::ReadGroupNoVirtual(\n"
|
||||
" $number$, input, mutable_$name$()));\n");
|
||||
}
|
||||
}
|
||||
|
||||
void MessageFieldGenerator::
|
||||
GenerateSerializeWithCachedSizes(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"::google::protobuf::internal::WireFormatLite::Write$stream_writer$(\n"
|
||||
" $number$, this->$name$(), output);\n");
|
||||
}
|
||||
|
||||
void MessageFieldGenerator::
|
||||
GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"target = ::google::protobuf::internal::WireFormatLite::\n"
|
||||
" Write$declared_type$NoVirtualToArray(\n"
|
||||
" $number$, this->$name$(), target);\n");
|
||||
}
|
||||
|
||||
void MessageFieldGenerator::
|
||||
GenerateByteSize(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"total_size += $tag_size$ +\n"
|
||||
" ::google::protobuf::internal::WireFormatLite::$declared_type$SizeNoVirtual(\n"
|
||||
" this->$name$());\n");
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
MessageOneofFieldGenerator::
|
||||
MessageOneofFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options)
|
||||
: MessageFieldGenerator(descriptor, options) {
|
||||
SetCommonOneofFieldVariables(descriptor, &variables_);
|
||||
}
|
||||
|
||||
MessageOneofFieldGenerator::~MessageOneofFieldGenerator() {}
|
||||
|
||||
void MessageOneofFieldGenerator::
|
||||
GenerateInlineAccessorDefinitions(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline const $type$& $classname$::$name$() const {\n"
|
||||
" return has_$name$() ? *$oneof_prefix$$name$_\n"
|
||||
" : $type$::default_instance();\n"
|
||||
"}\n"
|
||||
"inline $type$* $classname$::mutable_$name$() {\n"
|
||||
" if (!has_$name$()) {\n"
|
||||
" clear_$oneof_name$();\n"
|
||||
" set_has_$name$();\n"
|
||||
" $oneof_prefix$$name$_ = new $type$;\n"
|
||||
" }\n"
|
||||
" return $oneof_prefix$$name$_;\n"
|
||||
"}\n"
|
||||
"inline $type$* $classname$::$release_name$() {\n"
|
||||
" if (has_$name$()) {\n"
|
||||
" clear_has_$oneof_name$();\n"
|
||||
" $type$* temp = $oneof_prefix$$name$_;\n"
|
||||
" $oneof_prefix$$name$_ = NULL;\n"
|
||||
" return temp;\n"
|
||||
" } else {\n"
|
||||
" return NULL;\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"inline void $classname$::set_allocated_$name$($type$* $name$) {\n"
|
||||
" clear_$oneof_name$();\n"
|
||||
" if ($name$) {\n"
|
||||
" set_has_$name$();\n"
|
||||
" $oneof_prefix$$name$_ = $name$;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void MessageOneofFieldGenerator::
|
||||
GenerateClearingCode(io::Printer* printer) const {
|
||||
// if it is the active field, it cannot be NULL.
|
||||
printer->Print(variables_,
|
||||
"delete $oneof_prefix$$name$_;\n");
|
||||
}
|
||||
|
||||
void MessageOneofFieldGenerator::
|
||||
GenerateSwappingCode(io::Printer* printer) const {
|
||||
// Don't print any swapping code. Swapping the union will swap this field.
|
||||
}
|
||||
|
||||
void MessageOneofFieldGenerator::
|
||||
GenerateConstructorCode(io::Printer* printer) const {
|
||||
// Don't print any constructor code. The field is in a union. We allocate
|
||||
// space only when this field is used.
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
RepeatedMessageFieldGenerator::
|
||||
RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options)
|
||||
: descriptor_(descriptor) {
|
||||
SetMessageVariables(descriptor, &variables_, options);
|
||||
}
|
||||
|
||||
RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {}
|
||||
|
||||
void RepeatedMessageFieldGenerator::
|
||||
GeneratePrivateMembers(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"::google::protobuf::RepeatedPtrField< $type$ > $name$_;\n");
|
||||
}
|
||||
|
||||
void RepeatedMessageFieldGenerator::
|
||||
GenerateAccessorDeclarations(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline const $type$& $name$(int index) const$deprecation$;\n"
|
||||
"inline $type$* mutable_$name$(int index)$deprecation$;\n"
|
||||
"inline $type$* add_$name$()$deprecation$;\n");
|
||||
printer->Print(variables_,
|
||||
"inline const ::google::protobuf::RepeatedPtrField< $type$ >&\n"
|
||||
" $name$() const$deprecation$;\n"
|
||||
"inline ::google::protobuf::RepeatedPtrField< $type$ >*\n"
|
||||
" mutable_$name$()$deprecation$;\n");
|
||||
}
|
||||
|
||||
void RepeatedMessageFieldGenerator::
|
||||
GenerateInlineAccessorDefinitions(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline const $type$& $classname$::$name$(int index) const {\n"
|
||||
" // @@protoc_insertion_point(field_get:$full_name$)\n"
|
||||
" return $name$_.$cppget$(index);\n"
|
||||
"}\n"
|
||||
"inline $type$* $classname$::mutable_$name$(int index) {\n"
|
||||
" // @@protoc_insertion_point(field_mutable:$full_name$)\n"
|
||||
" return $name$_.Mutable(index);\n"
|
||||
"}\n"
|
||||
"inline $type$* $classname$::add_$name$() {\n"
|
||||
" // @@protoc_insertion_point(field_add:$full_name$)\n"
|
||||
" return $name$_.Add();\n"
|
||||
"}\n");
|
||||
printer->Print(variables_,
|
||||
"inline const ::google::protobuf::RepeatedPtrField< $type$ >&\n"
|
||||
"$classname$::$name$() const {\n"
|
||||
" // @@protoc_insertion_point(field_list:$full_name$)\n"
|
||||
" return $name$_;\n"
|
||||
"}\n"
|
||||
"inline ::google::protobuf::RepeatedPtrField< $type$ >*\n"
|
||||
"$classname$::mutable_$name$() {\n"
|
||||
" // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
|
||||
" return &$name$_;\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void RepeatedMessageFieldGenerator::
|
||||
GenerateClearingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$name$_.Clear();\n");
|
||||
}
|
||||
|
||||
void RepeatedMessageFieldGenerator::
|
||||
GenerateMergingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$name$_.MergeFrom(from.$name$_);\n");
|
||||
}
|
||||
|
||||
void RepeatedMessageFieldGenerator::
|
||||
GenerateSwappingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$name$_.Swap(&other->$name$_);\n");
|
||||
}
|
||||
|
||||
void RepeatedMessageFieldGenerator::
|
||||
GenerateConstructorCode(io::Printer* printer) const {
|
||||
// Not needed for repeated fields.
|
||||
}
|
||||
|
||||
void RepeatedMessageFieldGenerator::
|
||||
GenerateMergeFromCodedStream(io::Printer* printer) const {
|
||||
if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) {
|
||||
printer->Print(variables_,
|
||||
"DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n"
|
||||
" input, add_$name$()));\n");
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
"DO_(::google::protobuf::internal::WireFormatLite::ReadGroupNoVirtual(\n"
|
||||
" $number$, input, add_$name$()));\n");
|
||||
}
|
||||
}
|
||||
|
||||
void RepeatedMessageFieldGenerator::
|
||||
GenerateSerializeWithCachedSizes(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"for (int i = 0; i < this->$name$_size(); i++) {\n"
|
||||
" ::google::protobuf::internal::WireFormatLite::Write$stream_writer$(\n"
|
||||
" $number$, this->$name$(i), output);\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void RepeatedMessageFieldGenerator::
|
||||
GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"for (int i = 0; i < this->$name$_size(); i++) {\n"
|
||||
" target = ::google::protobuf::internal::WireFormatLite::\n"
|
||||
" Write$declared_type$NoVirtualToArray(\n"
|
||||
" $number$, this->$name$(i), target);\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void RepeatedMessageFieldGenerator::
|
||||
GenerateByteSize(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"total_size += $tag_size$ * this->$name$_size();\n"
|
||||
"for (int i = 0; i < this->$name$_size(); i++) {\n"
|
||||
" total_size +=\n"
|
||||
" ::google::protobuf::internal::WireFormatLite::$declared_type$SizeNoVirtual(\n"
|
||||
" this->$name$(i));\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
@@ -1,121 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "google/protobuf/compiler/cpp/cpp_field.h"
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
class MessageFieldGenerator : public FieldGenerator {
|
||||
public:
|
||||
explicit MessageFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options);
|
||||
~MessageFieldGenerator();
|
||||
|
||||
// implements FieldGenerator ---------------------------------------
|
||||
void GeneratePrivateMembers(io::Printer* printer) const;
|
||||
void GenerateAccessorDeclarations(io::Printer* printer) const;
|
||||
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
|
||||
void GenerateClearingCode(io::Printer* printer) const;
|
||||
void GenerateMergingCode(io::Printer* printer) const;
|
||||
void GenerateSwappingCode(io::Printer* printer) const;
|
||||
void GenerateConstructorCode(io::Printer* printer) const;
|
||||
void GenerateMergeFromCodedStream(io::Printer* printer) const;
|
||||
void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
|
||||
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
|
||||
void GenerateByteSize(io::Printer* printer) const;
|
||||
|
||||
protected:
|
||||
const FieldDescriptor* descriptor_;
|
||||
map<string, string> variables_;
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator);
|
||||
};
|
||||
|
||||
class MessageOneofFieldGenerator : public MessageFieldGenerator {
|
||||
public:
|
||||
explicit MessageOneofFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options);
|
||||
~MessageOneofFieldGenerator();
|
||||
|
||||
// implements FieldGenerator ---------------------------------------
|
||||
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
|
||||
void GenerateClearingCode(io::Printer* printer) const;
|
||||
void GenerateSwappingCode(io::Printer* printer) const;
|
||||
void GenerateConstructorCode(io::Printer* printer) const;
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator);
|
||||
};
|
||||
|
||||
class RepeatedMessageFieldGenerator : public FieldGenerator {
|
||||
public:
|
||||
explicit RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options);
|
||||
~RepeatedMessageFieldGenerator();
|
||||
|
||||
// implements FieldGenerator ---------------------------------------
|
||||
void GeneratePrivateMembers(io::Printer* printer) const;
|
||||
void GenerateAccessorDeclarations(io::Printer* printer) const;
|
||||
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
|
||||
void GenerateClearingCode(io::Printer* printer) const;
|
||||
void GenerateMergingCode(io::Printer* printer) const;
|
||||
void GenerateSwappingCode(io::Printer* printer) const;
|
||||
void GenerateConstructorCode(io::Printer* printer) const;
|
||||
void GenerateMergeFromCodedStream(io::Printer* printer) const;
|
||||
void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
|
||||
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
|
||||
void GenerateByteSize(io::Printer* printer) const;
|
||||
|
||||
private:
|
||||
const FieldDescriptor* descriptor_;
|
||||
map<string, string> variables_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator);
|
||||
};
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__
|
||||
@@ -1,58 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Jeffrey Rennie)
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
// Generator options:
|
||||
struct Options {
|
||||
Options() : safe_boundary_check(false) {
|
||||
}
|
||||
string dllexport_decl;
|
||||
bool safe_boundary_check;
|
||||
};
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__
|
||||
@@ -1,453 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#include "google/protobuf/compiler/cpp/cpp_primitive_field.h"
|
||||
#include "google/protobuf/compiler/cpp/cpp_helpers.h"
|
||||
#include <google/protobuf/io/printer.h>
|
||||
#include <google/protobuf/wire_format.h>
|
||||
#include "google/protobuf/stubs/strutil.h"
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
using internal::WireFormatLite;
|
||||
|
||||
namespace {
|
||||
|
||||
// For encodings with fixed sizes, returns that size in bytes. Otherwise
|
||||
// returns -1.
|
||||
int FixedSize(FieldDescriptor::Type type) {
|
||||
switch (type) {
|
||||
case FieldDescriptor::TYPE_INT32 : return -1;
|
||||
case FieldDescriptor::TYPE_INT64 : return -1;
|
||||
case FieldDescriptor::TYPE_UINT32 : return -1;
|
||||
case FieldDescriptor::TYPE_UINT64 : return -1;
|
||||
case FieldDescriptor::TYPE_SINT32 : return -1;
|
||||
case FieldDescriptor::TYPE_SINT64 : return -1;
|
||||
case FieldDescriptor::TYPE_FIXED32 : return WireFormatLite::kFixed32Size;
|
||||
case FieldDescriptor::TYPE_FIXED64 : return WireFormatLite::kFixed64Size;
|
||||
case FieldDescriptor::TYPE_SFIXED32: return WireFormatLite::kSFixed32Size;
|
||||
case FieldDescriptor::TYPE_SFIXED64: return WireFormatLite::kSFixed64Size;
|
||||
case FieldDescriptor::TYPE_FLOAT : return WireFormatLite::kFloatSize;
|
||||
case FieldDescriptor::TYPE_DOUBLE : return WireFormatLite::kDoubleSize;
|
||||
|
||||
case FieldDescriptor::TYPE_BOOL : return WireFormatLite::kBoolSize;
|
||||
case FieldDescriptor::TYPE_ENUM : return -1;
|
||||
|
||||
case FieldDescriptor::TYPE_STRING : return -1;
|
||||
case FieldDescriptor::TYPE_BYTES : return -1;
|
||||
case FieldDescriptor::TYPE_GROUP : return -1;
|
||||
case FieldDescriptor::TYPE_MESSAGE : return -1;
|
||||
|
||||
// No default because we want the compiler to complain if any new
|
||||
// types are added.
|
||||
}
|
||||
GOOGLE_LOG(FATAL) << "Can't get here.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
void SetPrimitiveVariables(const FieldDescriptor* descriptor,
|
||||
map<string, string>* variables,
|
||||
const Options& options) {
|
||||
SetCommonFieldVariables(descriptor, variables, options);
|
||||
(*variables)["type"] = PrimitiveTypeName(descriptor->cpp_type());
|
||||
(*variables)["default"] = DefaultValue(descriptor);
|
||||
(*variables)["tag"] = SimpleItoa(internal::WireFormat::MakeTag(descriptor));
|
||||
int fixed_size = FixedSize(descriptor->type());
|
||||
if (fixed_size != -1) {
|
||||
(*variables)["fixed_size"] = SimpleItoa(fixed_size);
|
||||
}
|
||||
(*variables)["wire_format_field_type"] =
|
||||
"::google::protobuf::internal::WireFormatLite::" + FieldDescriptorProto_Type_Name(
|
||||
static_cast<FieldDescriptorProto_Type>(descriptor->type()));
|
||||
(*variables)["full_name"] = descriptor->full_name();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// ===================================================================
|
||||
|
||||
PrimitiveFieldGenerator::
|
||||
PrimitiveFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options)
|
||||
: descriptor_(descriptor) {
|
||||
SetPrimitiveVariables(descriptor, &variables_, options);
|
||||
}
|
||||
|
||||
PrimitiveFieldGenerator::~PrimitiveFieldGenerator() {}
|
||||
|
||||
void PrimitiveFieldGenerator::
|
||||
GeneratePrivateMembers(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$type$ $name$_;\n");
|
||||
}
|
||||
|
||||
void PrimitiveFieldGenerator::
|
||||
GenerateAccessorDeclarations(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline $type$ $name$() const$deprecation$;\n"
|
||||
"inline void set_$name$($type$ value)$deprecation$;\n");
|
||||
}
|
||||
|
||||
void PrimitiveFieldGenerator::
|
||||
GenerateInlineAccessorDefinitions(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline $type$ $classname$::$name$() const {\n"
|
||||
" // @@protoc_insertion_point(field_get:$full_name$)\n"
|
||||
" return $name$_;\n"
|
||||
"}\n"
|
||||
"inline void $classname$::set_$name$($type$ value) {\n"
|
||||
" set_has_$name$();\n"
|
||||
" $name$_ = value;\n"
|
||||
" // @@protoc_insertion_point(field_set:$full_name$)\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void PrimitiveFieldGenerator::
|
||||
GenerateClearingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$name$_ = $default$;\n");
|
||||
}
|
||||
|
||||
void PrimitiveFieldGenerator::
|
||||
GenerateMergingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "set_$name$(from.$name$());\n");
|
||||
}
|
||||
|
||||
void PrimitiveFieldGenerator::
|
||||
GenerateSwappingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "std::swap($name$_, other->$name$_);\n");
|
||||
}
|
||||
|
||||
void PrimitiveFieldGenerator::
|
||||
GenerateConstructorCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$name$_ = $default$;\n");
|
||||
}
|
||||
|
||||
void PrimitiveFieldGenerator::
|
||||
GenerateMergeFromCodedStream(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n"
|
||||
" $type$, $wire_format_field_type$>(\n"
|
||||
" input, &$name$_)));\n"
|
||||
"set_has_$name$();\n");
|
||||
}
|
||||
|
||||
void PrimitiveFieldGenerator::
|
||||
GenerateSerializeWithCachedSizes(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"::google::protobuf::internal::WireFormatLite::Write$declared_type$("
|
||||
"$number$, this->$name$(), output);\n");
|
||||
}
|
||||
|
||||
void PrimitiveFieldGenerator::
|
||||
GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"target = ::google::protobuf::internal::WireFormatLite::Write$declared_type$ToArray("
|
||||
"$number$, this->$name$(), target);\n");
|
||||
}
|
||||
|
||||
void PrimitiveFieldGenerator::
|
||||
GenerateByteSize(io::Printer* printer) const {
|
||||
int fixed_size = FixedSize(descriptor_->type());
|
||||
if (fixed_size == -1) {
|
||||
printer->Print(variables_,
|
||||
"total_size += $tag_size$ +\n"
|
||||
" ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n"
|
||||
" this->$name$());\n");
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
"total_size += $tag_size$ + $fixed_size$;\n");
|
||||
}
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
PrimitiveOneofFieldGenerator::
|
||||
PrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options)
|
||||
: PrimitiveFieldGenerator(descriptor, options) {
|
||||
SetCommonOneofFieldVariables(descriptor, &variables_);
|
||||
}
|
||||
|
||||
PrimitiveOneofFieldGenerator::~PrimitiveOneofFieldGenerator() {}
|
||||
|
||||
void PrimitiveOneofFieldGenerator::
|
||||
GenerateInlineAccessorDefinitions(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline $type$ $classname$::$name$() const {\n"
|
||||
" if (has_$name$()) {\n"
|
||||
" return $oneof_prefix$$name$_;\n"
|
||||
" }\n"
|
||||
" return $default$;\n"
|
||||
"}\n"
|
||||
"inline void $classname$::set_$name$($type$ value) {\n"
|
||||
" if (!has_$name$()) {\n"
|
||||
" clear_$oneof_name$();\n"
|
||||
" set_has_$name$();\n"
|
||||
" }\n"
|
||||
" $oneof_prefix$$name$_ = value;\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void PrimitiveOneofFieldGenerator::
|
||||
GenerateClearingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$oneof_prefix$$name$_ = $default$;\n");
|
||||
}
|
||||
|
||||
void PrimitiveOneofFieldGenerator::
|
||||
GenerateSwappingCode(io::Printer* printer) const {
|
||||
// Don't print any swapping code. Swapping the union will swap this field.
|
||||
}
|
||||
|
||||
void PrimitiveOneofFieldGenerator::
|
||||
GenerateConstructorCode(io::Printer* printer) const {
|
||||
printer->Print(
|
||||
variables_,
|
||||
" $classname$_default_oneof_instance_->$name$_ = $default$;\n");
|
||||
}
|
||||
|
||||
void PrimitiveOneofFieldGenerator::
|
||||
GenerateMergeFromCodedStream(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"clear_$oneof_name$();\n"
|
||||
"DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n"
|
||||
" $type$, $wire_format_field_type$>(\n"
|
||||
" input, &$oneof_prefix$$name$_)));\n"
|
||||
"set_has_$name$();\n");
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
RepeatedPrimitiveFieldGenerator::
|
||||
RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options)
|
||||
: descriptor_(descriptor) {
|
||||
SetPrimitiveVariables(descriptor, &variables_, options);
|
||||
|
||||
if (descriptor->options().packed()) {
|
||||
variables_["packed_reader"] = "ReadPackedPrimitive";
|
||||
variables_["repeated_reader"] = "ReadRepeatedPrimitiveNoInline";
|
||||
} else {
|
||||
variables_["packed_reader"] = "ReadPackedPrimitiveNoInline";
|
||||
variables_["repeated_reader"] = "ReadRepeatedPrimitive";
|
||||
}
|
||||
}
|
||||
|
||||
RepeatedPrimitiveFieldGenerator::~RepeatedPrimitiveFieldGenerator() {}
|
||||
|
||||
void RepeatedPrimitiveFieldGenerator::
|
||||
GeneratePrivateMembers(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"::google::protobuf::RepeatedField< $type$ > $name$_;\n");
|
||||
if (descriptor_->options().packed() && HasGeneratedMethods(descriptor_->file())) {
|
||||
printer->Print(variables_,
|
||||
"mutable int _$name$_cached_byte_size_;\n");
|
||||
}
|
||||
}
|
||||
|
||||
void RepeatedPrimitiveFieldGenerator::
|
||||
GenerateAccessorDeclarations(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline $type$ $name$(int index) const$deprecation$;\n"
|
||||
"inline void set_$name$(int index, $type$ value)$deprecation$;\n"
|
||||
"inline void add_$name$($type$ value)$deprecation$;\n");
|
||||
printer->Print(variables_,
|
||||
"inline const ::google::protobuf::RepeatedField< $type$ >&\n"
|
||||
" $name$() const$deprecation$;\n"
|
||||
"inline ::google::protobuf::RepeatedField< $type$ >*\n"
|
||||
" mutable_$name$()$deprecation$;\n");
|
||||
}
|
||||
|
||||
void RepeatedPrimitiveFieldGenerator::
|
||||
GenerateInlineAccessorDefinitions(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline $type$ $classname$::$name$(int index) const {\n"
|
||||
" // @@protoc_insertion_point(field_get:$full_name$)\n"
|
||||
" return $name$_.Get(index);\n"
|
||||
"}\n"
|
||||
"inline void $classname$::set_$name$(int index, $type$ value) {\n"
|
||||
" $name$_.Set(index, value);\n"
|
||||
" // @@protoc_insertion_point(field_set:$full_name$)\n"
|
||||
"}\n"
|
||||
"inline void $classname$::add_$name$($type$ value) {\n"
|
||||
" $name$_.Add(value);\n"
|
||||
" // @@protoc_insertion_point(field_add:$full_name$)\n"
|
||||
"}\n");
|
||||
printer->Print(variables_,
|
||||
"inline const ::google::protobuf::RepeatedField< $type$ >&\n"
|
||||
"$classname$::$name$() const {\n"
|
||||
" // @@protoc_insertion_point(field_list:$full_name$)\n"
|
||||
" return $name$_;\n"
|
||||
"}\n"
|
||||
"inline ::google::protobuf::RepeatedField< $type$ >*\n"
|
||||
"$classname$::mutable_$name$() {\n"
|
||||
" // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
|
||||
" return &$name$_;\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void RepeatedPrimitiveFieldGenerator::
|
||||
GenerateClearingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$name$_.Clear();\n");
|
||||
}
|
||||
|
||||
void RepeatedPrimitiveFieldGenerator::
|
||||
GenerateMergingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$name$_.MergeFrom(from.$name$_);\n");
|
||||
}
|
||||
|
||||
void RepeatedPrimitiveFieldGenerator::
|
||||
GenerateSwappingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$name$_.Swap(&other->$name$_);\n");
|
||||
}
|
||||
|
||||
void RepeatedPrimitiveFieldGenerator::
|
||||
GenerateConstructorCode(io::Printer* printer) const {
|
||||
if (descriptor_->options().packed() && HasGeneratedMethods(descriptor_->file())) {
|
||||
printer->Print(variables_, "_$name$_cached_byte_size_ = 0;\n");
|
||||
}
|
||||
}
|
||||
|
||||
void RepeatedPrimitiveFieldGenerator::
|
||||
GenerateMergeFromCodedStream(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"DO_((::google::protobuf::internal::WireFormatLite::$repeated_reader$<\n"
|
||||
" $type$, $wire_format_field_type$>(\n"
|
||||
" $tag_size$, $tag$, input, this->mutable_$name$())));\n");
|
||||
}
|
||||
|
||||
void RepeatedPrimitiveFieldGenerator::
|
||||
GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"DO_((::google::protobuf::internal::WireFormatLite::$packed_reader$<\n"
|
||||
" $type$, $wire_format_field_type$>(\n"
|
||||
" input, this->mutable_$name$())));\n");
|
||||
}
|
||||
|
||||
void RepeatedPrimitiveFieldGenerator::
|
||||
GenerateSerializeWithCachedSizes(io::Printer* printer) const {
|
||||
if (descriptor_->options().packed()) {
|
||||
// Write the tag and the size.
|
||||
printer->Print(variables_,
|
||||
"if (this->$name$_size() > 0) {\n"
|
||||
" ::google::protobuf::internal::WireFormatLite::WriteTag("
|
||||
"$number$, "
|
||||
"::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, "
|
||||
"output);\n"
|
||||
" output->WriteVarint32(_$name$_cached_byte_size_);\n"
|
||||
"}\n");
|
||||
}
|
||||
printer->Print(variables_,
|
||||
"for (int i = 0; i < this->$name$_size(); i++) {\n");
|
||||
if (descriptor_->options().packed()) {
|
||||
printer->Print(variables_,
|
||||
" ::google::protobuf::internal::WireFormatLite::Write$declared_type$NoTag(\n"
|
||||
" this->$name$(i), output);\n");
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
" ::google::protobuf::internal::WireFormatLite::Write$declared_type$(\n"
|
||||
" $number$, this->$name$(i), output);\n");
|
||||
}
|
||||
printer->Print("}\n");
|
||||
}
|
||||
|
||||
void RepeatedPrimitiveFieldGenerator::
|
||||
GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
|
||||
if (descriptor_->options().packed()) {
|
||||
// Write the tag and the size.
|
||||
printer->Print(variables_,
|
||||
"if (this->$name$_size() > 0) {\n"
|
||||
" target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(\n"
|
||||
" $number$,\n"
|
||||
" ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n"
|
||||
" target);\n"
|
||||
" target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(\n"
|
||||
" _$name$_cached_byte_size_, target);\n"
|
||||
"}\n");
|
||||
}
|
||||
printer->Print(variables_,
|
||||
"for (int i = 0; i < this->$name$_size(); i++) {\n");
|
||||
if (descriptor_->options().packed()) {
|
||||
printer->Print(variables_,
|
||||
" target = ::google::protobuf::internal::WireFormatLite::\n"
|
||||
" Write$declared_type$NoTagToArray(this->$name$(i), target);\n");
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
" target = ::google::protobuf::internal::WireFormatLite::\n"
|
||||
" Write$declared_type$ToArray($number$, this->$name$(i), target);\n");
|
||||
}
|
||||
printer->Print("}\n");
|
||||
}
|
||||
|
||||
void RepeatedPrimitiveFieldGenerator::
|
||||
GenerateByteSize(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"{\n"
|
||||
" int data_size = 0;\n");
|
||||
printer->Indent();
|
||||
int fixed_size = FixedSize(descriptor_->type());
|
||||
if (fixed_size == -1) {
|
||||
printer->Print(variables_,
|
||||
"for (int i = 0; i < this->$name$_size(); i++) {\n"
|
||||
" data_size += ::google::protobuf::internal::WireFormatLite::\n"
|
||||
" $declared_type$Size(this->$name$(i));\n"
|
||||
"}\n");
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
"data_size = $fixed_size$ * this->$name$_size();\n");
|
||||
}
|
||||
|
||||
if (descriptor_->options().packed()) {
|
||||
printer->Print(variables_,
|
||||
"if (data_size > 0) {\n"
|
||||
" total_size += $tag_size$ +\n"
|
||||
" ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n"
|
||||
"}\n"
|
||||
"GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n"
|
||||
"_$name$_cached_byte_size_ = data_size;\n"
|
||||
"GOOGLE_SAFE_CONCURRENT_WRITES_END();\n"
|
||||
"total_size += data_size;\n");
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
"total_size += $tag_size$ * this->$name$_size() + data_size;\n");
|
||||
}
|
||||
printer->Outdent();
|
||||
printer->Print("}\n");
|
||||
}
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
@@ -1,123 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "google/protobuf/compiler/cpp/cpp_field.h"
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
class PrimitiveFieldGenerator : public FieldGenerator {
|
||||
public:
|
||||
explicit PrimitiveFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options);
|
||||
~PrimitiveFieldGenerator();
|
||||
|
||||
// implements FieldGenerator ---------------------------------------
|
||||
void GeneratePrivateMembers(io::Printer* printer) const;
|
||||
void GenerateAccessorDeclarations(io::Printer* printer) const;
|
||||
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
|
||||
void GenerateClearingCode(io::Printer* printer) const;
|
||||
void GenerateMergingCode(io::Printer* printer) const;
|
||||
void GenerateSwappingCode(io::Printer* printer) const;
|
||||
void GenerateConstructorCode(io::Printer* printer) const;
|
||||
void GenerateMergeFromCodedStream(io::Printer* printer) const;
|
||||
void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
|
||||
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
|
||||
void GenerateByteSize(io::Printer* printer) const;
|
||||
|
||||
protected:
|
||||
const FieldDescriptor* descriptor_;
|
||||
map<string, string> variables_;
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator);
|
||||
};
|
||||
|
||||
class PrimitiveOneofFieldGenerator : public PrimitiveFieldGenerator {
|
||||
public:
|
||||
explicit PrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options);
|
||||
~PrimitiveOneofFieldGenerator();
|
||||
|
||||
// implements FieldGenerator ---------------------------------------
|
||||
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
|
||||
void GenerateClearingCode(io::Printer* printer) const;
|
||||
void GenerateSwappingCode(io::Printer* printer) const;
|
||||
void GenerateConstructorCode(io::Printer* printer) const;
|
||||
void GenerateMergeFromCodedStream(io::Printer* printer) const;
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveOneofFieldGenerator);
|
||||
};
|
||||
|
||||
class RepeatedPrimitiveFieldGenerator : public FieldGenerator {
|
||||
public:
|
||||
explicit RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options);
|
||||
~RepeatedPrimitiveFieldGenerator();
|
||||
|
||||
// implements FieldGenerator ---------------------------------------
|
||||
void GeneratePrivateMembers(io::Printer* printer) const;
|
||||
void GenerateAccessorDeclarations(io::Printer* printer) const;
|
||||
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
|
||||
void GenerateClearingCode(io::Printer* printer) const;
|
||||
void GenerateMergingCode(io::Printer* printer) const;
|
||||
void GenerateSwappingCode(io::Printer* printer) const;
|
||||
void GenerateConstructorCode(io::Printer* printer) const;
|
||||
void GenerateMergeFromCodedStream(io::Printer* printer) const;
|
||||
void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const;
|
||||
void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
|
||||
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
|
||||
void GenerateByteSize(io::Printer* printer) const;
|
||||
|
||||
private:
|
||||
const FieldDescriptor* descriptor_;
|
||||
map<string, string> variables_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator);
|
||||
};
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__
|
||||
@@ -1,642 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#include "google/protobuf/compiler/cpp/cpp_string_field.h"
|
||||
#include "google/protobuf/compiler/cpp/cpp_helpers.h"
|
||||
#include <google/protobuf/io/printer.h>
|
||||
#include <google/protobuf/descriptor.pb.h>
|
||||
#include "google/protobuf/stubs/strutil.h"
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
namespace {
|
||||
|
||||
void SetStringVariables(const FieldDescriptor* descriptor,
|
||||
map<string, string>* variables,
|
||||
const Options& options) {
|
||||
SetCommonFieldVariables(descriptor, variables, options);
|
||||
(*variables)["default"] = DefaultValue(descriptor);
|
||||
(*variables)["default_length"] =
|
||||
SimpleItoa(descriptor->default_value_string().length());
|
||||
(*variables)["default_variable"] = descriptor->default_value_string().empty()
|
||||
? "&::google::protobuf::internal::GetEmptyStringAlreadyInited()"
|
||||
: "_default_" + FieldName(descriptor) + "_";
|
||||
(*variables)["pointer_type"] =
|
||||
descriptor->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char";
|
||||
// NOTE: Escaped here to unblock proto1->proto2 migration.
|
||||
// TODO(liujisi): Extend this to apply for other conflicting methods.
|
||||
(*variables)["release_name"] =
|
||||
SafeFunctionName(descriptor->containing_type(),
|
||||
descriptor, "release_");
|
||||
(*variables)["full_name"] = descriptor->full_name();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// ===================================================================
|
||||
|
||||
StringFieldGenerator::
|
||||
StringFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options)
|
||||
: descriptor_(descriptor) {
|
||||
SetStringVariables(descriptor, &variables_, options);
|
||||
}
|
||||
|
||||
StringFieldGenerator::~StringFieldGenerator() {}
|
||||
|
||||
void StringFieldGenerator::
|
||||
GeneratePrivateMembers(io::Printer* printer) const {
|
||||
printer->Print(variables_, "::std::string* $name$_;\n");
|
||||
}
|
||||
|
||||
void StringFieldGenerator::
|
||||
GenerateStaticMembers(io::Printer* printer) const {
|
||||
if (!descriptor_->default_value_string().empty()) {
|
||||
printer->Print(variables_, "static ::std::string* $default_variable$;\n");
|
||||
}
|
||||
}
|
||||
|
||||
void StringFieldGenerator::
|
||||
GenerateAccessorDeclarations(io::Printer* printer) const {
|
||||
// If we're using StringFieldGenerator for a field with a ctype, it's
|
||||
// because that ctype isn't actually implemented. In particular, this is
|
||||
// true of ctype=CORD and ctype=STRING_PIECE in the open source release.
|
||||
// We aren't releasing Cord because it has too many Google-specific
|
||||
// dependencies and we aren't releasing StringPiece because it's hardly
|
||||
// useful outside of Google and because it would get confusing to have
|
||||
// multiple instances of the StringPiece class in different libraries (PCRE
|
||||
// already includes it for their C++ bindings, which came from Google).
|
||||
//
|
||||
// In any case, we make all the accessors private while still actually
|
||||
// using a string to represent the field internally. This way, we can
|
||||
// guarantee that if we do ever implement the ctype, it won't break any
|
||||
// existing users who might be -- for whatever reason -- already using .proto
|
||||
// files that applied the ctype. The field can still be accessed via the
|
||||
// reflection interface since the reflection interface is independent of
|
||||
// the string's underlying representation.
|
||||
if (descriptor_->options().ctype() != FieldOptions::STRING) {
|
||||
printer->Outdent();
|
||||
printer->Print(
|
||||
" private:\n"
|
||||
" // Hidden due to unknown ctype option.\n");
|
||||
printer->Indent();
|
||||
}
|
||||
|
||||
printer->Print(variables_,
|
||||
"inline const ::std::string& $name$() const$deprecation$;\n"
|
||||
"inline void set_$name$(const ::std::string& value)$deprecation$;\n"
|
||||
"inline void set_$name$(const char* value)$deprecation$;\n"
|
||||
"inline void set_$name$(const $pointer_type$* value, size_t size)"
|
||||
"$deprecation$;\n"
|
||||
"inline ::std::string* mutable_$name$()$deprecation$;\n"
|
||||
"inline ::std::string* $release_name$()$deprecation$;\n"
|
||||
"inline void set_allocated_$name$(::std::string* $name$)$deprecation$;\n");
|
||||
|
||||
|
||||
if (descriptor_->options().ctype() != FieldOptions::STRING) {
|
||||
printer->Outdent();
|
||||
printer->Print(" public:\n");
|
||||
printer->Indent();
|
||||
}
|
||||
}
|
||||
|
||||
void StringFieldGenerator::
|
||||
GenerateInlineAccessorDefinitions(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline const ::std::string& $classname$::$name$() const {\n"
|
||||
" // @@protoc_insertion_point(field_get:$full_name$)\n"
|
||||
" return *$name$_;\n"
|
||||
"}\n"
|
||||
"inline void $classname$::set_$name$(const ::std::string& value) {\n"
|
||||
" set_has_$name$();\n"
|
||||
" if ($name$_ == $default_variable$) {\n"
|
||||
" $name$_ = new ::std::string;\n"
|
||||
" }\n"
|
||||
" $name$_->assign(value);\n"
|
||||
" // @@protoc_insertion_point(field_set:$full_name$)\n"
|
||||
"}\n"
|
||||
"inline void $classname$::set_$name$(const char* value) {\n"
|
||||
" set_has_$name$();\n"
|
||||
" if ($name$_ == $default_variable$) {\n"
|
||||
" $name$_ = new ::std::string;\n"
|
||||
" }\n"
|
||||
" $name$_->assign(value);\n"
|
||||
" // @@protoc_insertion_point(field_set_char:$full_name$)\n"
|
||||
"}\n"
|
||||
"inline "
|
||||
"void $classname$::set_$name$(const $pointer_type$* value, size_t size) {\n"
|
||||
" set_has_$name$();\n"
|
||||
" if ($name$_ == $default_variable$) {\n"
|
||||
" $name$_ = new ::std::string;\n"
|
||||
" }\n"
|
||||
" $name$_->assign(reinterpret_cast<const char*>(value), size);\n"
|
||||
" // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
|
||||
"}\n"
|
||||
"inline ::std::string* $classname$::mutable_$name$() {\n"
|
||||
" set_has_$name$();\n"
|
||||
" if ($name$_ == $default_variable$) {\n");
|
||||
if (descriptor_->default_value_string().empty()) {
|
||||
printer->Print(variables_,
|
||||
" $name$_ = new ::std::string;\n");
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
" $name$_ = new ::std::string(*$default_variable$);\n");
|
||||
}
|
||||
printer->Print(variables_,
|
||||
" }\n"
|
||||
" // @@protoc_insertion_point(field_mutable:$full_name$)\n"
|
||||
" return $name$_;\n"
|
||||
"}\n"
|
||||
"inline ::std::string* $classname$::$release_name$() {\n"
|
||||
" clear_has_$name$();\n"
|
||||
" if ($name$_ == $default_variable$) {\n"
|
||||
" return NULL;\n"
|
||||
" } else {\n"
|
||||
" ::std::string* temp = $name$_;\n"
|
||||
" $name$_ = const_cast< ::std::string*>($default_variable$);\n"
|
||||
" return temp;\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"inline void $classname$::set_allocated_$name$(::std::string* $name$) {\n"
|
||||
" if ($name$_ != $default_variable$) {\n"
|
||||
" delete $name$_;\n"
|
||||
" }\n"
|
||||
" if ($name$) {\n"
|
||||
" set_has_$name$();\n"
|
||||
" $name$_ = $name$;\n"
|
||||
" } else {\n"
|
||||
" clear_has_$name$();\n"
|
||||
" $name$_ = const_cast< ::std::string*>($default_variable$);\n"
|
||||
" }\n"
|
||||
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void StringFieldGenerator::
|
||||
GenerateNonInlineAccessorDefinitions(io::Printer* printer) const {
|
||||
if (!descriptor_->default_value_string().empty()) {
|
||||
// Initialized in GenerateDefaultInstanceAllocator.
|
||||
printer->Print(variables_,
|
||||
"::std::string* $classname$::$default_variable$ = NULL;\n");
|
||||
}
|
||||
}
|
||||
|
||||
void StringFieldGenerator::
|
||||
GenerateClearingCode(io::Printer* printer) const {
|
||||
if (descriptor_->default_value_string().empty()) {
|
||||
printer->Print(variables_,
|
||||
"if ($name$_ != $default_variable$) {\n"
|
||||
" $name$_->clear();\n"
|
||||
"}\n");
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
"if ($name$_ != $default_variable$) {\n"
|
||||
" $name$_->assign(*$default_variable$);\n"
|
||||
"}\n");
|
||||
}
|
||||
}
|
||||
|
||||
void StringFieldGenerator::
|
||||
GenerateMergingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "set_$name$(from.$name$());\n");
|
||||
}
|
||||
|
||||
void StringFieldGenerator::
|
||||
GenerateSwappingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "std::swap($name$_, other->$name$_);\n");
|
||||
}
|
||||
|
||||
void StringFieldGenerator::
|
||||
GenerateConstructorCode(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"$name$_ = const_cast< ::std::string*>($default_variable$);\n");
|
||||
}
|
||||
|
||||
void StringFieldGenerator::
|
||||
GenerateDestructorCode(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"if ($name$_ != $default_variable$) {\n"
|
||||
" delete $name$_;\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void StringFieldGenerator::
|
||||
GenerateDefaultInstanceAllocator(io::Printer* printer) const {
|
||||
if (!descriptor_->default_value_string().empty()) {
|
||||
printer->Print(variables_,
|
||||
"$classname$::$default_variable$ =\n"
|
||||
" new ::std::string($default$, $default_length$);\n");
|
||||
}
|
||||
}
|
||||
|
||||
void StringFieldGenerator::
|
||||
GenerateShutdownCode(io::Printer* printer) const {
|
||||
if (!descriptor_->default_value_string().empty()) {
|
||||
printer->Print(variables_,
|
||||
"delete $classname$::$default_variable$;\n");
|
||||
}
|
||||
}
|
||||
|
||||
void StringFieldGenerator::
|
||||
GenerateMergeFromCodedStream(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"DO_(::google::protobuf::internal::WireFormatLite::Read$declared_type$(\n"
|
||||
" input, this->mutable_$name$()));\n");
|
||||
if (HasUtf8Verification(descriptor_->file()) &&
|
||||
descriptor_->type() == FieldDescriptor::TYPE_STRING) {
|
||||
printer->Print(variables_,
|
||||
"::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n"
|
||||
" this->$name$().data(), this->$name$().length(),\n"
|
||||
" ::google::protobuf::internal::WireFormat::PARSE,\n"
|
||||
" \"$name$\");\n");
|
||||
}
|
||||
}
|
||||
|
||||
void StringFieldGenerator::
|
||||
GenerateSerializeWithCachedSizes(io::Printer* printer) const {
|
||||
if (HasUtf8Verification(descriptor_->file()) &&
|
||||
descriptor_->type() == FieldDescriptor::TYPE_STRING) {
|
||||
printer->Print(variables_,
|
||||
"::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n"
|
||||
" this->$name$().data(), this->$name$().length(),\n"
|
||||
" ::google::protobuf::internal::WireFormat::SERIALIZE,\n"
|
||||
" \"$name$\");\n");
|
||||
}
|
||||
printer->Print(variables_,
|
||||
"::google::protobuf::internal::WireFormatLite::Write$declared_type$MaybeAliased(\n"
|
||||
" $number$, this->$name$(), output);\n");
|
||||
}
|
||||
|
||||
void StringFieldGenerator::
|
||||
GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
|
||||
if (HasUtf8Verification(descriptor_->file()) &&
|
||||
descriptor_->type() == FieldDescriptor::TYPE_STRING) {
|
||||
printer->Print(variables_,
|
||||
"::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n"
|
||||
" this->$name$().data(), this->$name$().length(),\n"
|
||||
" ::google::protobuf::internal::WireFormat::SERIALIZE,\n"
|
||||
" \"$name$\");\n");
|
||||
}
|
||||
printer->Print(variables_,
|
||||
"target =\n"
|
||||
" ::google::protobuf::internal::WireFormatLite::Write$declared_type$ToArray(\n"
|
||||
" $number$, this->$name$(), target);\n");
|
||||
}
|
||||
|
||||
void StringFieldGenerator::
|
||||
GenerateByteSize(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"total_size += $tag_size$ +\n"
|
||||
" ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n"
|
||||
" this->$name$());\n");
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
StringOneofFieldGenerator::
|
||||
StringOneofFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options)
|
||||
: StringFieldGenerator(descriptor, options) {
|
||||
SetCommonOneofFieldVariables(descriptor, &variables_);
|
||||
}
|
||||
|
||||
StringOneofFieldGenerator::~StringOneofFieldGenerator() {}
|
||||
|
||||
void StringOneofFieldGenerator::
|
||||
GenerateInlineAccessorDefinitions(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline const ::std::string& $classname$::$name$() const {\n"
|
||||
" if (has_$name$()) {\n"
|
||||
" return *$oneof_prefix$$name$_;\n"
|
||||
" }\n");
|
||||
if (descriptor_->default_value_string().empty()) {
|
||||
printer->Print(variables_,
|
||||
" return ::google::protobuf::internal::GetEmptyStringAlreadyInited();\n");
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
" return *$default_variable$;\n");
|
||||
}
|
||||
printer->Print(variables_,
|
||||
"}\n"
|
||||
"inline void $classname$::set_$name$(const ::std::string& value) {\n"
|
||||
" if (!has_$name$()) {\n"
|
||||
" clear_$oneof_name$();\n"
|
||||
" set_has_$name$();\n"
|
||||
" $oneof_prefix$$name$_ = new ::std::string;\n"
|
||||
" }\n"
|
||||
" $oneof_prefix$$name$_->assign(value);\n"
|
||||
"}\n"
|
||||
"inline void $classname$::set_$name$(const char* value) {\n"
|
||||
" if (!has_$name$()) {\n"
|
||||
" clear_$oneof_name$();\n"
|
||||
" set_has_$name$();\n"
|
||||
" $oneof_prefix$$name$_ = new ::std::string;\n"
|
||||
" }\n"
|
||||
" $oneof_prefix$$name$_->assign(value);\n"
|
||||
"}\n"
|
||||
"inline "
|
||||
"void $classname$::set_$name$(const $pointer_type$* value, size_t size) {\n"
|
||||
" if (!has_$name$()) {\n"
|
||||
" clear_$oneof_name$();\n"
|
||||
" set_has_$name$();\n"
|
||||
" $oneof_prefix$$name$_ = new ::std::string;\n"
|
||||
" }\n"
|
||||
" $oneof_prefix$$name$_->assign(\n"
|
||||
" reinterpret_cast<const char*>(value), size);\n"
|
||||
"}\n"
|
||||
"inline ::std::string* $classname$::mutable_$name$() {\n"
|
||||
" if (!has_$name$()) {\n"
|
||||
" clear_$oneof_name$();\n"
|
||||
" set_has_$name$();\n");
|
||||
if (descriptor_->default_value_string().empty()) {
|
||||
printer->Print(variables_,
|
||||
" $oneof_prefix$$name$_ = new ::std::string;\n");
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
" $oneof_prefix$$name$_ = new ::std::string(*$default_variable$);\n");
|
||||
}
|
||||
printer->Print(variables_,
|
||||
" }\n"
|
||||
" return $oneof_prefix$$name$_;\n"
|
||||
"}\n"
|
||||
"inline ::std::string* $classname$::$release_name$() {\n"
|
||||
" if (has_$name$()) {\n"
|
||||
" clear_has_$oneof_name$();\n"
|
||||
" ::std::string* temp = $oneof_prefix$$name$_;\n"
|
||||
" $oneof_prefix$$name$_ = NULL;\n"
|
||||
" return temp;\n"
|
||||
" } else {\n"
|
||||
" return NULL;\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"inline void $classname$::set_allocated_$name$(::std::string* $name$) {\n"
|
||||
" clear_$oneof_name$();\n"
|
||||
" if ($name$) {\n"
|
||||
" set_has_$name$();\n"
|
||||
" $oneof_prefix$$name$_ = $name$;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void StringOneofFieldGenerator::
|
||||
GenerateClearingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"delete $oneof_prefix$$name$_;\n");
|
||||
}
|
||||
|
||||
void StringOneofFieldGenerator::
|
||||
GenerateSwappingCode(io::Printer* printer) const {
|
||||
// Don't print any swapping code. Swapping the union will swap this field.
|
||||
}
|
||||
|
||||
void StringOneofFieldGenerator::
|
||||
GenerateConstructorCode(io::Printer* printer) const {
|
||||
if (!descriptor_->default_value_string().empty()) {
|
||||
printer->Print(variables_,
|
||||
" $classname$_default_oneof_instance_->$name$_ = "
|
||||
"$classname$::$default_variable$;\n");
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
" $classname$_default_oneof_instance_->$name$_ = "
|
||||
"$default_variable$;\n");
|
||||
}
|
||||
}
|
||||
|
||||
void StringOneofFieldGenerator::
|
||||
GenerateDestructorCode(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"if (has_$name$()) {\n"
|
||||
" delete $oneof_prefix$$name$_;\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
RepeatedStringFieldGenerator::
|
||||
RepeatedStringFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options)
|
||||
: descriptor_(descriptor) {
|
||||
SetStringVariables(descriptor, &variables_, options);
|
||||
}
|
||||
|
||||
RepeatedStringFieldGenerator::~RepeatedStringFieldGenerator() {}
|
||||
|
||||
void RepeatedStringFieldGenerator::
|
||||
GeneratePrivateMembers(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"::google::protobuf::RepeatedPtrField< ::std::string> $name$_;\n");
|
||||
}
|
||||
|
||||
void RepeatedStringFieldGenerator::
|
||||
GenerateAccessorDeclarations(io::Printer* printer) const {
|
||||
// See comment above about unknown ctypes.
|
||||
if (descriptor_->options().ctype() != FieldOptions::STRING) {
|
||||
printer->Outdent();
|
||||
printer->Print(
|
||||
" private:\n"
|
||||
" // Hidden due to unknown ctype option.\n");
|
||||
printer->Indent();
|
||||
}
|
||||
|
||||
printer->Print(variables_,
|
||||
"inline const ::std::string& $name$(int index) const$deprecation$;\n"
|
||||
"inline ::std::string* mutable_$name$(int index)$deprecation$;\n"
|
||||
"inline void set_$name$(int index, const ::std::string& value)$deprecation$;\n"
|
||||
"inline void set_$name$(int index, const char* value)$deprecation$;\n"
|
||||
"inline "
|
||||
"void set_$name$(int index, const $pointer_type$* value, size_t size)"
|
||||
"$deprecation$;\n"
|
||||
"inline ::std::string* add_$name$()$deprecation$;\n"
|
||||
"inline void add_$name$(const ::std::string& value)$deprecation$;\n"
|
||||
"inline void add_$name$(const char* value)$deprecation$;\n"
|
||||
"inline void add_$name$(const $pointer_type$* value, size_t size)"
|
||||
"$deprecation$;\n");
|
||||
|
||||
printer->Print(variables_,
|
||||
"inline const ::google::protobuf::RepeatedPtrField< ::std::string>& $name$() const"
|
||||
"$deprecation$;\n"
|
||||
"inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_$name$()"
|
||||
"$deprecation$;\n");
|
||||
|
||||
if (descriptor_->options().ctype() != FieldOptions::STRING) {
|
||||
printer->Outdent();
|
||||
printer->Print(" public:\n");
|
||||
printer->Indent();
|
||||
}
|
||||
}
|
||||
|
||||
void RepeatedStringFieldGenerator::
|
||||
GenerateInlineAccessorDefinitions(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"inline const ::std::string& $classname$::$name$(int index) const {\n"
|
||||
" // @@protoc_insertion_point(field_get:$full_name$)\n"
|
||||
" return $name$_.$cppget$(index);\n"
|
||||
"}\n"
|
||||
"inline ::std::string* $classname$::mutable_$name$(int index) {\n"
|
||||
" // @@protoc_insertion_point(field_mutable:$full_name$)\n"
|
||||
" return $name$_.Mutable(index);\n"
|
||||
"}\n"
|
||||
"inline void $classname$::set_$name$(int index, const ::std::string& value) {\n"
|
||||
" // @@protoc_insertion_point(field_set:$full_name$)\n"
|
||||
" $name$_.Mutable(index)->assign(value);\n"
|
||||
"}\n"
|
||||
"inline void $classname$::set_$name$(int index, const char* value) {\n"
|
||||
" $name$_.Mutable(index)->assign(value);\n"
|
||||
" // @@protoc_insertion_point(field_set_char:$full_name$)\n"
|
||||
"}\n"
|
||||
"inline void "
|
||||
"$classname$::set_$name$"
|
||||
"(int index, const $pointer_type$* value, size_t size) {\n"
|
||||
" $name$_.Mutable(index)->assign(\n"
|
||||
" reinterpret_cast<const char*>(value), size);\n"
|
||||
" // @@protoc_insertion_point(field_set_pointer:$full_name$)\n"
|
||||
"}\n"
|
||||
"inline ::std::string* $classname$::add_$name$() {\n"
|
||||
" return $name$_.Add();\n"
|
||||
"}\n"
|
||||
"inline void $classname$::add_$name$(const ::std::string& value) {\n"
|
||||
" $name$_.Add()->assign(value);\n"
|
||||
" // @@protoc_insertion_point(field_add:$full_name$)\n"
|
||||
"}\n"
|
||||
"inline void $classname$::add_$name$(const char* value) {\n"
|
||||
" $name$_.Add()->assign(value);\n"
|
||||
" // @@protoc_insertion_point(field_add_char:$full_name$)\n"
|
||||
"}\n"
|
||||
"inline void "
|
||||
"$classname$::add_$name$(const $pointer_type$* value, size_t size) {\n"
|
||||
" $name$_.Add()->assign(reinterpret_cast<const char*>(value), size);\n"
|
||||
" // @@protoc_insertion_point(field_add_pointer:$full_name$)\n"
|
||||
"}\n");
|
||||
printer->Print(variables_,
|
||||
"inline const ::google::protobuf::RepeatedPtrField< ::std::string>&\n"
|
||||
"$classname$::$name$() const {\n"
|
||||
" // @@protoc_insertion_point(field_list:$full_name$)\n"
|
||||
" return $name$_;\n"
|
||||
"}\n"
|
||||
"inline ::google::protobuf::RepeatedPtrField< ::std::string>*\n"
|
||||
"$classname$::mutable_$name$() {\n"
|
||||
" // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
|
||||
" return &$name$_;\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void RepeatedStringFieldGenerator::
|
||||
GenerateClearingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$name$_.Clear();\n");
|
||||
}
|
||||
|
||||
void RepeatedStringFieldGenerator::
|
||||
GenerateMergingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$name$_.MergeFrom(from.$name$_);\n");
|
||||
}
|
||||
|
||||
void RepeatedStringFieldGenerator::
|
||||
GenerateSwappingCode(io::Printer* printer) const {
|
||||
printer->Print(variables_, "$name$_.Swap(&other->$name$_);\n");
|
||||
}
|
||||
|
||||
void RepeatedStringFieldGenerator::
|
||||
GenerateConstructorCode(io::Printer* printer) const {
|
||||
// Not needed for repeated fields.
|
||||
}
|
||||
|
||||
void RepeatedStringFieldGenerator::
|
||||
GenerateMergeFromCodedStream(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"DO_(::google::protobuf::internal::WireFormatLite::Read$declared_type$(\n"
|
||||
" input, this->add_$name$()));\n");
|
||||
if (HasUtf8Verification(descriptor_->file()) &&
|
||||
descriptor_->type() == FieldDescriptor::TYPE_STRING) {
|
||||
printer->Print(variables_,
|
||||
"::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n"
|
||||
" this->$name$(this->$name$_size() - 1).data(),\n"
|
||||
" this->$name$(this->$name$_size() - 1).length(),\n"
|
||||
" ::google::protobuf::internal::WireFormat::PARSE,\n"
|
||||
" \"$name$\");\n");
|
||||
}
|
||||
}
|
||||
|
||||
void RepeatedStringFieldGenerator::
|
||||
GenerateSerializeWithCachedSizes(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"for (int i = 0; i < this->$name$_size(); i++) {\n");
|
||||
if (HasUtf8Verification(descriptor_->file()) &&
|
||||
descriptor_->type() == FieldDescriptor::TYPE_STRING) {
|
||||
printer->Print(variables_,
|
||||
"::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n"
|
||||
" this->$name$(i).data(), this->$name$(i).length(),\n"
|
||||
" ::google::protobuf::internal::WireFormat::SERIALIZE,\n"
|
||||
" \"$name$\");\n");
|
||||
}
|
||||
printer->Print(variables_,
|
||||
" ::google::protobuf::internal::WireFormatLite::Write$declared_type$(\n"
|
||||
" $number$, this->$name$(i), output);\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void RepeatedStringFieldGenerator::
|
||||
GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"for (int i = 0; i < this->$name$_size(); i++) {\n");
|
||||
if (HasUtf8Verification(descriptor_->file()) &&
|
||||
descriptor_->type() == FieldDescriptor::TYPE_STRING) {
|
||||
printer->Print(variables_,
|
||||
" ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n"
|
||||
" this->$name$(i).data(), this->$name$(i).length(),\n"
|
||||
" ::google::protobuf::internal::WireFormat::SERIALIZE,\n"
|
||||
" \"$name$\");\n");
|
||||
}
|
||||
printer->Print(variables_,
|
||||
" target = ::google::protobuf::internal::WireFormatLite::\n"
|
||||
" Write$declared_type$ToArray($number$, this->$name$(i), target);\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
void RepeatedStringFieldGenerator::
|
||||
GenerateByteSize(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"total_size += $tag_size$ * this->$name$_size();\n"
|
||||
"for (int i = 0; i < this->$name$_size(); i++) {\n"
|
||||
" total_size += ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n"
|
||||
" this->$name$(i));\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
@@ -1,127 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "google/protobuf/compiler/cpp/cpp_field.h"
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace compiler {
|
||||
namespace cpp {
|
||||
|
||||
class StringFieldGenerator : public FieldGenerator {
|
||||
public:
|
||||
explicit StringFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options);
|
||||
~StringFieldGenerator();
|
||||
|
||||
// implements FieldGenerator ---------------------------------------
|
||||
void GeneratePrivateMembers(io::Printer* printer) const;
|
||||
void GenerateStaticMembers(io::Printer* printer) const;
|
||||
void GenerateAccessorDeclarations(io::Printer* printer) const;
|
||||
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
|
||||
void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const;
|
||||
void GenerateClearingCode(io::Printer* printer) const;
|
||||
void GenerateMergingCode(io::Printer* printer) const;
|
||||
void GenerateSwappingCode(io::Printer* printer) const;
|
||||
void GenerateConstructorCode(io::Printer* printer) const;
|
||||
void GenerateDestructorCode(io::Printer* printer) const;
|
||||
void GenerateDefaultInstanceAllocator(io::Printer* printer) const;
|
||||
void GenerateShutdownCode(io::Printer* printer) const;
|
||||
void GenerateMergeFromCodedStream(io::Printer* printer) const;
|
||||
void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
|
||||
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
|
||||
void GenerateByteSize(io::Printer* printer) const;
|
||||
|
||||
protected:
|
||||
const FieldDescriptor* descriptor_;
|
||||
map<string, string> variables_;
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator);
|
||||
};
|
||||
|
||||
class StringOneofFieldGenerator : public StringFieldGenerator {
|
||||
public:
|
||||
explicit StringOneofFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options);
|
||||
~StringOneofFieldGenerator();
|
||||
|
||||
// implements FieldGenerator ---------------------------------------
|
||||
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
|
||||
void GenerateClearingCode(io::Printer* printer) const;
|
||||
void GenerateSwappingCode(io::Printer* printer) const;
|
||||
void GenerateConstructorCode(io::Printer* printer) const;
|
||||
void GenerateDestructorCode(io::Printer* printer) const;
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOneofFieldGenerator);
|
||||
};
|
||||
|
||||
class RepeatedStringFieldGenerator : public FieldGenerator {
|
||||
public:
|
||||
explicit RepeatedStringFieldGenerator(const FieldDescriptor* descriptor,
|
||||
const Options& options);
|
||||
~RepeatedStringFieldGenerator();
|
||||
|
||||
// implements FieldGenerator ---------------------------------------
|
||||
void GeneratePrivateMembers(io::Printer* printer) const;
|
||||
void GenerateAccessorDeclarations(io::Printer* printer) const;
|
||||
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
|
||||
void GenerateClearingCode(io::Printer* printer) const;
|
||||
void GenerateMergingCode(io::Printer* printer) const;
|
||||
void GenerateSwappingCode(io::Printer* printer) const;
|
||||
void GenerateConstructorCode(io::Printer* printer) const;
|
||||
void GenerateMergeFromCodedStream(io::Printer* printer) const;
|
||||
void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
|
||||
void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
|
||||
void GenerateByteSize(io::Printer* printer) const;
|
||||
|
||||
private:
|
||||
const FieldDescriptor* descriptor_;
|
||||
map<string, string> variables_;
|
||||
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedStringFieldGenerator);
|
||||
};
|
||||
|
||||
} // namespace cpp
|
||||
} // namespace compiler
|
||||
} // namespace protobuf
|
||||
|
||||
} // namespace google
|
||||
#endif // GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__
|
||||
@@ -1,232 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
//
|
||||
// Deals with the fact that hash_map is not defined everywhere.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_STUBS_HASH_H__
|
||||
#define GOOGLE_PROTOBUF_STUBS_HASH_H__
|
||||
|
||||
#include <string.h>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include "config.h"
|
||||
|
||||
#if defined(HAVE_HASH_MAP) && defined(HAVE_HASH_SET)
|
||||
#include HASH_MAP_H
|
||||
#include HASH_SET_H
|
||||
#else
|
||||
#define MISSING_HASH
|
||||
#include <map>
|
||||
#include <set>
|
||||
#endif
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
#ifdef MISSING_HASH
|
||||
|
||||
// This system doesn't have hash_map or hash_set. Emulate them using map and
|
||||
// set.
|
||||
|
||||
// Make hash<T> be the same as less<T>. Note that everywhere where custom
|
||||
// hash functions are defined in the protobuf code, they are also defined such
|
||||
// that they can be used as "less" functions, which is required by MSVC anyway.
|
||||
template <typename Key>
|
||||
struct hash {
|
||||
// Dummy, just to make derivative hash functions compile.
|
||||
int operator()(const Key& key) {
|
||||
GOOGLE_LOG(FATAL) << "Should never be called.";
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline bool operator()(const Key& a, const Key& b) const {
|
||||
return a < b;
|
||||
}
|
||||
};
|
||||
|
||||
// Make sure char* is compared by value.
|
||||
template <>
|
||||
struct hash<const char*> {
|
||||
// Dummy, just to make derivative hash functions compile.
|
||||
int operator()(const char* key) {
|
||||
GOOGLE_LOG(FATAL) << "Should never be called.";
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline bool operator()(const char* a, const char* b) const {
|
||||
return strcmp(a, b) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Data,
|
||||
typename HashFcn = hash<Key>,
|
||||
typename EqualKey = int >
|
||||
class hash_map : public std::map<Key, Data, HashFcn> {
|
||||
public:
|
||||
hash_map(int = 0) {}
|
||||
};
|
||||
|
||||
template <typename Key,
|
||||
typename HashFcn = hash<Key>,
|
||||
typename EqualKey = int >
|
||||
class hash_set : public std::set<Key, HashFcn> {
|
||||
public:
|
||||
hash_set(int = 0) {}
|
||||
};
|
||||
|
||||
#elif defined(_MSC_VER) && !defined(_STLPORT_VERSION)
|
||||
|
||||
template <typename Key>
|
||||
struct hash : public HASH_NAMESPACE::hash_compare<Key> {
|
||||
};
|
||||
|
||||
// MSVC's hash_compare<const char*> hashes based on the string contents but
|
||||
// compares based on the string pointer. WTF?
|
||||
class CstringLess {
|
||||
public:
|
||||
inline bool operator()(const char* a, const char* b) const {
|
||||
return strcmp(a, b) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash<const char*>
|
||||
: public HASH_NAMESPACE::hash_compare<const char*, CstringLess> {
|
||||
};
|
||||
|
||||
template <typename Key, typename Data,
|
||||
typename HashFcn = hash<Key>,
|
||||
typename EqualKey = int >
|
||||
class hash_map : public HASH_NAMESPACE::hash_map<
|
||||
Key, Data, HashFcn> {
|
||||
public:
|
||||
hash_map(int = 0) {}
|
||||
};
|
||||
|
||||
template <typename Key,
|
||||
typename HashFcn = hash<Key>,
|
||||
typename EqualKey = int >
|
||||
class hash_set : public HASH_NAMESPACE::hash_set<
|
||||
Key, HashFcn> {
|
||||
public:
|
||||
hash_set(int = 0) {}
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
template <typename Key>
|
||||
struct hash : public HASH_NAMESPACE::hash<Key> {
|
||||
};
|
||||
|
||||
template <typename Key>
|
||||
struct hash<const Key*> {
|
||||
inline size_t operator()(const Key* key) const {
|
||||
return reinterpret_cast<size_t>(key);
|
||||
}
|
||||
};
|
||||
|
||||
// Unlike the old SGI version, the TR1 "hash" does not special-case char*. So,
|
||||
// we go ahead and provide our own implementation.
|
||||
template <>
|
||||
struct hash<const char*> {
|
||||
inline size_t operator()(const char* str) const {
|
||||
size_t result = 0;
|
||||
for (; *str != '\0'; str++) {
|
||||
result = 5 * result + *str;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Data,
|
||||
typename HashFcn = hash<Key>,
|
||||
typename EqualKey = std::equal_to<Key> >
|
||||
class hash_map : public HASH_NAMESPACE::HASH_MAP_CLASS<
|
||||
Key, Data, HashFcn, EqualKey> {
|
||||
public:
|
||||
hash_map(int = 0) {}
|
||||
};
|
||||
|
||||
template <typename Key,
|
||||
typename HashFcn = hash<Key>,
|
||||
typename EqualKey = std::equal_to<Key> >
|
||||
class hash_set : public HASH_NAMESPACE::HASH_SET_CLASS<
|
||||
Key, HashFcn, EqualKey> {
|
||||
public:
|
||||
hash_set(int = 0) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
template <>
|
||||
struct hash<string> {
|
||||
inline size_t operator()(const string& key) const {
|
||||
return hash<const char*>()(key.c_str());
|
||||
}
|
||||
|
||||
static const size_t bucket_size = 4;
|
||||
static const size_t min_buckets = 8;
|
||||
inline size_t operator()(const string& a, const string& b) const {
|
||||
return a < b;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename First, typename Second>
|
||||
struct hash<pair<First, Second> > {
|
||||
inline size_t operator()(const pair<First, Second>& key) const {
|
||||
size_t first_hash = hash<First>()(key.first);
|
||||
size_t second_hash = hash<Second>()(key.second);
|
||||
|
||||
// FIXME(kenton): What is the best way to compute this hash? I have
|
||||
// no idea! This seems a bit better than an XOR.
|
||||
return first_hash * ((1 << 16) - 1) + second_hash;
|
||||
}
|
||||
|
||||
static const size_t bucket_size = 4;
|
||||
static const size_t min_buckets = 8;
|
||||
inline size_t operator()(const pair<First, Second>& a,
|
||||
const pair<First, Second>& b) const {
|
||||
return a < b;
|
||||
}
|
||||
};
|
||||
|
||||
// Used by GCC/SGI STL only. (Why isn't this provided by the standard
|
||||
// library? :( )
|
||||
struct streq {
|
||||
inline bool operator()(const char* a, const char* b) const {
|
||||
return strcmp(a, b) == 0;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_STUBS_HASH_H__
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,562 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// from google3/strings/strutil.h
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_STUBS_STRUTIL_H__
|
||||
#define GOOGLE_PROTOBUF_STUBS_STRUTIL_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define strtoll _strtoi64
|
||||
#define strtoull _strtoui64
|
||||
#elif defined(__DECCXX) && defined(__osf__)
|
||||
// HP C++ on Tru64 does not have strtoll, but strtol is already 64-bit.
|
||||
#define strtoll strtol
|
||||
#define strtoull strtoul
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// ascii_isalnum()
|
||||
// Check if an ASCII character is alphanumeric. We can't use ctype's
|
||||
// isalnum() because it is affected by locale. This function is applied
|
||||
// to identifiers in the protocol buffer language, not to natural-language
|
||||
// strings, so locale should not be taken into account.
|
||||
// ascii_isdigit()
|
||||
// Like above, but only accepts digits.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline bool ascii_isalnum(char c) {
|
||||
return ('a' <= c && c <= 'z') ||
|
||||
('A' <= c && c <= 'Z') ||
|
||||
('0' <= c && c <= '9');
|
||||
}
|
||||
|
||||
inline bool ascii_isdigit(char c) {
|
||||
return ('0' <= c && c <= '9');
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// HasPrefixString()
|
||||
// Check if a string begins with a given prefix.
|
||||
// StripPrefixString()
|
||||
// Given a string and a putative prefix, returns the string minus the
|
||||
// prefix string if the prefix matches, otherwise the original
|
||||
// string.
|
||||
// ----------------------------------------------------------------------
|
||||
inline bool HasPrefixString(const string& str,
|
||||
const string& prefix) {
|
||||
return str.size() >= prefix.size() &&
|
||||
str.compare(0, prefix.size(), prefix) == 0;
|
||||
}
|
||||
|
||||
inline string StripPrefixString(const string& str, const string& prefix) {
|
||||
if (HasPrefixString(str, prefix)) {
|
||||
return str.substr(prefix.size());
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// HasSuffixString()
|
||||
// Return true if str ends in suffix.
|
||||
// StripSuffixString()
|
||||
// Given a string and a putative suffix, returns the string minus the
|
||||
// suffix string if the suffix matches, otherwise the original
|
||||
// string.
|
||||
// ----------------------------------------------------------------------
|
||||
inline bool HasSuffixString(const string& str,
|
||||
const string& suffix) {
|
||||
return str.size() >= suffix.size() &&
|
||||
str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
|
||||
}
|
||||
|
||||
inline string StripSuffixString(const string& str, const string& suffix) {
|
||||
if (HasSuffixString(str, suffix)) {
|
||||
return str.substr(0, str.size() - suffix.size());
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// StripString
|
||||
// Replaces any occurrence of the character 'remove' (or the characters
|
||||
// in 'remove') with the character 'replacewith'.
|
||||
// Good for keeping html characters or protocol characters (\t) out
|
||||
// of places where they might cause a problem.
|
||||
// ----------------------------------------------------------------------
|
||||
LIBPROTOBUF_EXPORT void StripString(string* s, const char* remove,
|
||||
char replacewith);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// LowerString()
|
||||
// UpperString()
|
||||
// ToUpper()
|
||||
// Convert the characters in "s" to lowercase or uppercase. ASCII-only:
|
||||
// these functions intentionally ignore locale because they are applied to
|
||||
// identifiers used in the Protocol Buffer language, not to natural-language
|
||||
// strings.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline void LowerString(string * s) {
|
||||
string::iterator end = s->end();
|
||||
for (string::iterator i = s->begin(); i != end; ++i) {
|
||||
// tolower() changes based on locale. We don't want this!
|
||||
if ('A' <= *i && *i <= 'Z') *i += 'a' - 'A';
|
||||
}
|
||||
}
|
||||
|
||||
inline void UpperString(string * s) {
|
||||
string::iterator end = s->end();
|
||||
for (string::iterator i = s->begin(); i != end; ++i) {
|
||||
// toupper() changes based on locale. We don't want this!
|
||||
if ('a' <= *i && *i <= 'z') *i += 'A' - 'a';
|
||||
}
|
||||
}
|
||||
|
||||
inline string ToUpper(const string& s) {
|
||||
string out = s;
|
||||
UpperString(&out);
|
||||
return out;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// StringReplace()
|
||||
// Give me a string and two patterns "old" and "new", and I replace
|
||||
// the first instance of "old" in the string with "new", if it
|
||||
// exists. RETURN a new string, regardless of whether the replacement
|
||||
// happened or not.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
LIBPROTOBUF_EXPORT string StringReplace(const string& s, const string& oldsub,
|
||||
const string& newsub, bool replace_all);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// SplitStringUsing()
|
||||
// Split a string using a character delimiter. Append the components
|
||||
// to 'result'. If there are consecutive delimiters, this function skips
|
||||
// over all of them.
|
||||
// ----------------------------------------------------------------------
|
||||
LIBPROTOBUF_EXPORT void SplitStringUsing(const string& full, const char* delim,
|
||||
vector<string>* res);
|
||||
|
||||
// Split a string using one or more byte delimiters, presented
|
||||
// as a nul-terminated c string. Append the components to 'result'.
|
||||
// If there are consecutive delimiters, this function will return
|
||||
// corresponding empty strings. If you want to drop the empty
|
||||
// strings, try SplitStringUsing().
|
||||
//
|
||||
// If "full" is the empty string, yields an empty string as the only value.
|
||||
// ----------------------------------------------------------------------
|
||||
LIBPROTOBUF_EXPORT void SplitStringAllowEmpty(const string& full,
|
||||
const char* delim,
|
||||
vector<string>* result);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Split()
|
||||
// Split a string using a character delimiter.
|
||||
// ----------------------------------------------------------------------
|
||||
inline vector<string> Split(
|
||||
const string& full, const char* delim, bool skip_empty = true) {
|
||||
vector<string> result;
|
||||
if (skip_empty) {
|
||||
SplitStringUsing(full, delim, &result);
|
||||
} else {
|
||||
SplitStringAllowEmpty(full, delim, &result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// JoinStrings()
|
||||
// These methods concatenate a vector of strings into a C++ string, using
|
||||
// the C-string "delim" as a separator between components. There are two
|
||||
// flavors of the function, one flavor returns the concatenated string,
|
||||
// another takes a pointer to the target string. In the latter case the
|
||||
// target string is cleared and overwritten.
|
||||
// ----------------------------------------------------------------------
|
||||
LIBPROTOBUF_EXPORT void JoinStrings(const vector<string>& components,
|
||||
const char* delim, string* result);
|
||||
|
||||
inline string JoinStrings(const vector<string>& components,
|
||||
const char* delim) {
|
||||
string result;
|
||||
JoinStrings(components, delim, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// UnescapeCEscapeSequences()
|
||||
// Copies "source" to "dest", rewriting C-style escape sequences
|
||||
// -- '\n', '\r', '\\', '\ooo', etc -- to their ASCII
|
||||
// equivalents. "dest" must be sufficiently large to hold all
|
||||
// the characters in the rewritten string (i.e. at least as large
|
||||
// as strlen(source) + 1 should be safe, since the replacements
|
||||
// are always shorter than the original escaped sequences). It's
|
||||
// safe for source and dest to be the same. RETURNS the length
|
||||
// of dest.
|
||||
//
|
||||
// It allows hex sequences \xhh, or generally \xhhhhh with an
|
||||
// arbitrary number of hex digits, but all of them together must
|
||||
// specify a value of a single byte (e.g. \x0045 is equivalent
|
||||
// to \x45, and \x1234 is erroneous).
|
||||
//
|
||||
// It also allows escape sequences of the form \uhhhh (exactly four
|
||||
// hex digits, upper or lower case) or \Uhhhhhhhh (exactly eight
|
||||
// hex digits, upper or lower case) to specify a Unicode code
|
||||
// point. The dest array will contain the UTF8-encoded version of
|
||||
// that code-point (e.g., if source contains \u2019, then dest will
|
||||
// contain the three bytes 0xE2, 0x80, and 0x99).
|
||||
//
|
||||
// Errors: In the first form of the call, errors are reported with
|
||||
// LOG(ERROR). The same is true for the second form of the call if
|
||||
// the pointer to the string vector is NULL; otherwise, error
|
||||
// messages are stored in the vector. In either case, the effect on
|
||||
// the dest array is not defined, but rest of the source will be
|
||||
// processed.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest);
|
||||
LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest,
|
||||
vector<string> *errors);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// UnescapeCEscapeString()
|
||||
// This does the same thing as UnescapeCEscapeSequences, but creates
|
||||
// a new string. The caller does not need to worry about allocating
|
||||
// a dest buffer. This should be used for non performance critical
|
||||
// tasks such as printing debug messages. It is safe for src and dest
|
||||
// to be the same.
|
||||
//
|
||||
// The second call stores its errors in a supplied string vector.
|
||||
// If the string vector pointer is NULL, it reports the errors with LOG().
|
||||
//
|
||||
// In the first and second calls, the length of dest is returned. In the
|
||||
// the third call, the new string is returned.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
LIBPROTOBUF_EXPORT int UnescapeCEscapeString(const string& src, string* dest);
|
||||
LIBPROTOBUF_EXPORT int UnescapeCEscapeString(const string& src, string* dest,
|
||||
vector<string> *errors);
|
||||
LIBPROTOBUF_EXPORT string UnescapeCEscapeString(const string& src);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// CEscapeString()
|
||||
// Copies 'src' to 'dest', escaping dangerous characters using
|
||||
// C-style escape sequences. This is very useful for preparing query
|
||||
// flags. 'src' and 'dest' should not overlap.
|
||||
// Returns the number of bytes written to 'dest' (not including the \0)
|
||||
// or -1 if there was insufficient space.
|
||||
//
|
||||
// Currently only \n, \r, \t, ", ', \ and !isprint() chars are escaped.
|
||||
// ----------------------------------------------------------------------
|
||||
LIBPROTOBUF_EXPORT int CEscapeString(const char* src, int src_len,
|
||||
char* dest, int dest_len);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// CEscape()
|
||||
// More convenient form of CEscapeString: returns result as a "string".
|
||||
// This version is slower than CEscapeString() because it does more
|
||||
// allocation. However, it is much more convenient to use in
|
||||
// non-speed-critical code like logging messages etc.
|
||||
// ----------------------------------------------------------------------
|
||||
LIBPROTOBUF_EXPORT string CEscape(const string& src);
|
||||
|
||||
namespace strings {
|
||||
// Like CEscape() but does not escape bytes with the upper bit set.
|
||||
LIBPROTOBUF_EXPORT string Utf8SafeCEscape(const string& src);
|
||||
|
||||
// Like CEscape() but uses hex (\x) escapes instead of octals.
|
||||
LIBPROTOBUF_EXPORT string CHexEscape(const string& src);
|
||||
} // namespace strings
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// strto32()
|
||||
// strtou32()
|
||||
// strto64()
|
||||
// strtou64()
|
||||
// Architecture-neutral plug compatible replacements for strtol() and
|
||||
// strtoul(). Long's have different lengths on ILP-32 and LP-64
|
||||
// platforms, so using these is safer, from the point of view of
|
||||
// overflow behavior, than using the standard libc functions.
|
||||
// ----------------------------------------------------------------------
|
||||
LIBPROTOBUF_EXPORT int32 strto32_adaptor(const char *nptr, char **endptr,
|
||||
int base);
|
||||
LIBPROTOBUF_EXPORT uint32 strtou32_adaptor(const char *nptr, char **endptr,
|
||||
int base);
|
||||
|
||||
inline int32 strto32(const char *nptr, char **endptr, int base) {
|
||||
if (sizeof(int32) == sizeof(long))
|
||||
return strtol(nptr, endptr, base);
|
||||
else
|
||||
return strto32_adaptor(nptr, endptr, base);
|
||||
}
|
||||
|
||||
inline uint32 strtou32(const char *nptr, char **endptr, int base) {
|
||||
if (sizeof(uint32) == sizeof(unsigned long))
|
||||
return strtoul(nptr, endptr, base);
|
||||
else
|
||||
return strtou32_adaptor(nptr, endptr, base);
|
||||
}
|
||||
|
||||
// For now, long long is 64-bit on all the platforms we care about, so these
|
||||
// functions can simply pass the call to strto[u]ll.
|
||||
inline int64 strto64(const char *nptr, char **endptr, int base) {
|
||||
GOOGLE_COMPILE_ASSERT(sizeof(int64) == sizeof(long long),
|
||||
sizeof_int64_is_not_sizeof_long_long);
|
||||
return strtoll(nptr, endptr, base);
|
||||
}
|
||||
|
||||
inline uint64 strtou64(const char *nptr, char **endptr, int base) {
|
||||
GOOGLE_COMPILE_ASSERT(sizeof(uint64) == sizeof(unsigned long long),
|
||||
sizeof_uint64_is_not_sizeof_long_long);
|
||||
return strtoull(nptr, endptr, base);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// safe_strto32()
|
||||
// ----------------------------------------------------------------------
|
||||
LIBPROTOBUF_EXPORT bool safe_int(string text, int32* value_p);
|
||||
|
||||
inline bool safe_strto32(string text, int32* value) {
|
||||
return safe_int(text, value);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// FastIntToBuffer()
|
||||
// FastHexToBuffer()
|
||||
// FastHex64ToBuffer()
|
||||
// FastHex32ToBuffer()
|
||||
// FastTimeToBuffer()
|
||||
// These are intended for speed. FastIntToBuffer() assumes the
|
||||
// integer is non-negative. FastHexToBuffer() puts output in
|
||||
// hex rather than decimal. FastTimeToBuffer() puts the output
|
||||
// into RFC822 format.
|
||||
//
|
||||
// FastHex64ToBuffer() puts a 64-bit unsigned value in hex-format,
|
||||
// padded to exactly 16 bytes (plus one byte for '\0')
|
||||
//
|
||||
// FastHex32ToBuffer() puts a 32-bit unsigned value in hex-format,
|
||||
// padded to exactly 8 bytes (plus one byte for '\0')
|
||||
//
|
||||
// All functions take the output buffer as an arg.
|
||||
// They all return a pointer to the beginning of the output,
|
||||
// which may not be the beginning of the input buffer.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// Suggested buffer size for FastToBuffer functions. Also works with
|
||||
// DoubleToBuffer() and FloatToBuffer().
|
||||
static const int kFastToBufferSize = 32;
|
||||
|
||||
LIBPROTOBUF_EXPORT char* FastInt32ToBuffer(int32 i, char* buffer);
|
||||
LIBPROTOBUF_EXPORT char* FastInt64ToBuffer(int64 i, char* buffer);
|
||||
char* FastUInt32ToBuffer(uint32 i, char* buffer); // inline below
|
||||
char* FastUInt64ToBuffer(uint64 i, char* buffer); // inline below
|
||||
LIBPROTOBUF_EXPORT char* FastHexToBuffer(int i, char* buffer);
|
||||
LIBPROTOBUF_EXPORT char* FastHex64ToBuffer(uint64 i, char* buffer);
|
||||
LIBPROTOBUF_EXPORT char* FastHex32ToBuffer(uint32 i, char* buffer);
|
||||
|
||||
// at least 22 bytes long
|
||||
inline char* FastIntToBuffer(int i, char* buffer) {
|
||||
return (sizeof(i) == 4 ?
|
||||
FastInt32ToBuffer(i, buffer) : FastInt64ToBuffer(i, buffer));
|
||||
}
|
||||
inline char* FastUIntToBuffer(unsigned int i, char* buffer) {
|
||||
return (sizeof(i) == 4 ?
|
||||
FastUInt32ToBuffer(i, buffer) : FastUInt64ToBuffer(i, buffer));
|
||||
}
|
||||
inline char* FastLongToBuffer(long i, char* buffer) {
|
||||
return (sizeof(i) == 4 ?
|
||||
FastInt32ToBuffer(i, buffer) : FastInt64ToBuffer(i, buffer));
|
||||
}
|
||||
inline char* FastULongToBuffer(unsigned long i, char* buffer) {
|
||||
return (sizeof(i) == 4 ?
|
||||
FastUInt32ToBuffer(i, buffer) : FastUInt64ToBuffer(i, buffer));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// FastInt32ToBufferLeft()
|
||||
// FastUInt32ToBufferLeft()
|
||||
// FastInt64ToBufferLeft()
|
||||
// FastUInt64ToBufferLeft()
|
||||
//
|
||||
// Like the Fast*ToBuffer() functions above, these are intended for speed.
|
||||
// Unlike the Fast*ToBuffer() functions, however, these functions write
|
||||
// their output to the beginning of the buffer (hence the name, as the
|
||||
// output is left-aligned). The caller is responsible for ensuring that
|
||||
// the buffer has enough space to hold the output.
|
||||
//
|
||||
// Returns a pointer to the end of the string (i.e. the null character
|
||||
// terminating the string).
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
LIBPROTOBUF_EXPORT char* FastInt32ToBufferLeft(int32 i, char* buffer);
|
||||
LIBPROTOBUF_EXPORT char* FastUInt32ToBufferLeft(uint32 i, char* buffer);
|
||||
LIBPROTOBUF_EXPORT char* FastInt64ToBufferLeft(int64 i, char* buffer);
|
||||
LIBPROTOBUF_EXPORT char* FastUInt64ToBufferLeft(uint64 i, char* buffer);
|
||||
|
||||
// Just define these in terms of the above.
|
||||
inline char* FastUInt32ToBuffer(uint32 i, char* buffer) {
|
||||
FastUInt32ToBufferLeft(i, buffer);
|
||||
return buffer;
|
||||
}
|
||||
inline char* FastUInt64ToBuffer(uint64 i, char* buffer) {
|
||||
FastUInt64ToBufferLeft(i, buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// SimpleItoa()
|
||||
// Description: converts an integer to a string.
|
||||
//
|
||||
// Return value: string
|
||||
// ----------------------------------------------------------------------
|
||||
LIBPROTOBUF_EXPORT string SimpleItoa(int i);
|
||||
LIBPROTOBUF_EXPORT string SimpleItoa(unsigned int i);
|
||||
LIBPROTOBUF_EXPORT string SimpleItoa(long i);
|
||||
LIBPROTOBUF_EXPORT string SimpleItoa(unsigned long i);
|
||||
LIBPROTOBUF_EXPORT string SimpleItoa(long long i);
|
||||
LIBPROTOBUF_EXPORT string SimpleItoa(unsigned long long i);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// SimpleDtoa()
|
||||
// SimpleFtoa()
|
||||
// DoubleToBuffer()
|
||||
// FloatToBuffer()
|
||||
// Description: converts a double or float to a string which, if
|
||||
// passed to NoLocaleStrtod(), will produce the exact same original double
|
||||
// (except in case of NaN; all NaNs are considered the same value).
|
||||
// We try to keep the string short but it's not guaranteed to be as
|
||||
// short as possible.
|
||||
//
|
||||
// DoubleToBuffer() and FloatToBuffer() write the text to the given
|
||||
// buffer and return it. The buffer must be at least
|
||||
// kDoubleToBufferSize bytes for doubles and kFloatToBufferSize
|
||||
// bytes for floats. kFastToBufferSize is also guaranteed to be large
|
||||
// enough to hold either.
|
||||
//
|
||||
// Return value: string
|
||||
// ----------------------------------------------------------------------
|
||||
LIBPROTOBUF_EXPORT string SimpleDtoa(double value);
|
||||
LIBPROTOBUF_EXPORT string SimpleFtoa(float value);
|
||||
|
||||
LIBPROTOBUF_EXPORT char* DoubleToBuffer(double i, char* buffer);
|
||||
LIBPROTOBUF_EXPORT char* FloatToBuffer(float i, char* buffer);
|
||||
|
||||
// In practice, doubles should never need more than 24 bytes and floats
|
||||
// should never need more than 14 (including null terminators), but we
|
||||
// overestimate to be safe.
|
||||
static const int kDoubleToBufferSize = 32;
|
||||
static const int kFloatToBufferSize = 24;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// ToString() are internal help methods used in StrCat() and Join()
|
||||
// ----------------------------------------------------------------------
|
||||
namespace internal {
|
||||
inline string ToString(int i) {
|
||||
return SimpleItoa(i);
|
||||
}
|
||||
|
||||
inline string ToString(string a) {
|
||||
return a;
|
||||
}
|
||||
} // namespace internal
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// StrCat()
|
||||
// These methods join some strings together.
|
||||
// ----------------------------------------------------------------------
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
string StrCat(
|
||||
const T1& a, const T2& b, const T3& c, const T4& d, const T5& e) {
|
||||
return internal::ToString(a) + internal::ToString(b) +
|
||||
internal::ToString(c) + internal::ToString(d) + internal::ToString(e);
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
string StrCat(
|
||||
const T1& a, const T2& b, const T3& c, const T4& d) {
|
||||
return internal::ToString(a) + internal::ToString(b) +
|
||||
internal::ToString(c) + internal::ToString(d);
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
string StrCat(const T1& a, const T2& b, const T3& c) {
|
||||
return internal::ToString(a) + internal::ToString(b) +
|
||||
internal::ToString(c);
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
string StrCat(const T1& a, const T2& b) {
|
||||
return internal::ToString(a) + internal::ToString(b);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Join()
|
||||
// These methods concatenate a range of components into a C++ string, using
|
||||
// the C-string "delim" as a separator between components.
|
||||
// ----------------------------------------------------------------------
|
||||
template <typename Iterator>
|
||||
void Join(Iterator start, Iterator end,
|
||||
const char* delim, string* result) {
|
||||
for (Iterator it = start; it != end; ++it) {
|
||||
if (it != start) {
|
||||
result->append(delim);
|
||||
}
|
||||
result->append(internal::ToString(*it));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Range>
|
||||
string Join(const Range& components,
|
||||
const char* delim) {
|
||||
string result;
|
||||
Join(components.begin(), components.end(), delim, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// ToHex()
|
||||
// Return a lower-case hex string representation of the given integer.
|
||||
// ----------------------------------------------------------------------
|
||||
LIBPROTOBUF_EXPORT string ToHex(uint64 num);
|
||||
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_STUBS_STRUTIL_H__
|
||||
@@ -1,134 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
|
||||
#include <google/protobuf/stubs/substitute.h>
|
||||
#include <google/protobuf/stubs/strutil.h>
|
||||
#include <google/protobuf/stubs/stl_util.h>
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace strings {
|
||||
|
||||
using internal::SubstituteArg;
|
||||
|
||||
// Returns the number of args in arg_array which were passed explicitly
|
||||
// to Substitute().
|
||||
static int CountSubstituteArgs(const SubstituteArg* const* args_array) {
|
||||
int count = 0;
|
||||
while (args_array[count] != NULL && args_array[count]->size() != -1) {
|
||||
++count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
string Substitute(
|
||||
const char* format,
|
||||
const SubstituteArg& arg0, const SubstituteArg& arg1,
|
||||
const SubstituteArg& arg2, const SubstituteArg& arg3,
|
||||
const SubstituteArg& arg4, const SubstituteArg& arg5,
|
||||
const SubstituteArg& arg6, const SubstituteArg& arg7,
|
||||
const SubstituteArg& arg8, const SubstituteArg& arg9) {
|
||||
string result;
|
||||
SubstituteAndAppend(&result, format, arg0, arg1, arg2, arg3, arg4,
|
||||
arg5, arg6, arg7, arg8, arg9);
|
||||
return result;
|
||||
}
|
||||
|
||||
void SubstituteAndAppend(
|
||||
string* output, const char* format,
|
||||
const SubstituteArg& arg0, const SubstituteArg& arg1,
|
||||
const SubstituteArg& arg2, const SubstituteArg& arg3,
|
||||
const SubstituteArg& arg4, const SubstituteArg& arg5,
|
||||
const SubstituteArg& arg6, const SubstituteArg& arg7,
|
||||
const SubstituteArg& arg8, const SubstituteArg& arg9) {
|
||||
const SubstituteArg* const args_array[] = {
|
||||
&arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, NULL
|
||||
};
|
||||
|
||||
// Determine total size needed.
|
||||
int size = 0;
|
||||
for (int i = 0; format[i] != '\0'; i++) {
|
||||
if (format[i] == '$') {
|
||||
if (ascii_isdigit(format[i+1])) {
|
||||
int index = format[i+1] - '0';
|
||||
if (args_array[index]->size() == -1) {
|
||||
GOOGLE_LOG(DFATAL)
|
||||
<< "strings::Substitute format string invalid: asked for \"$"
|
||||
<< index << "\", but only " << CountSubstituteArgs(args_array)
|
||||
<< " args were given. Full format string was: \""
|
||||
<< CEscape(format) << "\".";
|
||||
return;
|
||||
}
|
||||
size += args_array[index]->size();
|
||||
++i; // Skip next char.
|
||||
} else if (format[i+1] == '$') {
|
||||
++size;
|
||||
++i; // Skip next char.
|
||||
} else {
|
||||
GOOGLE_LOG(DFATAL)
|
||||
<< "Invalid strings::Substitute() format string: \""
|
||||
<< CEscape(format) << "\".";
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
++size;
|
||||
}
|
||||
}
|
||||
|
||||
if (size == 0) return;
|
||||
|
||||
// Build the string.
|
||||
int original_size = output->size();
|
||||
STLStringResizeUninitialized(output, original_size + size);
|
||||
char* target = string_as_array(output) + original_size;
|
||||
for (int i = 0; format[i] != '\0'; i++) {
|
||||
if (format[i] == '$') {
|
||||
if (ascii_isdigit(format[i+1])) {
|
||||
const SubstituteArg* src = args_array[format[i+1] - '0'];
|
||||
memcpy(target, src->data(), src->size());
|
||||
target += src->size();
|
||||
++i; // Skip next char.
|
||||
} else if (format[i+1] == '$') {
|
||||
*target++ = '$';
|
||||
++i; // Skip next char.
|
||||
}
|
||||
} else {
|
||||
*target++ = format[i];
|
||||
}
|
||||
}
|
||||
|
||||
GOOGLE_DCHECK_EQ(target - output->data(), output->size());
|
||||
}
|
||||
|
||||
} // namespace strings
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
@@ -1,170 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: [email protected] (Kenton Varda)
|
||||
// from google3/strings/substitute.h
|
||||
|
||||
#include <string>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/stubs/strutil.h>
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_STUBS_SUBSTITUTE_H_
|
||||
#define GOOGLE_PROTOBUF_STUBS_SUBSTITUTE_H_
|
||||
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
namespace strings {
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// strings::Substitute()
|
||||
// strings::SubstituteAndAppend()
|
||||
// Kind of like StringPrintf, but different.
|
||||
//
|
||||
// Example:
|
||||
// string GetMessage(string first_name, string last_name, int age) {
|
||||
// return strings::Substitute("My name is $0 $1 and I am $2 years old.",
|
||||
// first_name, last_name, age);
|
||||
// }
|
||||
//
|
||||
// Differences from StringPrintf:
|
||||
// * The format string does not identify the types of arguments.
|
||||
// Instead, the magic of C++ deals with this for us. See below
|
||||
// for a list of accepted types.
|
||||
// * Substitutions in the format string are identified by a '$'
|
||||
// followed by a digit. So, you can use arguments out-of-order and
|
||||
// use the same argument multiple times.
|
||||
// * It's much faster than StringPrintf.
|
||||
//
|
||||
// Supported types:
|
||||
// * Strings (const char*, const string&)
|
||||
// * Note that this means you do not have to add .c_str() to all of
|
||||
// your strings. In fact, you shouldn't; it will be slower.
|
||||
// * int32, int64, uint32, uint64: Formatted using SimpleItoa().
|
||||
// * float, double: Formatted using SimpleFtoa() and SimpleDtoa().
|
||||
// * bool: Printed as "true" or "false".
|
||||
//
|
||||
// SubstituteAndAppend() is like Substitute() but appends the result to
|
||||
// *output. Example:
|
||||
//
|
||||
// string str;
|
||||
// strings::SubstituteAndAppend(&str,
|
||||
// "My name is $0 $1 and I am $2 years old.",
|
||||
// first_name, last_name, age);
|
||||
//
|
||||
// Substitute() is significantly faster than StringPrintf(). For very
|
||||
// large strings, it may be orders of magnitude faster.
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace internal { // Implementation details.
|
||||
|
||||
class SubstituteArg {
|
||||
public:
|
||||
inline SubstituteArg(const char* value)
|
||||
: text_(value), size_(strlen(text_)) {}
|
||||
inline SubstituteArg(const string& value)
|
||||
: text_(value.data()), size_(value.size()) {}
|
||||
|
||||
// Indicates that no argument was given.
|
||||
inline explicit SubstituteArg()
|
||||
: text_(NULL), size_(-1) {}
|
||||
|
||||
// Primitives
|
||||
// We don't overload for signed and unsigned char because if people are
|
||||
// explicitly declaring their chars as signed or unsigned then they are
|
||||
// probably actually using them as 8-bit integers and would probably
|
||||
// prefer an integer representation. But, we don't really know. So, we
|
||||
// make the caller decide what to do.
|
||||
inline SubstituteArg(char value)
|
||||
: text_(scratch_), size_(1) { scratch_[0] = value; }
|
||||
inline SubstituteArg(short value)
|
||||
: text_(FastInt32ToBuffer(value, scratch_)), size_(strlen(text_)) {}
|
||||
inline SubstituteArg(unsigned short value)
|
||||
: text_(FastUInt32ToBuffer(value, scratch_)), size_(strlen(text_)) {}
|
||||
inline SubstituteArg(int value)
|
||||
: text_(FastInt32ToBuffer(value, scratch_)), size_(strlen(text_)) {}
|
||||
inline SubstituteArg(unsigned int value)
|
||||
: text_(FastUInt32ToBuffer(value, scratch_)), size_(strlen(text_)) {}
|
||||
inline SubstituteArg(long value)
|
||||
: text_(FastLongToBuffer(value, scratch_)), size_(strlen(text_)) {}
|
||||
inline SubstituteArg(unsigned long value)
|
||||
: text_(FastULongToBuffer(value, scratch_)), size_(strlen(text_)) {}
|
||||
inline SubstituteArg(long long value)
|
||||
: text_(FastInt64ToBuffer(value, scratch_)), size_(strlen(text_)) {}
|
||||
inline SubstituteArg(unsigned long long value)
|
||||
: text_(FastUInt64ToBuffer(value, scratch_)), size_(strlen(text_)) {}
|
||||
inline SubstituteArg(float value)
|
||||
: text_(FloatToBuffer(value, scratch_)), size_(strlen(text_)) {}
|
||||
inline SubstituteArg(double value)
|
||||
: text_(DoubleToBuffer(value, scratch_)), size_(strlen(text_)) {}
|
||||
inline SubstituteArg(bool value)
|
||||
: text_(value ? "true" : "false"), size_(strlen(text_)) {}
|
||||
|
||||
inline const char* data() const { return text_; }
|
||||
inline int size() const { return size_; }
|
||||
|
||||
private:
|
||||
const char* text_;
|
||||
int size_;
|
||||
char scratch_[kFastToBufferSize];
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
LIBPROTOBUF_EXPORT string Substitute(
|
||||
const char* format,
|
||||
const internal::SubstituteArg& arg0 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg1 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg2 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg3 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg4 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg5 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg6 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg7 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg8 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg9 = internal::SubstituteArg());
|
||||
|
||||
LIBPROTOBUF_EXPORT void SubstituteAndAppend(
|
||||
string* output, const char* format,
|
||||
const internal::SubstituteArg& arg0 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg1 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg2 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg3 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg4 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg5 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg6 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg7 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg8 = internal::SubstituteArg(),
|
||||
const internal::SubstituteArg& arg9 = internal::SubstituteArg());
|
||||
|
||||
} // namespace strings
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#endif // GOOGLE_PROTOBUF_STUBS_SUBSTITUTE_H_
|
||||
@@ -1,8 +0,0 @@
|
||||
#include "BnetCodeGenerator.h"
|
||||
#include <google/protobuf/compiler/plugin.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
BnetCodeGenerator gen;
|
||||
return google::protobuf::compiler::PluginMain(argc, argv, &gen);
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: method_options.proto
|
||||
|
||||
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
|
||||
#include "method_options.pb.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/stubs/once.h>
|
||||
#include <google/protobuf/io/coded_stream.h>
|
||||
#include <google/protobuf/wire_format_lite_inl.h>
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include <google/protobuf/generated_message_reflection.h>
|
||||
#include <google/protobuf/reflection_ops.h>
|
||||
#include <google/protobuf/wire_format.h>
|
||||
// @@protoc_insertion_point(includes)
|
||||
|
||||
namespace Battlenet {
|
||||
|
||||
namespace {
|
||||
|
||||
const ::google::protobuf::Descriptor* BGSMethodOptions_descriptor_ = NULL;
|
||||
const ::google::protobuf::internal::GeneratedMessageReflection*
|
||||
BGSMethodOptions_reflection_ = NULL;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
void protobuf_AssignDesc_method_5foptions_2eproto() {
|
||||
protobuf_AddDesc_method_5foptions_2eproto();
|
||||
const ::google::protobuf::FileDescriptor* file =
|
||||
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
|
||||
"method_options.proto");
|
||||
GOOGLE_CHECK(file != NULL);
|
||||
BGSMethodOptions_descriptor_ = file->message_type(0);
|
||||
static const int BGSMethodOptions_offsets_[1] = {
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BGSMethodOptions, id_),
|
||||
};
|
||||
BGSMethodOptions_reflection_ =
|
||||
new ::google::protobuf::internal::GeneratedMessageReflection(
|
||||
BGSMethodOptions_descriptor_,
|
||||
BGSMethodOptions::default_instance_,
|
||||
BGSMethodOptions_offsets_,
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BGSMethodOptions, _has_bits_[0]),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BGSMethodOptions, _unknown_fields_),
|
||||
-1,
|
||||
::google::protobuf::DescriptorPool::generated_pool(),
|
||||
::google::protobuf::MessageFactory::generated_factory(),
|
||||
sizeof(BGSMethodOptions));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
|
||||
inline void protobuf_AssignDescriptorsOnce() {
|
||||
::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
|
||||
&protobuf_AssignDesc_method_5foptions_2eproto);
|
||||
}
|
||||
|
||||
void protobuf_RegisterTypes(const ::std::string&) {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
|
||||
BGSMethodOptions_descriptor_, &BGSMethodOptions::default_instance());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void protobuf_ShutdownFile_method_5foptions_2eproto() {
|
||||
delete BGSMethodOptions::default_instance_;
|
||||
delete BGSMethodOptions_reflection_;
|
||||
}
|
||||
|
||||
void protobuf_AddDesc_method_5foptions_2eproto() {
|
||||
static bool already_here = false;
|
||||
if (already_here) return;
|
||||
already_here = true;
|
||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||
|
||||
::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();
|
||||
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
|
||||
"\n\024method_options.proto\022\tBattlenet\032 googl"
|
||||
"e/protobuf/descriptor.proto\"\036\n\020BGSMethod"
|
||||
"Options\022\n\n\002id\030\001 \001(\r:U\n\016method_options\022\036."
|
||||
"google.protobuf.MethodOptions\030\220\277\005 \001(\0132\033."
|
||||
"Battlenet.BGSMethodOptionsB%\n\rbnet.proto"
|
||||
"colB\022MethodOptionsProtoH\002", 225);
|
||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
||||
"method_options.proto", &protobuf_RegisterTypes);
|
||||
BGSMethodOptions::default_instance_ = new BGSMethodOptions();
|
||||
::google::protobuf::internal::ExtensionSet::RegisterMessageExtension(
|
||||
&::google::protobuf::MethodOptions::default_instance(),
|
||||
90000, 11, false, false,
|
||||
&::Battlenet::BGSMethodOptions::default_instance());
|
||||
BGSMethodOptions::default_instance_->InitAsDefaultInstance();
|
||||
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_method_5foptions_2eproto);
|
||||
}
|
||||
|
||||
// Force AddDescriptors() to be called at static initialization time.
|
||||
struct StaticDescriptorInitializer_method_5foptions_2eproto {
|
||||
StaticDescriptorInitializer_method_5foptions_2eproto() {
|
||||
protobuf_AddDesc_method_5foptions_2eproto();
|
||||
}
|
||||
} static_descriptor_initializer_method_5foptions_2eproto_;
|
||||
|
||||
// ===================================================================
|
||||
|
||||
#ifndef _MSC_VER
|
||||
const int BGSMethodOptions::kIdFieldNumber;
|
||||
#endif // !_MSC_VER
|
||||
|
||||
BGSMethodOptions::BGSMethodOptions()
|
||||
: ::google::protobuf::Message() {
|
||||
SharedCtor();
|
||||
// @@protoc_insertion_point(constructor:Battlenet.BGSMethodOptions)
|
||||
}
|
||||
|
||||
void BGSMethodOptions::InitAsDefaultInstance() {
|
||||
}
|
||||
|
||||
BGSMethodOptions::BGSMethodOptions(const BGSMethodOptions& from)
|
||||
: ::google::protobuf::Message() {
|
||||
SharedCtor();
|
||||
MergeFrom(from);
|
||||
// @@protoc_insertion_point(copy_constructor:Battlenet.BGSMethodOptions)
|
||||
}
|
||||
|
||||
void BGSMethodOptions::SharedCtor() {
|
||||
_cached_size_ = 0;
|
||||
id_ = 0u;
|
||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||
}
|
||||
|
||||
BGSMethodOptions::~BGSMethodOptions() {
|
||||
// @@protoc_insertion_point(destructor:Battlenet.BGSMethodOptions)
|
||||
SharedDtor();
|
||||
}
|
||||
|
||||
void BGSMethodOptions::SharedDtor() {
|
||||
if (this != default_instance_) {
|
||||
}
|
||||
}
|
||||
|
||||
void BGSMethodOptions::SetCachedSize(int size) const {
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
||||
_cached_size_ = size;
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||
}
|
||||
const ::google::protobuf::Descriptor* BGSMethodOptions::descriptor() {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
return BGSMethodOptions_descriptor_;
|
||||
}
|
||||
|
||||
const BGSMethodOptions& BGSMethodOptions::default_instance() {
|
||||
if (default_instance_ == NULL) protobuf_AddDesc_method_5foptions_2eproto();
|
||||
return *default_instance_;
|
||||
}
|
||||
|
||||
BGSMethodOptions* BGSMethodOptions::default_instance_ = NULL;
|
||||
|
||||
BGSMethodOptions* BGSMethodOptions::New() const {
|
||||
return new BGSMethodOptions;
|
||||
}
|
||||
|
||||
void BGSMethodOptions::Swap(BGSMethodOptions* other) {
|
||||
if (other != this) {
|
||||
GetReflection()->Swap(this, other);}
|
||||
}
|
||||
|
||||
::google::protobuf::Metadata BGSMethodOptions::GetMetadata() const {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
::google::protobuf::Metadata metadata;
|
||||
metadata.descriptor = BGSMethodOptions_descriptor_;
|
||||
metadata.reflection = BGSMethodOptions_reflection_;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::MethodOptions,
|
||||
::google::protobuf::internal::MessageTypeTraits< ::Battlenet::BGSMethodOptions >, 11, false >
|
||||
method_options(kMethodOptionsFieldNumber, ::Battlenet::BGSMethodOptions::default_instance());
|
||||
|
||||
// @@protoc_insertion_point(namespace_scope)
|
||||
|
||||
} // namespace Battlenet
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
@@ -1,156 +0,0 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: method_options.proto
|
||||
|
||||
#ifndef PROTOBUF_method_5foptions_2eproto__INCLUDED
|
||||
#define PROTOBUF_method_5foptions_2eproto__INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
#if GOOGLE_PROTOBUF_VERSION < 2006000
|
||||
#error This file was generated by a newer version of protoc which is
|
||||
#error incompatible with your Protocol Buffer headers. Please update
|
||||
#error your headers.
|
||||
#endif
|
||||
#if 2006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
||||
#error This file was generated by an older version of protoc which is
|
||||
#error incompatible with your Protocol Buffer headers. Please
|
||||
#error regenerate this file with a newer version of protoc.
|
||||
#endif
|
||||
|
||||
#include <google/protobuf/generated_message_util.h>
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/repeated_field.h>
|
||||
#include <google/protobuf/extension_set.h>
|
||||
#include <google/protobuf/unknown_field_set.h>
|
||||
#include "google/protobuf/descriptor.pb.h"
|
||||
// @@protoc_insertion_point(includes)
|
||||
|
||||
namespace Battlenet {
|
||||
|
||||
// Internal implementation detail -- do not call these.
|
||||
void protobuf_AddDesc_method_5foptions_2eproto();
|
||||
void protobuf_AssignDesc_method_5foptions_2eproto();
|
||||
void protobuf_ShutdownFile_method_5foptions_2eproto();
|
||||
|
||||
class BGSMethodOptions;
|
||||
|
||||
// ===================================================================
|
||||
|
||||
class BGSMethodOptions : public ::google::protobuf::Message {
|
||||
public:
|
||||
BGSMethodOptions();
|
||||
virtual ~BGSMethodOptions();
|
||||
|
||||
BGSMethodOptions(const BGSMethodOptions& from);
|
||||
|
||||
inline BGSMethodOptions& operator=(const BGSMethodOptions& from) {
|
||||
CopyFrom(from);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
|
||||
return _unknown_fields_;
|
||||
}
|
||||
|
||||
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
|
||||
return &_unknown_fields_;
|
||||
}
|
||||
|
||||
static const ::google::protobuf::Descriptor* descriptor();
|
||||
static const BGSMethodOptions& default_instance();
|
||||
|
||||
void Swap(BGSMethodOptions* other);
|
||||
|
||||
// implements Message ----------------------------------------------
|
||||
|
||||
BGSMethodOptions* New() const;
|
||||
int GetCachedSize() const { return _cached_size_; }
|
||||
private:
|
||||
void SharedCtor();
|
||||
void SharedDtor();
|
||||
void SetCachedSize(int size) const;
|
||||
public:
|
||||
::google::protobuf::Metadata GetMetadata() const;
|
||||
|
||||
// nested types ----------------------------------------------------
|
||||
|
||||
// accessors -------------------------------------------------------
|
||||
|
||||
// optional uint32 id = 1;
|
||||
inline bool has_id() const;
|
||||
inline void clear_id();
|
||||
static const int kIdFieldNumber = 1;
|
||||
inline ::google::protobuf::uint32 id() const;
|
||||
inline void set_id(::google::protobuf::uint32 value);
|
||||
|
||||
// @@protoc_insertion_point(class_scope:Battlenet.BGSMethodOptions)
|
||||
private:
|
||||
inline void set_has_id();
|
||||
inline void clear_has_id();
|
||||
|
||||
::google::protobuf::UnknownFieldSet _unknown_fields_;
|
||||
|
||||
::google::protobuf::uint32 _has_bits_[1];
|
||||
mutable int _cached_size_;
|
||||
::google::protobuf::uint32 id_;
|
||||
friend void protobuf_AddDesc_method_5foptions_2eproto();
|
||||
friend void protobuf_AssignDesc_method_5foptions_2eproto();
|
||||
friend void protobuf_ShutdownFile_method_5foptions_2eproto();
|
||||
|
||||
void InitAsDefaultInstance();
|
||||
static BGSMethodOptions* default_instance_;
|
||||
};
|
||||
// ===================================================================
|
||||
|
||||
static const int kMethodOptionsFieldNumber = 90000;
|
||||
extern ::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::MethodOptions,
|
||||
::google::protobuf::internal::MessageTypeTraits< ::Battlenet::BGSMethodOptions >, 11, false >
|
||||
method_options;
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// BGSMethodOptions
|
||||
|
||||
// optional uint32 id = 1;
|
||||
inline bool BGSMethodOptions::has_id() const {
|
||||
return (_has_bits_[0] & 0x00000001u) != 0;
|
||||
}
|
||||
inline void BGSMethodOptions::set_has_id() {
|
||||
_has_bits_[0] |= 0x00000001u;
|
||||
}
|
||||
inline void BGSMethodOptions::clear_has_id() {
|
||||
_has_bits_[0] &= ~0x00000001u;
|
||||
}
|
||||
inline void BGSMethodOptions::clear_id() {
|
||||
id_ = 0u;
|
||||
clear_has_id();
|
||||
}
|
||||
inline ::google::protobuf::uint32 BGSMethodOptions::id() const {
|
||||
// @@protoc_insertion_point(field_get:Battlenet.BGSMethodOptions.id)
|
||||
return id_;
|
||||
}
|
||||
inline void BGSMethodOptions::set_id(::google::protobuf::uint32 value) {
|
||||
set_has_id();
|
||||
id_ = value;
|
||||
// @@protoc_insertion_point(field_set:Battlenet.BGSMethodOptions.id)
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(namespace_scope)
|
||||
|
||||
} // namespace Battlenet
|
||||
|
||||
#ifndef SWIG
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
|
||||
} // namespace google
|
||||
} // namespace protobuf
|
||||
#endif // SWIG
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
#endif // PROTOBUF_method_5foptions_2eproto__INCLUDED
|
||||
@@ -1,315 +0,0 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: service_options.proto
|
||||
|
||||
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
|
||||
#include "service_options.pb.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/stubs/once.h>
|
||||
#include <google/protobuf/io/coded_stream.h>
|
||||
#include <google/protobuf/wire_format_lite_inl.h>
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include <google/protobuf/generated_message_reflection.h>
|
||||
#include <google/protobuf/reflection_ops.h>
|
||||
#include <google/protobuf/wire_format.h>
|
||||
// @@protoc_insertion_point(includes)
|
||||
|
||||
namespace Battlenet {
|
||||
|
||||
namespace {
|
||||
|
||||
const ::google::protobuf::Descriptor* BGSServiceOptions_descriptor_ = NULL;
|
||||
const ::google::protobuf::internal::GeneratedMessageReflection*
|
||||
BGSServiceOptions_reflection_ = NULL;
|
||||
const ::google::protobuf::Descriptor* SDKServiceOptions_descriptor_ = NULL;
|
||||
const ::google::protobuf::internal::GeneratedMessageReflection*
|
||||
SDKServiceOptions_reflection_ = NULL;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
void protobuf_AssignDesc_service_5foptions_2eproto() {
|
||||
protobuf_AddDesc_service_5foptions_2eproto();
|
||||
const ::google::protobuf::FileDescriptor* file =
|
||||
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
|
||||
"service_options.proto");
|
||||
GOOGLE_CHECK(file != NULL);
|
||||
BGSServiceOptions_descriptor_ = file->message_type(0);
|
||||
static const int BGSServiceOptions_offsets_[3] = {
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BGSServiceOptions, descriptor_name_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BGSServiceOptions, version_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BGSServiceOptions, shard_name_),
|
||||
};
|
||||
BGSServiceOptions_reflection_ =
|
||||
new ::google::protobuf::internal::GeneratedMessageReflection(
|
||||
BGSServiceOptions_descriptor_,
|
||||
BGSServiceOptions::default_instance_,
|
||||
BGSServiceOptions_offsets_,
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BGSServiceOptions, _has_bits_[0]),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BGSServiceOptions, _unknown_fields_),
|
||||
-1,
|
||||
::google::protobuf::DescriptorPool::generated_pool(),
|
||||
::google::protobuf::MessageFactory::generated_factory(),
|
||||
sizeof(BGSServiceOptions));
|
||||
SDKServiceOptions_descriptor_ = file->message_type(1);
|
||||
static const int SDKServiceOptions_offsets_[3] = {
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SDKServiceOptions, inbound_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SDKServiceOptions, outbound_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SDKServiceOptions, use_client_id_),
|
||||
};
|
||||
SDKServiceOptions_reflection_ =
|
||||
new ::google::protobuf::internal::GeneratedMessageReflection(
|
||||
SDKServiceOptions_descriptor_,
|
||||
SDKServiceOptions::default_instance_,
|
||||
SDKServiceOptions_offsets_,
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SDKServiceOptions, _has_bits_[0]),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SDKServiceOptions, _unknown_fields_),
|
||||
-1,
|
||||
::google::protobuf::DescriptorPool::generated_pool(),
|
||||
::google::protobuf::MessageFactory::generated_factory(),
|
||||
sizeof(SDKServiceOptions));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
|
||||
inline void protobuf_AssignDescriptorsOnce() {
|
||||
::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
|
||||
&protobuf_AssignDesc_service_5foptions_2eproto);
|
||||
}
|
||||
|
||||
void protobuf_RegisterTypes(const ::std::string&) {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
|
||||
BGSServiceOptions_descriptor_, &BGSServiceOptions::default_instance());
|
||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
|
||||
SDKServiceOptions_descriptor_, &SDKServiceOptions::default_instance());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void protobuf_ShutdownFile_service_5foptions_2eproto() {
|
||||
delete BGSServiceOptions::default_instance_;
|
||||
delete BGSServiceOptions_reflection_;
|
||||
delete SDKServiceOptions::default_instance_;
|
||||
delete SDKServiceOptions_reflection_;
|
||||
}
|
||||
|
||||
void protobuf_AddDesc_service_5foptions_2eproto() {
|
||||
static bool already_here = false;
|
||||
if (already_here) return;
|
||||
already_here = true;
|
||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||
|
||||
::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();
|
||||
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
|
||||
"\n\025service_options.proto\022\tBattlenet\032 goog"
|
||||
"le/protobuf/descriptor.proto\"Q\n\021BGSServi"
|
||||
"ceOptions\022\027\n\017descriptor_name\030\001 \001(\t\022\017\n\007ve"
|
||||
"rsion\030\004 \001(\r\022\022\n\nshard_name\030\005 \001(\t\"M\n\021SDKSe"
|
||||
"rviceOptions\022\017\n\007inbound\030\001 \001(\010\022\020\n\010outboun"
|
||||
"d\030\002 \001(\010\022\025\n\ruse_client_id\030\003 \001(\010:X\n\017servic"
|
||||
"e_options\022\037.google.protobuf.ServiceOptio"
|
||||
"ns\030\220\277\005 \001(\0132\034.Battlenet.BGSServiceOptions"
|
||||
":\\\n\023sdk_service_options\022\037.google.protobu"
|
||||
"f.ServiceOptions\030\221\277\005 \001(\0132\034.Battlenet.SDK"
|
||||
"ServiceOptionsB&\n\rbnet.protocolB\023Service"
|
||||
"OptionsProtoH\002", 454);
|
||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
||||
"service_options.proto", &protobuf_RegisterTypes);
|
||||
BGSServiceOptions::default_instance_ = new BGSServiceOptions();
|
||||
SDKServiceOptions::default_instance_ = new SDKServiceOptions();
|
||||
::google::protobuf::internal::ExtensionSet::RegisterMessageExtension(
|
||||
&::google::protobuf::ServiceOptions::default_instance(),
|
||||
90000, 11, false, false,
|
||||
&::Battlenet::BGSServiceOptions::default_instance());
|
||||
::google::protobuf::internal::ExtensionSet::RegisterMessageExtension(
|
||||
&::google::protobuf::ServiceOptions::default_instance(),
|
||||
90001, 11, false, false,
|
||||
&::Battlenet::SDKServiceOptions::default_instance());
|
||||
BGSServiceOptions::default_instance_->InitAsDefaultInstance();
|
||||
SDKServiceOptions::default_instance_->InitAsDefaultInstance();
|
||||
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_service_5foptions_2eproto);
|
||||
}
|
||||
|
||||
// Force AddDescriptors() to be called at static initialization time.
|
||||
struct StaticDescriptorInitializer_service_5foptions_2eproto {
|
||||
StaticDescriptorInitializer_service_5foptions_2eproto() {
|
||||
protobuf_AddDesc_service_5foptions_2eproto();
|
||||
}
|
||||
} static_descriptor_initializer_service_5foptions_2eproto_;
|
||||
|
||||
// ===================================================================
|
||||
|
||||
#ifndef _MSC_VER
|
||||
const int BGSServiceOptions::kDescriptorNameFieldNumber;
|
||||
const int BGSServiceOptions::kVersionFieldNumber;
|
||||
const int BGSServiceOptions::kShardNameFieldNumber;
|
||||
#endif // !_MSC_VER
|
||||
|
||||
BGSServiceOptions::BGSServiceOptions()
|
||||
: ::google::protobuf::Message() {
|
||||
SharedCtor();
|
||||
// @@protoc_insertion_point(constructor:Battlenet.BGSServiceOptions)
|
||||
}
|
||||
|
||||
void BGSServiceOptions::InitAsDefaultInstance() {
|
||||
}
|
||||
|
||||
BGSServiceOptions::BGSServiceOptions(const BGSServiceOptions& from)
|
||||
: ::google::protobuf::Message() {
|
||||
SharedCtor();
|
||||
MergeFrom(from);
|
||||
// @@protoc_insertion_point(copy_constructor:Battlenet.BGSServiceOptions)
|
||||
}
|
||||
|
||||
void BGSServiceOptions::SharedCtor() {
|
||||
::google::protobuf::internal::GetEmptyString();
|
||||
_cached_size_ = 0;
|
||||
descriptor_name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||
version_ = 0u;
|
||||
shard_name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||
}
|
||||
|
||||
BGSServiceOptions::~BGSServiceOptions() {
|
||||
// @@protoc_insertion_point(destructor:Battlenet.BGSServiceOptions)
|
||||
SharedDtor();
|
||||
}
|
||||
|
||||
void BGSServiceOptions::SharedDtor() {
|
||||
if (descriptor_name_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
|
||||
delete descriptor_name_;
|
||||
}
|
||||
if (shard_name_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
|
||||
delete shard_name_;
|
||||
}
|
||||
if (this != default_instance_) {
|
||||
}
|
||||
}
|
||||
|
||||
void BGSServiceOptions::SetCachedSize(int size) const {
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
||||
_cached_size_ = size;
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||
}
|
||||
const ::google::protobuf::Descriptor* BGSServiceOptions::descriptor() {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
return BGSServiceOptions_descriptor_;
|
||||
}
|
||||
|
||||
const BGSServiceOptions& BGSServiceOptions::default_instance() {
|
||||
if (default_instance_ == NULL) protobuf_AddDesc_service_5foptions_2eproto();
|
||||
return *default_instance_;
|
||||
}
|
||||
|
||||
BGSServiceOptions* BGSServiceOptions::default_instance_ = NULL;
|
||||
|
||||
BGSServiceOptions* BGSServiceOptions::New() const {
|
||||
return new BGSServiceOptions;
|
||||
}
|
||||
|
||||
void BGSServiceOptions::Swap(BGSServiceOptions* other) {
|
||||
if (other != this) {
|
||||
GetReflection()->Swap(this, other);}
|
||||
}
|
||||
|
||||
::google::protobuf::Metadata BGSServiceOptions::GetMetadata() const {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
::google::protobuf::Metadata metadata;
|
||||
metadata.descriptor = BGSServiceOptions_descriptor_;
|
||||
metadata.reflection = BGSServiceOptions_reflection_;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
|
||||
// ===================================================================
|
||||
|
||||
#ifndef _MSC_VER
|
||||
const int SDKServiceOptions::kInboundFieldNumber;
|
||||
const int SDKServiceOptions::kOutboundFieldNumber;
|
||||
const int SDKServiceOptions::kUseClientIdFieldNumber;
|
||||
#endif // !_MSC_VER
|
||||
|
||||
SDKServiceOptions::SDKServiceOptions()
|
||||
: ::google::protobuf::Message() {
|
||||
SharedCtor();
|
||||
// @@protoc_insertion_point(constructor:Battlenet.SDKServiceOptions)
|
||||
}
|
||||
|
||||
void SDKServiceOptions::InitAsDefaultInstance() {
|
||||
}
|
||||
|
||||
SDKServiceOptions::SDKServiceOptions(const SDKServiceOptions& from)
|
||||
: ::google::protobuf::Message() {
|
||||
SharedCtor();
|
||||
MergeFrom(from);
|
||||
// @@protoc_insertion_point(copy_constructor:Battlenet.SDKServiceOptions)
|
||||
}
|
||||
|
||||
void SDKServiceOptions::SharedCtor() {
|
||||
_cached_size_ = 0;
|
||||
inbound_ = false;
|
||||
outbound_ = false;
|
||||
use_client_id_ = false;
|
||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||
}
|
||||
|
||||
SDKServiceOptions::~SDKServiceOptions() {
|
||||
// @@protoc_insertion_point(destructor:Battlenet.SDKServiceOptions)
|
||||
SharedDtor();
|
||||
}
|
||||
|
||||
void SDKServiceOptions::SharedDtor() {
|
||||
if (this != default_instance_) {
|
||||
}
|
||||
}
|
||||
|
||||
void SDKServiceOptions::SetCachedSize(int size) const {
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
||||
_cached_size_ = size;
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||
}
|
||||
const ::google::protobuf::Descriptor* SDKServiceOptions::descriptor() {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
return SDKServiceOptions_descriptor_;
|
||||
}
|
||||
|
||||
const SDKServiceOptions& SDKServiceOptions::default_instance() {
|
||||
if (default_instance_ == NULL) protobuf_AddDesc_service_5foptions_2eproto();
|
||||
return *default_instance_;
|
||||
}
|
||||
|
||||
SDKServiceOptions* SDKServiceOptions::default_instance_ = NULL;
|
||||
|
||||
SDKServiceOptions* SDKServiceOptions::New() const {
|
||||
return new SDKServiceOptions;
|
||||
}
|
||||
|
||||
void SDKServiceOptions::Swap(SDKServiceOptions* other) {
|
||||
if (other != this) {
|
||||
GetReflection()->Swap(this, other);}
|
||||
}
|
||||
|
||||
::google::protobuf::Metadata SDKServiceOptions::GetMetadata() const {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
::google::protobuf::Metadata metadata;
|
||||
metadata.descriptor = SDKServiceOptions_descriptor_;
|
||||
metadata.reflection = SDKServiceOptions_reflection_;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::ServiceOptions,
|
||||
::google::protobuf::internal::MessageTypeTraits< ::Battlenet::BGSServiceOptions >, 11, false >
|
||||
service_options(kServiceOptionsFieldNumber, ::Battlenet::BGSServiceOptions::default_instance());
|
||||
::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::ServiceOptions,
|
||||
::google::protobuf::internal::MessageTypeTraits< ::Battlenet::SDKServiceOptions >, 11, false >
|
||||
sdk_service_options(kSdkServiceOptionsFieldNumber, ::Battlenet::SDKServiceOptions::default_instance());
|
||||
|
||||
// @@protoc_insertion_point(namespace_scope)
|
||||
|
||||
} // namespace Battlenet
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
@@ -1,505 +0,0 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: service_options.proto
|
||||
|
||||
#ifndef PROTOBUF_service_5foptions_2eproto__INCLUDED
|
||||
#define PROTOBUF_service_5foptions_2eproto__INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
#if GOOGLE_PROTOBUF_VERSION < 2006000
|
||||
#error This file was generated by a newer version of protoc which is
|
||||
#error incompatible with your Protocol Buffer headers. Please update
|
||||
#error your headers.
|
||||
#endif
|
||||
#if 2006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
||||
#error This file was generated by an older version of protoc which is
|
||||
#error incompatible with your Protocol Buffer headers. Please
|
||||
#error regenerate this file with a newer version of protoc.
|
||||
#endif
|
||||
|
||||
#include <google/protobuf/generated_message_util.h>
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/repeated_field.h>
|
||||
#include <google/protobuf/extension_set.h>
|
||||
#include <google/protobuf/unknown_field_set.h>
|
||||
#include "google/protobuf/descriptor.pb.h"
|
||||
// @@protoc_insertion_point(includes)
|
||||
|
||||
namespace Battlenet {
|
||||
|
||||
// Internal implementation detail -- do not call these.
|
||||
void protobuf_AddDesc_service_5foptions_2eproto();
|
||||
void protobuf_AssignDesc_service_5foptions_2eproto();
|
||||
void protobuf_ShutdownFile_service_5foptions_2eproto();
|
||||
|
||||
class BGSServiceOptions;
|
||||
class SDKServiceOptions;
|
||||
|
||||
// ===================================================================
|
||||
|
||||
class BGSServiceOptions : public ::google::protobuf::Message {
|
||||
public:
|
||||
BGSServiceOptions();
|
||||
virtual ~BGSServiceOptions();
|
||||
|
||||
BGSServiceOptions(const BGSServiceOptions& from);
|
||||
|
||||
inline BGSServiceOptions& operator=(const BGSServiceOptions& from) {
|
||||
CopyFrom(from);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
|
||||
return _unknown_fields_;
|
||||
}
|
||||
|
||||
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
|
||||
return &_unknown_fields_;
|
||||
}
|
||||
|
||||
static const ::google::protobuf::Descriptor* descriptor();
|
||||
static const BGSServiceOptions& default_instance();
|
||||
|
||||
void Swap(BGSServiceOptions* other);
|
||||
|
||||
// implements Message ----------------------------------------------
|
||||
|
||||
BGSServiceOptions* New() const;
|
||||
int GetCachedSize() const { return _cached_size_; }
|
||||
private:
|
||||
void SharedCtor();
|
||||
void SharedDtor();
|
||||
void SetCachedSize(int size) const;
|
||||
public:
|
||||
::google::protobuf::Metadata GetMetadata() const;
|
||||
|
||||
// nested types ----------------------------------------------------
|
||||
|
||||
// accessors -------------------------------------------------------
|
||||
|
||||
// optional string descriptor_name = 1;
|
||||
inline bool has_descriptor_name() const;
|
||||
inline void clear_descriptor_name();
|
||||
static const int kDescriptorNameFieldNumber = 1;
|
||||
inline const ::std::string& descriptor_name() const;
|
||||
inline void set_descriptor_name(const ::std::string& value);
|
||||
inline void set_descriptor_name(const char* value);
|
||||
inline void set_descriptor_name(const char* value, size_t size);
|
||||
inline ::std::string* mutable_descriptor_name();
|
||||
inline ::std::string* release_descriptor_name();
|
||||
inline void set_allocated_descriptor_name(::std::string* descriptor_name);
|
||||
|
||||
// optional uint32 version = 4;
|
||||
inline bool has_version() const;
|
||||
inline void clear_version();
|
||||
static const int kVersionFieldNumber = 4;
|
||||
inline ::google::protobuf::uint32 version() const;
|
||||
inline void set_version(::google::protobuf::uint32 value);
|
||||
|
||||
// optional string shard_name = 5;
|
||||
inline bool has_shard_name() const;
|
||||
inline void clear_shard_name();
|
||||
static const int kShardNameFieldNumber = 5;
|
||||
inline const ::std::string& shard_name() const;
|
||||
inline void set_shard_name(const ::std::string& value);
|
||||
inline void set_shard_name(const char* value);
|
||||
inline void set_shard_name(const char* value, size_t size);
|
||||
inline ::std::string* mutable_shard_name();
|
||||
inline ::std::string* release_shard_name();
|
||||
inline void set_allocated_shard_name(::std::string* shard_name);
|
||||
|
||||
// @@protoc_insertion_point(class_scope:Battlenet.BGSServiceOptions)
|
||||
private:
|
||||
inline void set_has_descriptor_name();
|
||||
inline void clear_has_descriptor_name();
|
||||
inline void set_has_version();
|
||||
inline void clear_has_version();
|
||||
inline void set_has_shard_name();
|
||||
inline void clear_has_shard_name();
|
||||
|
||||
::google::protobuf::UnknownFieldSet _unknown_fields_;
|
||||
|
||||
::google::protobuf::uint32 _has_bits_[1];
|
||||
mutable int _cached_size_;
|
||||
::std::string* descriptor_name_;
|
||||
::std::string* shard_name_;
|
||||
::google::protobuf::uint32 version_;
|
||||
friend void protobuf_AddDesc_service_5foptions_2eproto();
|
||||
friend void protobuf_AssignDesc_service_5foptions_2eproto();
|
||||
friend void protobuf_ShutdownFile_service_5foptions_2eproto();
|
||||
|
||||
void InitAsDefaultInstance();
|
||||
static BGSServiceOptions* default_instance_;
|
||||
};
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
class SDKServiceOptions : public ::google::protobuf::Message {
|
||||
public:
|
||||
SDKServiceOptions();
|
||||
virtual ~SDKServiceOptions();
|
||||
|
||||
SDKServiceOptions(const SDKServiceOptions& from);
|
||||
|
||||
inline SDKServiceOptions& operator=(const SDKServiceOptions& from) {
|
||||
CopyFrom(from);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
|
||||
return _unknown_fields_;
|
||||
}
|
||||
|
||||
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
|
||||
return &_unknown_fields_;
|
||||
}
|
||||
|
||||
static const ::google::protobuf::Descriptor* descriptor();
|
||||
static const SDKServiceOptions& default_instance();
|
||||
|
||||
void Swap(SDKServiceOptions* other);
|
||||
|
||||
// implements Message ----------------------------------------------
|
||||
|
||||
SDKServiceOptions* New() const;
|
||||
int GetCachedSize() const { return _cached_size_; }
|
||||
private:
|
||||
void SharedCtor();
|
||||
void SharedDtor();
|
||||
void SetCachedSize(int size) const;
|
||||
public:
|
||||
::google::protobuf::Metadata GetMetadata() const;
|
||||
|
||||
// nested types ----------------------------------------------------
|
||||
|
||||
// accessors -------------------------------------------------------
|
||||
|
||||
// optional bool inbound = 1;
|
||||
inline bool has_inbound() const;
|
||||
inline void clear_inbound();
|
||||
static const int kInboundFieldNumber = 1;
|
||||
inline bool inbound() const;
|
||||
inline void set_inbound(bool value);
|
||||
|
||||
// optional bool outbound = 2;
|
||||
inline bool has_outbound() const;
|
||||
inline void clear_outbound();
|
||||
static const int kOutboundFieldNumber = 2;
|
||||
inline bool outbound() const;
|
||||
inline void set_outbound(bool value);
|
||||
|
||||
// optional bool use_client_id = 3;
|
||||
inline bool has_use_client_id() const;
|
||||
inline void clear_use_client_id();
|
||||
static const int kUseClientIdFieldNumber = 3;
|
||||
inline bool use_client_id() const;
|
||||
inline void set_use_client_id(bool value);
|
||||
|
||||
// @@protoc_insertion_point(class_scope:Battlenet.SDKServiceOptions)
|
||||
private:
|
||||
inline void set_has_inbound();
|
||||
inline void clear_has_inbound();
|
||||
inline void set_has_outbound();
|
||||
inline void clear_has_outbound();
|
||||
inline void set_has_use_client_id();
|
||||
inline void clear_has_use_client_id();
|
||||
|
||||
::google::protobuf::UnknownFieldSet _unknown_fields_;
|
||||
|
||||
::google::protobuf::uint32 _has_bits_[1];
|
||||
mutable int _cached_size_;
|
||||
bool inbound_;
|
||||
bool outbound_;
|
||||
bool use_client_id_;
|
||||
friend void protobuf_AddDesc_service_5foptions_2eproto();
|
||||
friend void protobuf_AssignDesc_service_5foptions_2eproto();
|
||||
friend void protobuf_ShutdownFile_service_5foptions_2eproto();
|
||||
|
||||
void InitAsDefaultInstance();
|
||||
static SDKServiceOptions* default_instance_;
|
||||
};
|
||||
// ===================================================================
|
||||
|
||||
static const int kServiceOptionsFieldNumber = 90000;
|
||||
extern ::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::ServiceOptions,
|
||||
::google::protobuf::internal::MessageTypeTraits< ::Battlenet::BGSServiceOptions >, 11, false >
|
||||
service_options;
|
||||
static const int kSdkServiceOptionsFieldNumber = 90001;
|
||||
extern ::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::ServiceOptions,
|
||||
::google::protobuf::internal::MessageTypeTraits< ::Battlenet::SDKServiceOptions >, 11, false >
|
||||
sdk_service_options;
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// BGSServiceOptions
|
||||
|
||||
// optional string descriptor_name = 1;
|
||||
inline bool BGSServiceOptions::has_descriptor_name() const {
|
||||
return (_has_bits_[0] & 0x00000001u) != 0;
|
||||
}
|
||||
inline void BGSServiceOptions::set_has_descriptor_name() {
|
||||
_has_bits_[0] |= 0x00000001u;
|
||||
}
|
||||
inline void BGSServiceOptions::clear_has_descriptor_name() {
|
||||
_has_bits_[0] &= ~0x00000001u;
|
||||
}
|
||||
inline void BGSServiceOptions::clear_descriptor_name() {
|
||||
if (descriptor_name_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
|
||||
descriptor_name_->clear();
|
||||
}
|
||||
clear_has_descriptor_name();
|
||||
}
|
||||
inline const ::std::string& BGSServiceOptions::descriptor_name() const {
|
||||
// @@protoc_insertion_point(field_get:Battlenet.BGSServiceOptions.descriptor_name)
|
||||
return *descriptor_name_;
|
||||
}
|
||||
inline void BGSServiceOptions::set_descriptor_name(const ::std::string& value) {
|
||||
set_has_descriptor_name();
|
||||
if (descriptor_name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
|
||||
descriptor_name_ = new ::std::string;
|
||||
}
|
||||
descriptor_name_->assign(value);
|
||||
// @@protoc_insertion_point(field_set:Battlenet.BGSServiceOptions.descriptor_name)
|
||||
}
|
||||
inline void BGSServiceOptions::set_descriptor_name(const char* value) {
|
||||
set_has_descriptor_name();
|
||||
if (descriptor_name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
|
||||
descriptor_name_ = new ::std::string;
|
||||
}
|
||||
descriptor_name_->assign(value);
|
||||
// @@protoc_insertion_point(field_set_char:Battlenet.BGSServiceOptions.descriptor_name)
|
||||
}
|
||||
inline void BGSServiceOptions::set_descriptor_name(const char* value, size_t size) {
|
||||
set_has_descriptor_name();
|
||||
if (descriptor_name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
|
||||
descriptor_name_ = new ::std::string;
|
||||
}
|
||||
descriptor_name_->assign(reinterpret_cast<const char*>(value), size);
|
||||
// @@protoc_insertion_point(field_set_pointer:Battlenet.BGSServiceOptions.descriptor_name)
|
||||
}
|
||||
inline ::std::string* BGSServiceOptions::mutable_descriptor_name() {
|
||||
set_has_descriptor_name();
|
||||
if (descriptor_name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
|
||||
descriptor_name_ = new ::std::string;
|
||||
}
|
||||
// @@protoc_insertion_point(field_mutable:Battlenet.BGSServiceOptions.descriptor_name)
|
||||
return descriptor_name_;
|
||||
}
|
||||
inline ::std::string* BGSServiceOptions::release_descriptor_name() {
|
||||
clear_has_descriptor_name();
|
||||
if (descriptor_name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
|
||||
return NULL;
|
||||
} else {
|
||||
::std::string* temp = descriptor_name_;
|
||||
descriptor_name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
inline void BGSServiceOptions::set_allocated_descriptor_name(::std::string* descriptor_name) {
|
||||
if (descriptor_name_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
|
||||
delete descriptor_name_;
|
||||
}
|
||||
if (descriptor_name) {
|
||||
set_has_descriptor_name();
|
||||
descriptor_name_ = descriptor_name;
|
||||
} else {
|
||||
clear_has_descriptor_name();
|
||||
descriptor_name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||
}
|
||||
// @@protoc_insertion_point(field_set_allocated:Battlenet.BGSServiceOptions.descriptor_name)
|
||||
}
|
||||
|
||||
// optional uint32 version = 4;
|
||||
inline bool BGSServiceOptions::has_version() const {
|
||||
return (_has_bits_[0] & 0x00000002u) != 0;
|
||||
}
|
||||
inline void BGSServiceOptions::set_has_version() {
|
||||
_has_bits_[0] |= 0x00000002u;
|
||||
}
|
||||
inline void BGSServiceOptions::clear_has_version() {
|
||||
_has_bits_[0] &= ~0x00000002u;
|
||||
}
|
||||
inline void BGSServiceOptions::clear_version() {
|
||||
version_ = 0u;
|
||||
clear_has_version();
|
||||
}
|
||||
inline ::google::protobuf::uint32 BGSServiceOptions::version() const {
|
||||
// @@protoc_insertion_point(field_get:Battlenet.BGSServiceOptions.version)
|
||||
return version_;
|
||||
}
|
||||
inline void BGSServiceOptions::set_version(::google::protobuf::uint32 value) {
|
||||
set_has_version();
|
||||
version_ = value;
|
||||
// @@protoc_insertion_point(field_set:Battlenet.BGSServiceOptions.version)
|
||||
}
|
||||
|
||||
// optional string shard_name = 5;
|
||||
inline bool BGSServiceOptions::has_shard_name() const {
|
||||
return (_has_bits_[0] & 0x00000004u) != 0;
|
||||
}
|
||||
inline void BGSServiceOptions::set_has_shard_name() {
|
||||
_has_bits_[0] |= 0x00000004u;
|
||||
}
|
||||
inline void BGSServiceOptions::clear_has_shard_name() {
|
||||
_has_bits_[0] &= ~0x00000004u;
|
||||
}
|
||||
inline void BGSServiceOptions::clear_shard_name() {
|
||||
if (shard_name_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
|
||||
shard_name_->clear();
|
||||
}
|
||||
clear_has_shard_name();
|
||||
}
|
||||
inline const ::std::string& BGSServiceOptions::shard_name() const {
|
||||
// @@protoc_insertion_point(field_get:Battlenet.BGSServiceOptions.shard_name)
|
||||
return *shard_name_;
|
||||
}
|
||||
inline void BGSServiceOptions::set_shard_name(const ::std::string& value) {
|
||||
set_has_shard_name();
|
||||
if (shard_name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
|
||||
shard_name_ = new ::std::string;
|
||||
}
|
||||
shard_name_->assign(value);
|
||||
// @@protoc_insertion_point(field_set:Battlenet.BGSServiceOptions.shard_name)
|
||||
}
|
||||
inline void BGSServiceOptions::set_shard_name(const char* value) {
|
||||
set_has_shard_name();
|
||||
if (shard_name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
|
||||
shard_name_ = new ::std::string;
|
||||
}
|
||||
shard_name_->assign(value);
|
||||
// @@protoc_insertion_point(field_set_char:Battlenet.BGSServiceOptions.shard_name)
|
||||
}
|
||||
inline void BGSServiceOptions::set_shard_name(const char* value, size_t size) {
|
||||
set_has_shard_name();
|
||||
if (shard_name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
|
||||
shard_name_ = new ::std::string;
|
||||
}
|
||||
shard_name_->assign(reinterpret_cast<const char*>(value), size);
|
||||
// @@protoc_insertion_point(field_set_pointer:Battlenet.BGSServiceOptions.shard_name)
|
||||
}
|
||||
inline ::std::string* BGSServiceOptions::mutable_shard_name() {
|
||||
set_has_shard_name();
|
||||
if (shard_name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
|
||||
shard_name_ = new ::std::string;
|
||||
}
|
||||
// @@protoc_insertion_point(field_mutable:Battlenet.BGSServiceOptions.shard_name)
|
||||
return shard_name_;
|
||||
}
|
||||
inline ::std::string* BGSServiceOptions::release_shard_name() {
|
||||
clear_has_shard_name();
|
||||
if (shard_name_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
|
||||
return NULL;
|
||||
} else {
|
||||
::std::string* temp = shard_name_;
|
||||
shard_name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
inline void BGSServiceOptions::set_allocated_shard_name(::std::string* shard_name) {
|
||||
if (shard_name_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
|
||||
delete shard_name_;
|
||||
}
|
||||
if (shard_name) {
|
||||
set_has_shard_name();
|
||||
shard_name_ = shard_name;
|
||||
} else {
|
||||
clear_has_shard_name();
|
||||
shard_name_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
|
||||
}
|
||||
// @@protoc_insertion_point(field_set_allocated:Battlenet.BGSServiceOptions.shard_name)
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// SDKServiceOptions
|
||||
|
||||
// optional bool inbound = 1;
|
||||
inline bool SDKServiceOptions::has_inbound() const {
|
||||
return (_has_bits_[0] & 0x00000001u) != 0;
|
||||
}
|
||||
inline void SDKServiceOptions::set_has_inbound() {
|
||||
_has_bits_[0] |= 0x00000001u;
|
||||
}
|
||||
inline void SDKServiceOptions::clear_has_inbound() {
|
||||
_has_bits_[0] &= ~0x00000001u;
|
||||
}
|
||||
inline void SDKServiceOptions::clear_inbound() {
|
||||
inbound_ = false;
|
||||
clear_has_inbound();
|
||||
}
|
||||
inline bool SDKServiceOptions::inbound() const {
|
||||
// @@protoc_insertion_point(field_get:Battlenet.SDKServiceOptions.inbound)
|
||||
return inbound_;
|
||||
}
|
||||
inline void SDKServiceOptions::set_inbound(bool value) {
|
||||
set_has_inbound();
|
||||
inbound_ = value;
|
||||
// @@protoc_insertion_point(field_set:Battlenet.SDKServiceOptions.inbound)
|
||||
}
|
||||
|
||||
// optional bool outbound = 2;
|
||||
inline bool SDKServiceOptions::has_outbound() const {
|
||||
return (_has_bits_[0] & 0x00000002u) != 0;
|
||||
}
|
||||
inline void SDKServiceOptions::set_has_outbound() {
|
||||
_has_bits_[0] |= 0x00000002u;
|
||||
}
|
||||
inline void SDKServiceOptions::clear_has_outbound() {
|
||||
_has_bits_[0] &= ~0x00000002u;
|
||||
}
|
||||
inline void SDKServiceOptions::clear_outbound() {
|
||||
outbound_ = false;
|
||||
clear_has_outbound();
|
||||
}
|
||||
inline bool SDKServiceOptions::outbound() const {
|
||||
// @@protoc_insertion_point(field_get:Battlenet.SDKServiceOptions.outbound)
|
||||
return outbound_;
|
||||
}
|
||||
inline void SDKServiceOptions::set_outbound(bool value) {
|
||||
set_has_outbound();
|
||||
outbound_ = value;
|
||||
// @@protoc_insertion_point(field_set:Battlenet.SDKServiceOptions.outbound)
|
||||
}
|
||||
|
||||
// optional bool use_client_id = 3;
|
||||
inline bool SDKServiceOptions::has_use_client_id() const {
|
||||
return (_has_bits_[0] & 0x00000004u) != 0;
|
||||
}
|
||||
inline void SDKServiceOptions::set_has_use_client_id() {
|
||||
_has_bits_[0] |= 0x00000004u;
|
||||
}
|
||||
inline void SDKServiceOptions::clear_has_use_client_id() {
|
||||
_has_bits_[0] &= ~0x00000004u;
|
||||
}
|
||||
inline void SDKServiceOptions::clear_use_client_id() {
|
||||
use_client_id_ = false;
|
||||
clear_has_use_client_id();
|
||||
}
|
||||
inline bool SDKServiceOptions::use_client_id() const {
|
||||
// @@protoc_insertion_point(field_get:Battlenet.SDKServiceOptions.use_client_id)
|
||||
return use_client_id_;
|
||||
}
|
||||
inline void SDKServiceOptions::set_use_client_id(bool value) {
|
||||
set_has_use_client_id();
|
||||
use_client_id_ = value;
|
||||
// @@protoc_insertion_point(field_set:Battlenet.SDKServiceOptions.use_client_id)
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(namespace_scope)
|
||||
|
||||
} // namespace Battlenet
|
||||
|
||||
#ifndef SWIG
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
|
||||
} // namespace google
|
||||
} // namespace protobuf
|
||||
#endif // SWIG
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
#endif // PROTOBUF_service_5foptions_2eproto__INCLUDED
|
||||
@@ -1,144 +0,0 @@
|
||||
{
|
||||
[1] std::atomic
|
||||
Helgrind:Race
|
||||
fun:_ZNSt13__atomic_baseIlE5storeElSt12memory_order
|
||||
fun:_ZNSt13__atomic_baseIlEaSEl
|
||||
}
|
||||
{
|
||||
[1] std::atomic
|
||||
Helgrind:Race
|
||||
fun:_ZNKSt13__atomic_baseIlE4loadESt12memory_order
|
||||
fun:_ZNKSt13__atomic_baseIlEcvlEv
|
||||
}
|
||||
{
|
||||
[1] std::atomic
|
||||
Helgrind:Race
|
||||
fun:_ZNSt13__atomic_baseIbE5storeEbSt12memory_order
|
||||
fun:_ZNSt13__atomic_baseIbEaSEb
|
||||
}
|
||||
{
|
||||
[1] std::atomic
|
||||
Helgrind:Race
|
||||
fun:_ZNKSt13__atomic_baseIbE4loadESt12memory_order
|
||||
fun:_ZNKSt11atomic_boolcvbEv
|
||||
}
|
||||
{
|
||||
[1] std::atomic
|
||||
Helgrind:Race
|
||||
fun:_ZNSt13__atomic_baseIiE5storeEiSt12memory_order
|
||||
fun:_ZNSt13__atomic_baseIiEaSEi
|
||||
}
|
||||
{
|
||||
[1] std::atomic
|
||||
Helgrind:Race
|
||||
fun:_ZNSt13__atomic_baseIiEmIEi
|
||||
}
|
||||
{
|
||||
[1] std::atomic
|
||||
Helgrind:Race
|
||||
fun:_ZNSt13__atomic_baseIjE5storeEjSt12memory_order
|
||||
fun:_ZNSt13__atomic_baseIjEaSEj
|
||||
}
|
||||
{
|
||||
[1] std::atomic
|
||||
Helgrind:Race
|
||||
fun:_ZNKSt13__atomic_baseIjE4loadESt12memory_order
|
||||
fun:_ZNKSt13__atomic_baseIjEcvjEv
|
||||
}
|
||||
{
|
||||
[1] std::atomic
|
||||
Helgrind:Race
|
||||
fun:load
|
||||
fun:_ZNKSt13__atomic_baseIjEcvjEv
|
||||
}
|
||||
{
|
||||
[1] std::atomic
|
||||
Helgrind:Race
|
||||
fun:store
|
||||
fun:_ZNSt13__atomic_baseIiEaSEi
|
||||
}
|
||||
{
|
||||
[1] std::atomic
|
||||
Helgrind:Race
|
||||
fun:store
|
||||
fun:_ZNSt13__atomic_baseIbEaSEb
|
||||
}
|
||||
{
|
||||
[1] std::atomic
|
||||
Helgrind:Race
|
||||
fun:load
|
||||
fun:_ZNKSt11atomic_boolcvbEv
|
||||
}
|
||||
{
|
||||
[1] std::atomic
|
||||
Helgrind:Race
|
||||
fun:store
|
||||
fun:_ZNSt13__atomic_baseIjEaSEj
|
||||
}
|
||||
{
|
||||
[2] integer counters
|
||||
Helgrind:Race
|
||||
fun:_ZN4MMAP11MMapManager7loadMapERKSsjii
|
||||
fun:_ZN3Map8LoadMMapEii
|
||||
}
|
||||
{
|
||||
[2] integer counters
|
||||
Helgrind:Race
|
||||
fun:_ZN8Movement7counterIjLj4294967295EE8IncreaseEv
|
||||
}
|
||||
{
|
||||
[2] integer counters
|
||||
Helgrind:Race
|
||||
fun:_ZN3G3D10BufferPool6mallocEm
|
||||
}
|
||||
{
|
||||
[3] System libraries
|
||||
Helgrind:Race
|
||||
fun:__GI_mempcpy
|
||||
fun:_IO_file_xsputn@@GLIBC_2.2.5
|
||||
fun:vfprintf
|
||||
}
|
||||
{
|
||||
[3] System libraries
|
||||
Helgrind:Race
|
||||
fun:__GI_mempcpy
|
||||
fun:_IO_file_xsputn@@GLIBC_2.2.5
|
||||
fun:fwrite
|
||||
}
|
||||
{
|
||||
[4] integer assignments
|
||||
Helgrind:Race
|
||||
fun:_ZN3Log14LoadFromConfigEv
|
||||
fun:_ZN5World18LoadConfigSettingsEb
|
||||
}
|
||||
{
|
||||
[4] integer assignments
|
||||
Helgrind:Race
|
||||
fun:_ZN3Log22CreateLoggerFromConfigERKSs
|
||||
fun:_ZN3Log21ReadLoggersFromConfigEv
|
||||
fun:_ZN3Log14LoadFromConfigEv
|
||||
fun:_ZN5World18LoadConfigSettingsEb
|
||||
}
|
||||
{
|
||||
[4] integer assignments
|
||||
Helgrind:Race
|
||||
fun:_ZN5World18LoadConfigSettingsEb
|
||||
}
|
||||
{
|
||||
[4] integer assignments
|
||||
Helgrind:Race
|
||||
fun:_ZNK5World12getIntConfigE15WorldIntConfigs
|
||||
}
|
||||
{
|
||||
[4] integer assignments
|
||||
Helgrind:Race
|
||||
fun:_ZNK3Log9ShouldLogERKSs8LogLevel
|
||||
}
|
||||
{
|
||||
[5] ignored static variables
|
||||
Helgrind:Race
|
||||
fun:_ZN3G3D7Vector3aSERKS0_
|
||||
fun:_ZN3G3D18CollisionDetection41collisionLocationForMovingPointFixedAABoxERKNS_7Vector3ES3_RKNS_5AABoxERS1_RbS7_
|
||||
fun:_ZN3G3D18CollisionDetection37collisionTimeForMovingPointFixedAABoxERKNS_7Vector3ES3_RKNS_5AABoxERS1_RbS7_
|
||||
fun:_ZNK3G3D3Ray16intersectionTimeERKNS_5AABoxE
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,54 +0,0 @@
|
||||
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
add_subdirectory(threads)
|
||||
|
||||
if(SERVERS OR TOOLS)
|
||||
add_subdirectory(boost)
|
||||
add_subdirectory(zlib)
|
||||
add_subdirectory(g3dlite)
|
||||
add_subdirectory(recastnavigation)
|
||||
add_subdirectory(fmt)
|
||||
add_subdirectory(SFMT)
|
||||
add_subdirectory(utf8cpp)
|
||||
add_subdirectory(valgrind)
|
||||
add_subdirectory(openssl)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT NOJEM)
|
||||
add_subdirectory(jemalloc)
|
||||
endif()
|
||||
add_subdirectory(argon2)
|
||||
add_subdirectory(openssl_ed25519)
|
||||
add_subdirectory(short_alloc)
|
||||
endif()
|
||||
|
||||
if(SERVERS)
|
||||
add_subdirectory(mysql)
|
||||
add_subdirectory(readline)
|
||||
add_subdirectory(gsoap)
|
||||
add_subdirectory(rapidjson)
|
||||
add_subdirectory(protobuf)
|
||||
endif()
|
||||
|
||||
if(SERVERS AND BUILD_EFSW)
|
||||
add_subdirectory(efsw)
|
||||
endif()
|
||||
|
||||
if(TOOLS)
|
||||
add_subdirectory(CascLib)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(Catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||
GIT_TAG v3.15.2
|
||||
GIT_SHALLOW 1)
|
||||
FetchContent_MakeAvailable(Catch2)
|
||||
endif()
|
||||
@@ -1,75 +0,0 @@
|
||||
add_library(casc STATIC)
|
||||
|
||||
target_sources(casc
|
||||
PRIVATE
|
||||
src/common/Common.cpp
|
||||
src/common/Directory.cpp
|
||||
src/common/Csv.cpp
|
||||
src/common/FileStream.cpp
|
||||
src/common/FileTree.cpp
|
||||
src/common/ListFile.cpp
|
||||
src/common/Mime.cpp
|
||||
src/common/RootHandler.cpp
|
||||
src/common/Sockets.cpp
|
||||
src/hashes/md5.cpp
|
||||
src/hashes/sha1.cpp
|
||||
src/jenkins/lookup3.c
|
||||
src/overwatch/apm.cpp
|
||||
src/overwatch/cmf.cpp
|
||||
src/overwatch/aes.cpp
|
||||
src/CascDecompress.cpp
|
||||
src/CascDecrypt.cpp
|
||||
src/CascDumpData.cpp
|
||||
src/CascFiles.cpp
|
||||
src/CascFindFile.cpp
|
||||
src/CascIndexFiles.cpp
|
||||
src/CascOpenFile.cpp
|
||||
src/CascOpenStorage.cpp
|
||||
src/CascReadFile.cpp
|
||||
src/CascRootFile_Diablo3.cpp
|
||||
src/CascRootFile_Install.cpp
|
||||
src/CascRootFile_MNDX.cpp
|
||||
src/CascRootFile_Text.cpp
|
||||
src/CascRootFile_TVFS.cpp
|
||||
src/CascRootFile_OW.cpp
|
||||
src/CascRootFile_WoW.cpp)
|
||||
|
||||
target_sources(casc
|
||||
PUBLIC
|
||||
FILE_SET HEADERS
|
||||
BASE_DIRS src
|
||||
FILES
|
||||
src/CascLib.h
|
||||
PRIVATE
|
||||
FILE_SET casc_private_headers
|
||||
TYPE HEADERS
|
||||
BASE_DIRS src
|
||||
FILES
|
||||
src/CascCommon.h
|
||||
src/CascPort.h
|
||||
src/common/Array.h
|
||||
src/common/Common.h
|
||||
src/common/Csv.h
|
||||
src/common/Directory.h
|
||||
src/common/FileStream.h
|
||||
src/common/FileTree.h
|
||||
src/common/ListFile.h
|
||||
src/common/Map.h
|
||||
src/common/Mime.h
|
||||
src/common/Path.h
|
||||
src/common/RootHandler.h
|
||||
src/common/Sockets.h
|
||||
src/jenkins/lookup.h)
|
||||
|
||||
target_compile_definitions(casc PUBLIC CASC_USE_SYSTEM_ZLIB CASCLIB_NO_AUTO_LINK_LIBRARY CASCLIB_NODEBUG)
|
||||
|
||||
target_link_libraries(casc
|
||||
PRIVATE
|
||||
trinity-dependency-interface
|
||||
PUBLIC
|
||||
zlib)
|
||||
|
||||
set_target_properties(casc
|
||||
PROPERTIES
|
||||
FOLDER
|
||||
"dep")
|
||||
@@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Ladislav Zezula
|
||||
|
||||
Permission 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:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE 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.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user