From 79641a4496294bbe626e832ecdc3da862ea273e3 Mon Sep 17 00:00:00 2001 From: BeyondWUXF <46481385+BeyondWUXF@users.noreply.github.com> Date: Wed, 8 Nov 2023 15:52:23 +0800 Subject: [PATCH 01/81] PingCallback set servantPrx --- servant/libservant/AdapterProxy.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/servant/libservant/AdapterProxy.cpp b/servant/libservant/AdapterProxy.cpp index 13792c17..7d71aa23 100755 --- a/servant/libservant/AdapterProxy.cpp +++ b/servant/libservant/AdapterProxy.cpp @@ -1050,6 +1050,7 @@ void AdapterProxy::doKeepAlive() ReqMessage *msg = new ReqMessage(); ServantProxyCallbackPtr callback = new PingCallback(); + callback->setServantPrx(_objectProxy->getServantProxy()); msg->init(ReqMessage::ASYNC_CALL, _objectProxy->getServantProxy()); msg->callback = callback; From 79190bc7a847e8d431bccf65f86a7a1cc93ddf9b Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Sun, 12 Nov 2023 15:18:56 +0800 Subject: [PATCH 02/81] Application add ServerBaseInfo --- servant/libservant/Application.cpp | 55 ++++++++++++++++++---- servant/servant/Application.h | 73 +++++++++++++++++++++++++++--- 2 files changed, 113 insertions(+), 15 deletions(-) diff --git a/servant/libservant/Application.cpp b/servant/libservant/Application.cpp index e9ad500c..e9735b79 100644 --- a/servant/libservant/Application.cpp +++ b/servant/libservant/Application.cpp @@ -54,6 +54,7 @@ namespace tars std::string ServerConfig::TarsPath; //服务路径 std::string ServerConfig::Application; //应用名称 std::string ServerConfig::ServerName; //服务名称,一个服务名称含一个或多个服务标识 +std::string ServerConfig::NodeName; //服务如果部署在框架上, 则表示节点名称, 从模板中获取(framework>=3.0.17才支持), 否则为LocalIp std::string ServerConfig::LocalIp; //本机IP std::string ServerConfig::BasePath; //应用程序路径,用于保存远程系统配置的本地目录 std::string ServerConfig::DataPath; //应用程序路径,用于本地数据 @@ -69,27 +70,60 @@ std::string ServerConfig::LogLevel; //log日志级别 std::string ServerConfig::ConfigFile; //框架配置文件路径 int ServerConfig::ReportFlow = 1; //是否服务端上报所有接口stat流量 0不上报 1上报 (用于非tars协议服务流量统计) int ServerConfig::IsCheckSet = 1; //是否对按照set规则调用进行合法性检查 0,不检查,1检查 -int ServerConfig::OpenCoroutine = 0; //是否启用协程处理方式 +int ServerConfig::OpenCoroutine = 0; //是否启用协程处理方式 size_t ServerConfig::CoroutineMemSize; //协程占用内存空间的最大大小 uint32_t ServerConfig::CoroutineStackSize; //每个协程的栈大小(默认128k) bool ServerConfig::ManualListen = false; //手工启动监听端口 -//bool ServerConfig::MergeNetImp = false; //合并网络和处理线程 int ServerConfig::NetThread = 1; //servernet thread bool ServerConfig::CloseCout = true; int ServerConfig::BackPacketLimit = 0; int ServerConfig::BackPacketMin = 1024; -//int ServerConfig::Pattern = 0; - -#if TARS_SSL std::string ServerConfig::CA; std::string ServerConfig::Cert; std::string ServerConfig::Key; -bool ServerConfig::VerifyClient = false; +bool ServerConfig::VerifyClient = false; std::string ServerConfig::Ciphers; -#endif - map ServerConfig::Context; +ServerBaseInfo ServerConfig::toServerBaseInfo() +{ + ServerBaseInfo serverBaseInfo; + serverBaseInfo.TarsPath = TarsPath; + serverBaseInfo.Application = Application; + serverBaseInfo.ServerName = ServerName; + serverBaseInfo.NodeName = NodeName; + serverBaseInfo.BasePath = BasePath; + serverBaseInfo.DataPath = DataPath; + serverBaseInfo.LocalIp = LocalIp; + serverBaseInfo.LogPath = LogPath; + serverBaseInfo.LogSize = LogSize; + serverBaseInfo.LogNum = LogNum; + serverBaseInfo.LogLevel = LogLevel; + serverBaseInfo.Local = Local; + serverBaseInfo.Node = Node; + serverBaseInfo.Log = Log; + serverBaseInfo.Config = Config; + serverBaseInfo.Notify = Notify; + serverBaseInfo.ConfigFile = ConfigFile; + serverBaseInfo.CloseCout = CloseCout; + serverBaseInfo.ReportFlow = ReportFlow; + serverBaseInfo.IsCheckSet = IsCheckSet; + serverBaseInfo.OpenCoroutine = OpenCoroutine; + serverBaseInfo.CoroutineMemSize = CoroutineMemSize; + serverBaseInfo.CoroutineStackSize = CoroutineStackSize; + serverBaseInfo.NetThread = NetThread; + serverBaseInfo.ManualListen = ManualListen; + serverBaseInfo.BackPacketLimit = BackPacketLimit; + serverBaseInfo.BackPacketMin = BackPacketMin; + serverBaseInfo.CA = CA; + serverBaseInfo.Cert = Cert; + serverBaseInfo.Key = Key; + serverBaseInfo.VerifyClient = VerifyClient; + serverBaseInfo.Ciphers = Ciphers; + serverBaseInfo.Context = Context; + + return serverBaseInfo; +} /////////////////////////////////////////////////////////////////////////////////////////// //TC_Config Application::_conf; //TC_EpollServerPtr Application::_epollServer = NULL; @@ -746,6 +780,8 @@ void Application::main(const string &config) //初始化Server部分 initializeServer(); + _serverBaseInfo = ServerConfig::toServerBaseInfo(); + vector adapters; //绑定对象和端口 @@ -1041,6 +1077,7 @@ void Application::outServer(ostream &os) { os << TC_Common::outfill("Application(app)") << ServerConfig::Application << endl; os << TC_Common::outfill("ServerName(server)") << ServerConfig::ServerName << endl; + os << TC_Common::outfill("NodeName(nodename)") << ServerConfig::NodeName << endl; os << TC_Common::outfill("BasePath(basepath)") << ServerConfig::BasePath << endl; os << TC_Common::outfill("DataPath(datapath)") << ServerConfig::DataPath << endl; os << TC_Common::outfill("LocalIp(localip)") << ServerConfig::LocalIp << endl; @@ -1059,7 +1096,6 @@ void Application::outServer(ostream &os) os << TC_Common::outfill("CloseCout(closecout)") << ServerConfig::CloseCout << endl; os << TC_Common::outfill("NetThread(netthread)") << ServerConfig::NetThread << endl; os << TC_Common::outfill("ManualListen(manuallisten)") << ServerConfig::ManualListen << endl; -// os << TC_Common::outfill("MergeNetImp(mergenetimp)") << ServerConfig::MergeNetImp << endl; os << TC_Common::outfill("ReportFlow(reportflow)") << ServerConfig::ReportFlow<< endl; os << TC_Common::outfill("BackPacketLimit(backpacketlimit)") << ServerConfig::BackPacketLimit<< endl; os << TC_Common::outfill("BackPacketMin(backpacketmin)") << ServerConfig::BackPacketMin<< endl; @@ -1126,6 +1162,7 @@ void Application::initializeServer() ServerConfig::LogSize = TC_Common::toSize(toDefault(_conf.get("/tars/application/server"), "52428800"), 52428800); ServerConfig::LogNum = TC_Common::strto(toDefault(_conf.get("/tars/application/server"), "10")); ServerConfig::LocalIp = _conf.get("/tars/application/server"); + ServerConfig::NodeName = toDefault(_conf.get("/tars/application/server"), ServerConfig::LocalIp); ServerConfig::Local = _conf.get("/tars/application/server"); ServerConfig::Node = _conf.get("/tars/application/server"); ServerConfig::Log = _conf.get("/tars/application/server"); diff --git a/servant/servant/Application.h b/servant/servant/Application.h index 53fcd7d4..21fe2473 100644 --- a/servant/servant/Application.h +++ b/servant/servant/Application.h @@ -101,6 +101,48 @@ namespace tars do { addAdminCommandNormal(string(c), std::bind(&f, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); } while (0); ////////////////////////////////////////////////////////////////////// + +/** + * 服务基本信息, 不使用的ServerConfig的原因是, 如果多个Application在同一个进程中初始化ServerConfig则会有问题 + */ +struct SVT_DLL_API ServerBaseInfo +{ + std::string TarsPath; + std::string Application; //应用名称 + std::string ServerName; //服务名称,一个服务名称含一个或多个服务标识 + std::string NodeName; //服务如果部署在框架上, 则表示节点名称, 从模板中获取(framework>=3.0.17才支持), 否则为LocalIp + std::string BasePath; //应用程序路径,用于保存远程系统配置的本地目录 + std::string DataPath; //应用程序数据路径用于保存普通数据文件 + std::string LocalIp; //本机IP + std::string LogPath; //log路径 + int LogSize; //log大小(字节) + int LogNum; //log个数() + std::string LogLevel; //log日志级别 + std::string Local; //本地套接字 + std::string Node; //本机node地址 + std::string Log; //日志中心地址 + std::string Config; //配置中心地址 + std::string Notify; //信息通知中心 + std::string ConfigFile; //框架配置文件路径 + bool CloseCout; + int ReportFlow; //是否服务端上报所有接口stat流量 0不上报 1上报(用于非tars协议服务流量统计) + int IsCheckSet; //是否对按照set规则调用进行合法性检查 0,不检查,1检查 + int OpenCoroutine; //是否启用协程处理方式(0~3) + size_t CoroutineMemSize; //协程占用内存空间的最大大小 + uint32_t CoroutineStackSize; //每个协程的栈大小(默认128k) + int NetThread; //servernet thread + bool ManualListen; //是否启用手工端口监听 + int BackPacketLimit; //回包积压检查 + int BackPacketMin; //回包速度检查 + + std::string CA; + std::string Cert; + std::string Key; + bool VerifyClient; + std::string Ciphers; + map Context; //框架内部用, 传递节点名称(以域名形式部署时) +}; + /** * 服务基本信息 */ @@ -109,6 +151,7 @@ struct SVT_DLL_API ServerConfig static std::string TarsPath; static std::string Application; //应用名称 static std::string ServerName; //服务名称,一个服务名称含一个或多个服务标识 + static std::string NodeName; //服务如果部署在框架上, 则表示节点名称, 从模板中获取(framework>=3.0.17才支持), 否则为LocalIp static std::string BasePath; //应用程序路径,用于保存远程系统配置的本地目录 static std::string DataPath; //应用程序数据路径用于保存普通数据文件 static std::string LocalIp; //本机IP @@ -125,7 +168,7 @@ struct SVT_DLL_API ServerConfig static bool CloseCout; static int ReportFlow; //是否服务端上报所有接口stat流量 0不上报 1上报(用于非tars协议服务流量统计) static int IsCheckSet; //是否对按照set规则调用进行合法性检查 0,不检查,1检查 - static int OpenCoroutine; //是否启用协程处理方式(0~3) + static int OpenCoroutine; //是否启用协程处理方式(0~3) static size_t CoroutineMemSize; //协程占用内存空间的最大大小 static uint32_t CoroutineStackSize; //每个协程的栈大小(默认128k) static int NetThread; //servernet thread @@ -133,13 +176,19 @@ struct SVT_DLL_API ServerConfig static int BackPacketLimit; //回包积压检查 static int BackPacketMin; //回包速度检查 - static std::string CA; - static std::string Cert; - static std::string Key; - static bool VerifyClient; - static std::string Ciphers; + static std::string CA; //ssl ca + static std::string Cert; //ssl 证书 + static std::string Key; //ssl 私钥 + static bool VerifyClient; //是否验证客户端 + static std::string Ciphers; //过滤的加密算法cd static map Context; //框架内部用, 传递节点名称(以域名形式部署时) + + /** + * 转换成ServerBaseInfo, 在initializeServer之后会自动调用, 复制给Application中的_serverBaseInfo + * @return + */ + static ServerBaseInfo toServerBaseInfo(); }; class PropertyReport; @@ -301,6 +350,12 @@ class Application: public BaseNotify */ TC_EpollServer::BindAdapterPtr getBindAdapter(const string &obj); + /** + * 获取服务基本信息 + * @return + */ + const ServerBaseInfo &getServerBaseInfo() const { return _serverBaseInfo; } + protected: /** * 初始化, 只会进程调用一次 @@ -554,6 +609,12 @@ class Application: public BaseNotify string setDivision(void); protected: + + /** + * server base info + */ + ServerBaseInfo _serverBaseInfo; + /** * config */ From 69e64bf16045ef03581db43d3c01900254a12b58 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 14 Nov 2023 09:21:38 +0800 Subject: [PATCH 03/81] fix trace, no not depend ServerConfig --- servant/CMakeLists.txt | 4 +- servant/libservant/AdminServant.cpp | 4 +- servant/libservant/Application.cpp | 4 + servant/libservant/Current.cpp | 7 +- servant/libservant/RemoteConfig.cpp | 1 + servant/libservant/RemoteLogger.cpp | 1 + servant/libservant/RemoteNotify.cpp | 1 - servant/libservant/Servant.cpp | 5 + servant/libservant/ServantHandle.cpp | 614 +++---- servant/libservant/ServantProxy.cpp | 26 +- servant/protocol | 2 +- servant/servant/Application.h | 2 +- servant/servant/Communicator.h | 2 - servant/servant/Current.h | 9 +- servant/servant/EndpointInfo.h | 2 - servant/servant/RemoteConfig.h | 3 + servant/servant/RemoteLogger.h | 21 +- servant/servant/Servant.h | 30 +- servant/servant/ServantHandle.h | 6 + servant/servant/ServantProxy.h | 40 +- tools/tars2cpp/tars2cpp.cpp | 28 +- tools/tarsgrammar/tars.tab.cpp | 2394 ++++++++++++-------------- tools/tarsparse/tars.lex.cpp | 79 +- tools/tarsparse/tars.tab.cpp | 2394 ++++++++++++-------------- tools/tarsparse/tars.tab.hpp | 80 +- 25 files changed, 2786 insertions(+), 2973 deletions(-) diff --git a/servant/CMakeLists.txt b/servant/CMakeLists.txt index 09e034ef..4238b6e8 100644 --- a/servant/CMakeLists.txt +++ b/servant/CMakeLists.txt @@ -41,8 +41,8 @@ macro(complice_tars OUT_DEPENDS_LIST HEADER INCLUDE) OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${TARS_H} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS tars2cpp ${FILE} - COMMAND ${TARS2CPP} --with-tars --without-trace ${HEADER_STRING} ${INCLUDE_STRING} ${TARS_IN} - COMMENT "${TARS2CPP} --with-tars --without-trace ${HEADER_STRING} ${INCLUDE_STRING} ${TARS_IN}") + COMMAND ${TARS2CPP} --with-tars ${HEADER_STRING} ${INCLUDE_STRING} ${TARS_IN} + COMMENT "${TARS2CPP} --with-tars ${HEADER_STRING} ${INCLUDE_STRING} ${TARS_IN}") list(APPEND DEPENDS_LIST ${CMAKE_CURRENT_SOURCE_DIR}/${TARS_H}) diff --git a/servant/libservant/AdminServant.cpp b/servant/libservant/AdminServant.cpp index 58def34a..4ebf0535 100644 --- a/servant/libservant/AdminServant.cpp +++ b/servant/libservant/AdminServant.cpp @@ -15,9 +15,11 @@ */ #include "util/tc_platform.h" #include "servant/AdminServant.h" -#include "servant/Application.h" #include "servant/NotifyObserver.h" #include "servant/ServantHelper.h" +#include "servant/RemoteNotify.h" +#include "servant/RemoteLogger.h" +#include "servant/Application.h" namespace tars { diff --git a/servant/libservant/Application.cpp b/servant/libservant/Application.cpp index e9735b79..eafd4176 100644 --- a/servant/libservant/Application.cpp +++ b/servant/libservant/Application.cpp @@ -26,6 +26,10 @@ #include "servant/NotifyObserver.h" #include "servant/AuthLogic.h" #include "servant/CommunicatorFactory.h" +#include "servant/StatReport.h" +#include "servant/RemoteLogger.h" +#include "servant/RemoteConfig.h" +#include "servant/RemoteNotify.h" #include #if TARGET_PLATFORM_LINUX diff --git a/servant/libservant/Current.cpp b/servant/libservant/Current.cpp index 7ca9f15d..56434c32 100644 --- a/servant/libservant/Current.cpp +++ b/servant/libservant/Current.cpp @@ -411,6 +411,11 @@ ServantHandle* Current::getServantHandle() return _servantHandle; } +string Current::getModuleName() +{ + return _servantHandle->getModuleName(); +} + TC_EpollServer::BindAdapter* Current::getBindAdapter() { return _data->adapter().get(); @@ -437,7 +442,7 @@ bool Current::isTraced() const return _traceCall; } -string Current::getTraceKey() const +const string &Current::getTraceKey() const { return _traceKey; } diff --git a/servant/libservant/RemoteConfig.cpp b/servant/libservant/RemoteConfig.cpp index aaf4d0c5..bb20a2cb 100755 --- a/servant/libservant/RemoteConfig.cpp +++ b/servant/libservant/RemoteConfig.cpp @@ -18,6 +18,7 @@ #include "util/tc_file.h" #include "servant/Communicator.h" #include "servant/RemoteNotify.h" +#include "servant/ConfigF.h" #include "servant/Application.h" #include diff --git a/servant/libservant/RemoteLogger.cpp b/servant/libservant/RemoteLogger.cpp index c7c6f4d1..d48bb585 100644 --- a/servant/libservant/RemoteLogger.cpp +++ b/servant/libservant/RemoteLogger.cpp @@ -17,6 +17,7 @@ #include "servant/RemoteLogger.h" #include "servant/Communicator.h" #include "servant/Application.h" +#include "servant/LogF.h" namespace tars { diff --git a/servant/libservant/RemoteNotify.cpp b/servant/libservant/RemoteNotify.cpp index d45940c8..41fb7817 100644 --- a/servant/libservant/RemoteNotify.cpp +++ b/servant/libservant/RemoteNotify.cpp @@ -15,7 +15,6 @@ */ #include "servant/RemoteNotify.h" -#include "servant/Communicator.h" #include "servant/RemoteLogger.h" #include "servant/Application.h" diff --git a/servant/libservant/Servant.cpp b/servant/libservant/Servant.cpp index a5c50c30..0be18daa 100644 --- a/servant/libservant/Servant.cpp +++ b/servant/libservant/Servant.cpp @@ -57,6 +57,11 @@ Application* Servant::getApplication() const return _application; } +string Servant::getModuleName() +{ + return _application->getServerBaseInfo().Application + "." + _application->getServerBaseInfo().ServerName; +} + void Servant::setHandle(TC_EpollServer::Handle* handle) { _handle = handle; diff --git a/servant/libservant/ServantHandle.cpp b/servant/libservant/ServantHandle.cpp index e0e5ff87..c218e332 100644 --- a/servant/libservant/ServantHandle.cpp +++ b/servant/libservant/ServantHandle.cpp @@ -23,7 +23,8 @@ #include "servant/BaseF.h" #include "servant/KeepAliveNodeF.h" #include "servant/Cookie.h" -#include "servant/Application.h" +#include "servant/RemoteNotify.h" + // #ifdef TARS_OPENTRACKING // #include "servant/text_map_carrier.h" // #endif @@ -34,229 +35,186 @@ namespace tars ///////////////////////////////////////////////////////////////////////// // ServantHandle::ServantHandle(Application *application) -: _application(application) + : _application(application) { - + } ServantHandle::~ServantHandle() { -// auto it = _servants.begin(); - -// while(it != _servants.end()) -// if(_servant) + try { - try - { - _servant->destroy(); - } - catch(exception &ex) - { - TLOGERROR("[ServantHandle::destroy error:" << ex.what() << "]" << endl); - } - catch(...) - { - TLOGERROR("[ServantHandle::destroy unknown exception error]" << endl); - } -// ++it; + _servant->destroy(); + } + catch (exception &ex) + { + TLOGERROR("[ServantHandle::destroy error:" << ex.what() << "]" << endl); } + catch (...) + { + TLOGERROR("[ServantHandle::destroy unknown exception error]" << endl); + } +} + +string ServantHandle::getModuleName() +{ + return _servant->getModuleName(); } void ServantHandle::handleAsyncResponse() { ReqMessagePtr resp; -// auto it = _servants.begin(); -// -// while (it != _servants.end()) -// if(_servant) + while (_servant->getResponseQueue().pop_front(resp)) { - while (_servant->getResponseQueue().pop_front(resp)) + try { - try + if (resp->response->iRet == TARSSERVERSUCCESS) { - if (resp->response->iRet == TARSSERVERSUCCESS) - { - _servant->doResponse(resp); - } - else if (resp->pObjectProxy == NULL) - { - _servant->doResponseNoRequest(resp); - } - else - { - _servant->doResponseException(resp); - } - } - catch (exception& e) + _servant->doResponse(resp); + } else if (resp->pObjectProxy == NULL) { - TLOGERROR("[ServantHandle::doResponse ex:" << e.what() << "]" << endl); - } - catch (...) + _servant->doResponseNoRequest(resp); + } else { - TLOGERROR("[ServantHandle::doResponse error]" << endl); + _servant->doResponseException(resp); } } - - //业务处理附加的自有消息 - try + catch (exception &e) { - _servant->doCustomMessage(false); - _servant->doCustomMessage(); - } - catch (exception& e) - { - TLOGERROR("[ServantHandle::doCustemMessage ex:" << e.what() << "]" << endl); + TLOGERROR("[ServantHandle::doResponse ex:" << e.what() << "]" << endl); } catch (...) { - TLOGERROR("[ServantHandle::doCustemMessage ex.]" << endl); + TLOGERROR("[ServantHandle::doResponse error]" << endl); } + } -// ++it; + //业务处理附加的自有消息 + try + { + _servant->doCustomMessage(false); + _servant->doCustomMessage(); } + catch (exception &e) + { + TLOGERROR("[ServantHandle::doCustemMessage ex:" << e.what() << "]" << endl); + } + catch (...) + { + TLOGERROR("[ServantHandle::doCustemMessage ex.]" << endl); + } + } void ServantHandle::handleCustomMessage(bool bExpectIdle) { -// for (auto it = _servants.begin(); it != _servants.end(); it++) -// if(_servant) + //业务处理附加的自有消息 + try { - //业务处理附加的自有消息 - try - { - _servant->doCustomMessage(bExpectIdle); - _servant->doCustomMessage(); - } - catch (exception& e) - { - TLOGERROR("[ServantHandle::doCustemMessage ex:" << e.what() << "]" << endl); - } - catch (...) - { - TLOGERROR("[ServantHandle::doCustemMessage ex.]" << endl); - } + _servant->doCustomMessage(bExpectIdle); + _servant->doCustomMessage(); + } + catch (exception &e) + { + TLOGERROR("[ServantHandle::doCustemMessage ex:" << e.what() << "]" << endl); + } + catch (...) + { + TLOGERROR("[ServantHandle::doCustemMessage ex.]" << endl); } } bool ServantHandle::allFilterIsEmpty() { -// auto it = _servants.begin(); - -// while (it != _servants.end()) -// if(_servant) - { - if (!_servant->getResponseQueue().empty()) - { - return false; - } -// ++it; - } - return true; + if (!_servant->getResponseQueue().empty()) + { + return false; + } + return true; } void ServantHandle::initialize() { - if(TC_CoroutineScheduler::scheduler()) - { - ServantProxyThreadData::getData()->_sched = TC_CoroutineScheduler::scheduler(); - } + if (TC_CoroutineScheduler::scheduler()) + { + ServantProxyThreadData::getData()->_sched = TC_CoroutineScheduler::scheduler(); + } _servant = _application->getServantHelper()->create(_bindAdapter->getName()); -// ServantPtr servant = _application->getServantHelper()->create(_bindAdapter->getName()); - -// if (servant) -// { -// _servants[servant->getName()] = servant; -// } -// else - if(!_servant) + if (!_servant) { - TLOGERROR("[ServantHandle initialize createServant ret null, for adapter `" +_bindAdapter->getName() + "`]" << endl); - cerr << "ServantHandle initialize createServant ret null, for adapter `" +_bindAdapter->getName() + "`]" << endl; + TLOGERROR("[ServantHandle initialize createServant ret null, for adapter `" + _bindAdapter->getName() + "`]" + << endl); + cerr << "ServantHandle initialize createServant ret null, for adapter `" + _bindAdapter->getName() + "`]" + << endl; - RemoteNotify::getInstance()->report("initialize createServant error: no adapter:" + _bindAdapter->getName()); + RemoteNotify::getInstance()->report("initialize createServant error: no adapter:" + _bindAdapter->getName()); - TC_Common::msleep(100); + TC_Common::msleep(100); - exit(-1); + exit(-1); } -// auto it = _servants.begin(); -// -// if(it == _servants.end()) -// { -// TLOGERROR("[initialize error: no servant exists]" << endl); -// -// RemoteNotify::getInstance()->report("initialize error: no servant exists."); -// -// TC_Common::msleep(100); -// -// exit(-1); -// } - -// while(it != _servants.end()) -// { - try - { - _servant->setHandle(this); + try + { + _servant->setHandle(this); - _servant->initialize(); + _servant->initialize(); - TLOGTARS("[" << _servant->getName() << " initialize]" << endl); - } - catch(exception &ex) - { - TLOGERROR("[initialize error:" << ex.what() << "]" << endl); + TLOGTARS("[" << _servant->getName() << " initialize]" << endl); + } + catch (exception &ex) + { + TLOGERROR("[initialize error:" << ex.what() << "]" << endl); - RemoteNotify::getInstance()->report("initialize error:" + string(ex.what())); + RemoteNotify::getInstance()->report("initialize error:" + string(ex.what())); - TC_Common::msleep(100); + TC_Common::msleep(100); - exit(-1); - } - catch(...) - { - TLOGERROR("[initialize unknown exception error]" << endl); + exit(-1); + } + catch (...) + { + TLOGERROR("[initialize unknown exception error]" << endl); - RemoteNotify::getInstance()->report("initialize unknown exception error"); + RemoteNotify::getInstance()->report("initialize unknown exception error"); - TC_Common::msleep(100); + TC_Common::msleep(100); - exit(-1); - } -// ++it; -// } + exit(-1); + } } void ServantHandle::heartbeat() { - time_t fcur = TNOW; + time_t fcur = TNOW; - if (abs(fcur - _bindAdapter->getHeartBeatTime()) > HEART_BEAT_INTERVAL) - { - _bindAdapter->setHeartBeatTime(fcur); + if (abs(fcur - _bindAdapter->getHeartBeatTime()) > HEART_BEAT_INTERVAL) + { + _bindAdapter->setHeartBeatTime(fcur); TARS_KEEPALIVE(_bindAdapter->getName()); - //上报连接数 比率 - if (_bindAdapter->_pReportConRate) - { - _bindAdapter->_pReportConRate->report((int)(_bindAdapter->getNowConnection() * 1000 / _bindAdapter->getMaxConns())); - } - - //有队列, 且队列长度>0才上报 - if (_bindAdapter->_pReportQueue) - { - _bindAdapter->_pReportQueue->report((int)_bindAdapter->getRecvBufferSize()); - } - } + //上报连接数 比率 + if (_bindAdapter->_pReportConRate) + { + _bindAdapter->_pReportConRate->report( + (int) (_bindAdapter->getNowConnection() * 1000 / _bindAdapter->getMaxConns())); + } + + //有队列, 且队列长度>0才上报 + if (_bindAdapter->_pReportQueue) + { + _bindAdapter->_pReportQueue->report((int) _bindAdapter->getRecvBufferSize()); + } + } } CurrentPtr ServantHandle::createCurrent(const shared_ptr &data) { - CurrentPtr current = new Current(this); + CurrentPtr current = new Current(this); try { @@ -271,96 +229,84 @@ CurrentPtr ServantHandle::createCurrent(const shared_ptrgetBindAdapter()->isTarsProtocol()) + if (current->getBindAdapter()->isTarsProtocol()) { int64_t now = TNOWMS; - //数据在队列中的时间超过了客户端等待的时间(TARS协议) - if (current->_request.iTimeout > 0 && (now - data->recvTimeStamp()) > current->_request.iTimeout) - { - //上报超时数目 - if (data->adapter()->_pReportTimeoutNum) - data->adapter()->_pReportTimeoutNum->report(1); + //数据在队列中的时间超过了客户端等待的时间(TARS协议) + if (current->_request.iTimeout > 0 && (now - data->recvTimeStamp()) > current->_request.iTimeout) + { + //上报超时数目 + if (data->adapter()->_pReportTimeoutNum) + data->adapter()->_pReportTimeoutNum->report(1); TLOGERROR("[TARS][ServantHandle::handle queue timeout:" - << current->_request.sServantName << ", func:" - << current->_request.sFuncName << ", recv time:" - << data->recvTimeStamp() << ", queue timeout:" - << data->adapter()->getQueueTimeout() << ", timeout:" - << current->_request.iTimeout << ", now:" - << now << ", ip:" << data->ip() << ", port:" << data->port() << "]" << endl); + << current->_request.sServantName << ", func:" + << current->_request.sFuncName << ", recv time:" + << data->recvTimeStamp() << ", queue timeout:" + << data->adapter()->getQueueTimeout() << ", timeout:" + << current->_request.iTimeout << ", now:" + << now << ", ip:" << data->ip() << ", port:" << data->port() << "]" << endl); current->sendResponse(TARSSERVERQUEUETIMEOUT); - return NULL; - } - } + return NULL; + } + } - return current; + return current; } CurrentPtr ServantHandle::createCloseCurrent(const shared_ptr &data) { - CurrentPtr current = new Current(this); + CurrentPtr current = new Current(this); - current->initializeClose(data); - current->setReportStat(false); - current->setCloseType(data->closeType()); - return current; + current->initializeClose(data); + current->setReportStat(false); + current->setCloseType(data->closeType()); + return current; } void ServantHandle::handleClose(const shared_ptr &data) { - TLOGTARS("[ServantHandle::handleClose,adapter:" << data->adapter()->getName() << ",peer:" << data->ip() << ":" << data->port() << "]"<< endl); - - CurrentPtr current = createCloseCurrent(data); + TLOGTARS("[ServantHandle::handleClose,adapter:" << data->adapter()->getName() << ",peer:" << data->ip() << ":" + << data->port() << "]" << endl); -// auto sit = _servants.find(current->getServantName()); - -// if (sit == _servants.end()) -// { -// TLOGERROR("[TARS]ServantHandle::handleClose,adapter:" << data->adapter()->getName() << ",peer:" << data->ip() << ":" << data->port() << ", " << current->getServantName() << " not found" << endl); -// -// return; -// } -// -// if(_servant) + CurrentPtr current = createCloseCurrent(data); + try { - try - { - //业务逻辑处理 - _servant->doClose(current); - } - catch (exception &ex) - { - TLOGERROR("[TARS]ServantHandle::handleClose " << ex.what() << endl); + //业务逻辑处理 + _servant->doClose(current); + } + catch (exception &ex) + { + TLOGERROR("[TARS]ServantHandle::handleClose " << ex.what() << endl); - return; - } - catch (...) - { - TLOGERROR("[TARS]ServantHandle::handleClose unknown error" << endl); + return; + } + catch (...) + { + TLOGERROR("[TARS]ServantHandle::handleClose unknown error" << endl); - return; - } + return; } } void ServantHandle::handleTimeout(const shared_ptr &data) { - CurrentPtr current = createCurrent(data); + CurrentPtr current = createCurrent(data); - if (!current) return; + if (!current) return; //上报超时数目 - if(data->adapter()->_pReportTimeoutNum) + if (data->adapter()->_pReportTimeoutNum) data->adapter()->_pReportTimeoutNum->report(1); TLOGERROR("[ServantHandle::handleTimeout adapter '" - << data->adapter()->getName() - << "', recvtime:" << data->recvTimeStamp() << "|" - << ", timeout:" << data->adapter()->getQueueTimeout() - << ", id:" << current->getRequestId() << "]" << endl); + << data->adapter()->getName() + << "', recvtime:" << data->recvTimeStamp() << "|" + << ", timeout:" << data->adapter()->getQueueTimeout() + << ", id:" << current->getRequestId() << "]" << endl); if (current->getBindAdapter()->isTarsProtocol()) { @@ -372,15 +318,15 @@ void ServantHandle::handleTimeout(const shared_ptr void ServantHandle::handleOverload(const shared_ptr &data) { - CurrentPtr current = createCurrent(data); + CurrentPtr current = createCurrent(data); - if (!current) return; + if (!current) return; TLOGERROR("[ServantHandle::handleOverload adapter '" - << data->adapter()->getName() - << "',overload:-1,queue capacity:" - << data->adapter()->getQueueCapacity() - << ",id:" << current->getRequestId() << "]" << endl); + << data->adapter()->getName() + << "',overload:-1,queue capacity:" + << data->adapter()->getQueueCapacity() + << ",id:" << current->getRequestId() << "]" << endl); if (current->getBindAdapter()->isTarsProtocol()) { @@ -392,15 +338,14 @@ void ServantHandle::handleOverload(const shared_ptr void ServantHandle::handle(const shared_ptr &data) { - CurrentPtr current = createCurrent(data); + CurrentPtr current = createCurrent(data); - if (!current) return; + if (!current) return; if (current->getBindAdapter()->isTarsProtocol()) { handleTarsProtocol(current); - } - else + } else { handleNoTarsProtocol(current); } @@ -408,15 +353,15 @@ void ServantHandle::handle(const shared_ptr &data) reportReqTime(data, current); } -bool ServantHandle::processDye(const CurrentPtr ¤t, string& dyeingKey) +bool ServantHandle::processDye(const CurrentPtr ¤t, string &dyeingKey) { - //当前线程的线程数据 - ServantProxyThreadData *sptd = ServantProxyThreadData::getData(); + //当前线程的线程数据 + ServantProxyThreadData *sptd = ServantProxyThreadData::getData(); - if (sptd) - { - sptd->_data._dyeingKey = ""; - } + if (sptd) + { + sptd->_data._dyeingKey = ""; + } //当前请求已经被染色, 需要打印染色日志 map::const_iterator dyeingIt = current->getRequestStatus().find(ServantProxy::STATUS_DYED_KEY); @@ -434,29 +379,31 @@ bool ServantHandle::processDye(const CurrentPtr ¤t, string& dyeingKey) return true; } - //servant已经被染色, 开启染色日志 - if (_application->getServantHelper()->isDyeing()) - { - map::const_iterator dyeingKeyIt = current->getRequestStatus().find(ServantProxy::STATUS_GRID_KEY); + //servant已经被染色, 开启染色日志 + if (_application->getServantHelper()->isDyeing()) + { + map::const_iterator dyeingKeyIt = current->getRequestStatus().find( + ServantProxy::STATUS_GRID_KEY); - if (dyeingKeyIt != current->getRequestStatus().end() && - _application->getServantHelper()->isDyeingReq(dyeingKeyIt->second, current->getServantName(), current->getFuncName())) - { - TLOGTARS("[TARS] dyeing servant got a dyeing req, key:" << dyeingKeyIt->second << endl); + if (dyeingKeyIt != current->getRequestStatus().end() && + _application->getServantHelper()->isDyeingReq(dyeingKeyIt->second, current->getServantName(), + current->getFuncName())) + { + TLOGTARS("[TARS] dyeing servant got a dyeing req, key:" << dyeingKeyIt->second << endl); - dyeingKey = dyeingKeyIt->second; + dyeingKey = dyeingKeyIt->second; - return true; - } - } + return true; + } + } - return false; + return false; } bool ServantHandle::processTrace(const CurrentPtr ¤t) { //当前线程的线程数据 - ServantProxyThreadData* sptd = ServantProxyThreadData::getData(); + ServantProxyThreadData *sptd = ServantProxyThreadData::getData(); if (sptd) { @@ -479,8 +426,7 @@ bool ServantHandle::processTrace(const CurrentPtr ¤t) { sptd->_traceCall = true; return true; - } - else + } else { TLOGTARS("[TARS] servant got a trace request, but trace key is error:" << traceIt->second << endl); } @@ -491,26 +437,30 @@ bool ServantHandle::processTrace(const CurrentPtr ¤t) bool ServantHandle::processCookie(const CurrentPtr ¤t, map &cookie) { - const static string STATUS = "STATUS_"; - - std::for_each(current->getRequestStatus().begin(), current->getRequestStatus().end(),[&](const map::value_type& p){ - if(p.first.size() > STATUS.size() && TC_Port::strncasecmp(p.first.c_str(), STATUS.c_str(), STATUS.size()) == 0) { - return; - } - cookie.insert(make_pair(p.first, p.second)); - }); - - return !cookie.empty(); + const static string STATUS = "STATUS_"; + + std::for_each(current->getRequestStatus().begin(), current->getRequestStatus().end(), + [&](const map::value_type &p) + { + if (p.first.size() > STATUS.size() && + TC_Port::strncasecmp(p.first.c_str(), STATUS.c_str(), STATUS.size()) == 0) + { + return; + } + cookie.insert(make_pair(p.first, p.second)); + }); + + return !cookie.empty(); } bool ServantHandle::checkValidSetInvoke(const CurrentPtr ¤t) { - /*是否允许检查合法性*/ - if (ServerConfig::IsCheckSet == 0) - { - //不检查 - return true; - } + /*是否允许检查合法性*/ + if (ServerConfig::IsCheckSet == 0) + { + //不检查 + return true; + } bool isSetInvoke = IS_MSG_TYPE(current->getMessageType(), tars::TARSMESSAGETYPESETNAME); //客户端按set规则调用且服务端启用set @@ -523,82 +473,79 @@ bool ServantHandle::checkValidSetInvoke(const CurrentPtr ¤t) * 3 客户端set名称与服务端set属于不同名称,eg,test1.s.1 <->test2.n.2 * 4 1,2,3条件都不满足,则认为该调用不合法 */ - map::const_iterator setIt = current->getRequestStatus().find(ServantProxy::STATUS_SETNAME_VALUE); + map::const_iterator setIt = current->getRequestStatus().find( + ServantProxy::STATUS_SETNAME_VALUE); string sSetName(""); if (setIt != current->getRequestStatus().end()) { TLOGTARS("[servant got a setname request, setname key:" << setIt->second << "]" << endl); - sSetName = setIt->second; + sSetName = setIt->second; if (ClientConfig::SetDivision == sSetName) { return true; - } - else + } else { //属于同一地区是也属于合法调用 - string setArea1 = ClientConfig::SetDivision.substr(0,ClientConfig::SetDivision.find_last_of(".")); - string setArea2 = sSetName.substr(0,sSetName.find_last_of(".")); + string setArea1 = ClientConfig::SetDivision.substr(0, ClientConfig::SetDivision.find_last_of(".")); + string setArea2 = sSetName.substr(0, sSetName.find_last_of(".")); if (setArea1 == setArea2) { return true; - } - else if (ClientConfig::SetDivision.substr(0,ClientConfig::SetDivision.find_first_of(".")) != - sSetName.substr(0,sSetName.find_first_of("."))) + } else if (ClientConfig::SetDivision.substr(0, ClientConfig::SetDivision.find_first_of(".")) != + sSetName.substr(0, sSetName.find_first_of("."))) { //属于不同的set之间调用也属于合法 return true; - } - else + } else { TLOGERROR("[ServantHandle::checkValidSetInvoke|" - << current->getIp() << "|" - << current->getMessageType() << "|" - << current->getServantName() << "|" - << current->getFuncName() << "|client:" - << ClientConfig::SetDivision << "|server:" - << sSetName << "]" << endl); + << current->getIp() << "|" + << current->getMessageType() << "|" + << current->getServantName() << "|" + << current->getFuncName() << "|client:" + << ClientConfig::SetDivision << "|server:" + << sSetName << "]" << endl); current->sendResponse(TARSINVOKEBYINVALIDESET); return false; } } - } - else + } else { TLOGERROR("[ServantHandle::checkValidSetInvoke|" - << current->getIp() << "|" - << current->getMessageType() << "|" - << current->getServantName() << "|" - << current->getFuncName() << "|client:" - << ClientConfig::SetDivision << "|server:" - << sSetName << "]" << endl); + << current->getIp() << "|" + << current->getMessageType() << "|" + << current->getServantName() << "|" + << current->getFuncName() << "|client:" + << ClientConfig::SetDivision << "|server:" + << sSetName << "]" << endl); current->sendResponse(TARSINVOKEBYINVALIDESET); return false; } } - //没有按set规则调用 - return true; + //没有按set规则调用 + return true; } void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) { TLOGTARS("[ServantHandle::handleTarsProtocol current:" - << current->getIp() << "|" - << current->getPort() << "|" - << current->getMessageType() << "|" - << current->getServantName() << "|" - << current->getFuncName() << "|" - << current->getRequestId() << "|" - << TC_Common::tostr(current->getRequestStatus()) << "]"<getIp() << "|" + << current->getPort() << "|" + << current->getMessageType() << "|" + << current->getServantName() << "|" + << current->getFuncName() << "|" + << current->getRequestId() << "|" + << TC_Common::tostr(current->getRequestStatus()) << "]" << endl); + + //检查set调用合法性 + if (!checkValidSetInvoke(current)) + { + return; + } //处理染色消息 string dyeingKey = ""; @@ -610,17 +557,17 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) processTrace(current); - //处理cookie - map cookie; - CookieOp cookieOp; - if (processCookie(current, cookie)) - { - cookieOp.setCookie(cookie); - current->setCookie(cookie); - } + //处理cookie + map cookie; + CookieOp cookieOp; + if (processCookie(current, cookie)) + { + cookieOp.setCookie(cookie); + current->setCookie(cookie); + } // processSample(current); - if(_servant->getName() != current->getServantName()) + if (_servant->getName() != current->getServantName()) { current->sendResponse(TARSSERVERNOSERVANTERR); // #ifdef TARS_OPENTRACKING @@ -631,16 +578,16 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) int ret = TARSSERVERUNKNOWNERR; - string sResultDesc = ""; + string sResultDesc = ""; - ResponsePacket response; + ResponsePacket response; try { //业务逻辑处理 ret = _servant->dispatch(current, response.sBuffer); } - catch(TarsDecodeException &ex) + catch (TarsDecodeException &ex) { TLOGERROR("[ServantHandle::handleTarsProtocol " << ex.what() << "]" << endl); @@ -648,7 +595,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) sResultDesc = ex.what(); } - catch(TarsEncodeException &ex) + catch (TarsEncodeException &ex) { TLOGERROR("[ServantHandle::handleTarsProtocol " << ex.what() << "]" << endl); @@ -656,7 +603,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) sResultDesc = ex.what(); } - catch(exception &ex) + catch (exception &ex) { TLOGERROR("[ServantHandle::handleTarsProtocol " << ex.what() << "]" << endl); @@ -664,7 +611,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) sResultDesc = ex.what(); } - catch(...) + catch (...) { TLOGERROR("[ServantHandle::handleTarsProtocol unknown error]" << endl); @@ -673,11 +620,11 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) sResultDesc = "handleTarsProtocol unknown exception error"; } - if(ret == TARSSERVERNOFUNCERR) - { - ret = _servant->doNoFunc(current); - } - + if (ret == TARSSERVERNOFUNCERR) + { + ret = _servant->doNoFunc(current); + } + //单向调用或者业务不需要同步返回 if (current->isResponse()) { @@ -691,36 +638,34 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) void ServantHandle::handleNoTarsProtocol(const TarsCurrentPtr ¤t) { TLOGTARS("[ServantHandle::handleNoTarsProtocol current:" - << current->getIp() << "|" - << current->getPort() << "|" - << current->getServantName() << "]" << endl); + << current->getIp() << "|" + << current->getPort() << "|" + << current->getServantName() << "]" << endl); -// auto sit = _servants.find(current->getServantName()); -// assert(sit != _servants.end()); - - vector buffer; + vector buffer; try { //业务逻辑处理 _servant->dispatch(current, buffer); } - catch(exception &ex) + catch (exception &ex) { TLOGERROR("[ServantHandle::handleNoTarsProtocol " << ex.what() << "]" << endl); } - catch(...) + catch (...) { TLOGERROR("[ServantHandle::handleNoTarsProtocol unknown error]" << endl); } - if (current->isResponse() && !buffer.empty()) - { - current->sendResponse((const char *)(buffer.data()), (uint32_t)buffer.size()); - } + if (current->isResponse() && !buffer.empty()) + { + current->sendResponse((const char *) (buffer.data()), (uint32_t) buffer.size()); + } } -void ServantHandle::reportReqTime(const shared_ptr &data, const CurrentPtr ¤t) { +void ServantHandle::reportReqTime(const shared_ptr &data, const CurrentPtr ¤t) +{ current->_reqTime.setFinishTimeStamp(TNOWUS); // 上报队列等待时间 @@ -732,5 +677,4 @@ void ServantHandle::reportReqTime(const shared_ptr data->adapter()->_pReportServantHandleTime->report(current->_reqTime.servantHandleTime()); } -//////////////////////////////////////////////////////////////////////////// } diff --git a/servant/libservant/ServantProxy.cpp b/servant/libservant/ServantProxy.cpp index d114209c..5a5712f5 100644 --- a/servant/libservant/ServantProxy.cpp +++ b/servant/libservant/ServantProxy.cpp @@ -330,6 +330,20 @@ const map & ServantProxyCallback::getResponseContext() return pCbtd->getResponseContext(); } +void ServantProxyCallback::setServantPrx(const ServantPrx &prx) +{ + _servantPrx = prx; + + _moduleName = std::make_shared(_servantPrx->_communicator->getProperty("modulename")); +} + +string ServantProxyCallback::getModuleName() +{ + auto moduleName = _moduleName; + + return *moduleName.get(); +} + /////////////////////////////////////////////////////////////////////////////////////////// int HttpServantProxyCallback::onDispatch(ReqMessagePtr msg) @@ -417,6 +431,8 @@ ServantProxy::ServantProxy(Communicator *pCommunicator, const string &name, cons _proxyProtocol.requestFunc = ProxyProtocol::tarsRequest; _proxyProtocol.responseFunc = ProxyProtocol::tarsResponse; + _moduleName = _communicator->getProperty("modulename", TC_File::extractFileName(TC_File::getExePath())); + //在每个公有网络线程对象中创建ObjectProxy for (size_t i = 0; i < _communicator->getCommunicatorEpollNum(); ++i) { @@ -454,6 +470,11 @@ const string &ServantProxy::tars_name() const return _objectProxy->name(); } +const string &ServantProxy::tars_moduleName() const +{ + return _moduleName; +} + string ServantProxy::tars_full_name() const { string name = _objectProxy->name(); @@ -1785,6 +1806,9 @@ vector ServantProxy::getEndpoint4All() return activeEndPoint; } - +void TARS_TRACE(const string &traceKey, const char *annotation, const string &client, const string &server, const char* func, int ret, const string &data, const string &ex) +{ + FDLOG(TRACE_LOG_FILENAME) << traceKey << "|" << annotation << "|" << client << "|" << server << "|" << func << "|" << TNOWMS << "|" << ret << "|" << TC_Base64::encode(data) << "|" << ex << endl; +} ////////////////////////////////////////////////////////////////////////////////////////////////// } diff --git a/servant/protocol b/servant/protocol index 9b3921b1..8afa10af 160000 --- a/servant/protocol +++ b/servant/protocol @@ -1 +1 @@ -Subproject commit 9b3921b1036a24ed175650160f793b9b94459ea8 +Subproject commit 8afa10af0b0521bc08af31fd8938f53779aded4b diff --git a/servant/servant/Application.h b/servant/servant/Application.h index 21fe2473..3da00b64 100644 --- a/servant/servant/Application.h +++ b/servant/servant/Application.h @@ -29,8 +29,8 @@ #include "servant/BaseNotify.h" #include "servant/ServantHelper.h" #include "servant/ServantHandle.h" +#include "servant/Communicator.h" #include "servant/StatReport.h" -#include "Communicator.h" #include "servant/RemoteLogger.h" #include "servant/RemoteConfig.h" #include "servant/RemoteNotify.h" diff --git a/servant/servant/Communicator.h b/servant/servant/Communicator.h index 7ccbc255..c8813ac5 100644 --- a/servant/servant/Communicator.h +++ b/servant/servant/Communicator.h @@ -23,9 +23,7 @@ #include "servant/Global.h" #include "servant/ServantProxy.h" #include "servant/ServantProxyFactory.h" -//#include "servant/ObjectProxyFactory.h" #include "servant/AsyncProcThread.h" -// #include "servant/CommunicatorEpoll.h" #include "servant/StatReport.h" #include "servant/RemoteLogger.h" diff --git a/servant/servant/Current.h b/servant/servant/Current.h index 86f6683d..79c3a95d 100644 --- a/servant/servant/Current.h +++ b/servant/servant/Current.h @@ -121,6 +121,12 @@ class Current : public TC_HandleBase */ ServantHandle* getServantHandle(); + /** + * 当前此服务端的名称: app.server, 给调用链使用 + * @return + */ + string getModuleName(); + /** * 获取来源的Adapter * @return TC_EpollServer::BindAdapter* @@ -270,10 +276,11 @@ class Current : public TC_HandleBase * 是否需要追踪调用链 */ bool isTraced() const; + /** * 调用链追踪Key */ - string getTraceKey() const; + const string &getTraceKey() const; /** * 服务器端连接是否还存在 diff --git a/servant/servant/EndpointInfo.h b/servant/servant/EndpointInfo.h index 0603bc04..82faf9fc 100755 --- a/servant/servant/EndpointInfo.h +++ b/servant/servant/EndpointInfo.h @@ -17,11 +17,9 @@ #ifndef __TARS_ENDPOINT_INFO_H_ #define __TARS_ENDPOINT_INFO_H_ -//#include "servant/Global.h" #include "util/tc_socket.h" #include "util/tc_clientsocket.h" #include "servant/EndpointF.h" -//#include "AuthF.h" #if TARGET_PLATFORM_WINDOWS #include diff --git a/servant/servant/RemoteConfig.h b/servant/servant/RemoteConfig.h index dc5a32d7..86b2088d 100644 --- a/servant/servant/RemoteConfig.h +++ b/servant/servant/RemoteConfig.h @@ -43,6 +43,9 @@ namespace tars * */ +class ConfigProxy; +typedef tars::TC_AutoPtr ConfigPrx; + class SVT_DLL_API RemoteConfig : public TC_Singleton { public: diff --git a/servant/servant/RemoteLogger.h b/servant/servant/RemoteLogger.h index e72920d1..ecb8b53d 100755 --- a/servant/servant/RemoteLogger.h +++ b/servant/servant/RemoteLogger.h @@ -56,6 +56,8 @@ namespace tars 8 RemoteTimeLogger会在RemoteTimeWriteT对象中, 异步写入到远程 9 从而本地文件写和远程写不在一个线程中. *****************************************************************************/ +//class LogProxy; +//typedef tars::TC_AutoPtr LogPrx; /////////////////////////////////////////////////////////////////////////////// @@ -73,8 +75,6 @@ class RollWriteT TC_RollLogger *_dyeingRollLogger; -// static int _dyeingThread; - string _app; string _server; string _logPath; @@ -999,23 +999,6 @@ class TarsDyeingSwitch #define FDLOG_DEBUG(x) FDLOG(x) << FILE_FUNC_LINE << "|" #endif -/////////////////////////////////////////// -/** - * 调用链追踪 - */ -#define TRACE_ANNOTATION_TS "ts" -#define TRACE_ANNOTATION_TE "te" -#define TRACE_ANNOTATION_CS "cs" -#define TRACE_ANNOTATION_CR "cr" -#define TRACE_ANNOTATION_SR "sr" -#define TRACE_ANNOTATION_SS "ss" - -#define TRACE_LOG_FILENAME "_t_trace_" -// traceKey: traceType-TraceID|SpanID|ParentSpanID -#define TARS_TRACE(traceKey, annotation, client, server, func, ret, data, ex) \ - { \ - FDLOG(TRACE_LOG_FILENAME) << traceKey << "|" << annotation << "|" << client << "|" << server << "|" << func << "|" << TNOWMS << "|" << ret << "|" << TC_Base64::encode(data) << "|" << ex << endl; \ - } ////////////////////////////////////////////// /** diff --git a/servant/servant/Servant.h b/servant/servant/Servant.h index 1c4367a0..8cdf2d25 100644 --- a/servant/servant/Servant.h +++ b/servant/servant/Servant.h @@ -77,6 +77,12 @@ class Servant : public BaseNotify */ Application* getApplication() const; + /** + * 获取服务端的名称: app.server + * @return + */ + string getModuleName(); + /** * 获取所属的Handle * @return HandlePtr& @@ -216,36 +222,36 @@ class ServantCallback : public ServantProxyCallback public: /** * 构造函数,type用来区分同一链路上的多种cb对象类型 - * @param type - * @param servant - * @param current + * @param type + * @param servant + * @param current */ ServantCallback(const string& type, const ServantPtr& servant, const CurrentPtr& current); /** - * callback的响应接口 - * @param msg - * @return int + * callback的响应接口 + * @param msg + * @return int */ virtual int onDispatch(ReqMessagePtr msg); /** * 连接关闭 - * @param msg - * @return int - */ + * @param msg + * @return int + */ virtual void onClose() { } /** * 获得生成时所属的servant - * @return const ServantPtr& + * @return const ServantPtr& */ const ServantPtr& getServant(); /** * 获得网络上下文 - * @return const CurrentPtr& + * @return const CurrentPtr& */ const CurrentPtr& getCurrent(); @@ -261,7 +267,7 @@ class ServantCallback : public ServantProxyCallback ////////////////////////////////////////////////////////////////////// //线程私有数据 -class CallbackThreadData //: public TC_ThreadPool::ThreadData +class CallbackThreadData { public: static thread_local shared_ptr g_sp; diff --git a/servant/servant/ServantHandle.h b/servant/servant/ServantHandle.h index 9a5e8c95..e8277790 100644 --- a/servant/servant/ServantHandle.h +++ b/servant/servant/ServantHandle.h @@ -66,6 +66,12 @@ class ServantHandle : public TC_EpollServer::Handle */ Application *getApplication() { return _application; } + /** + * 获取服务端的名称: app.server + * @return + */ + string getModuleName(); + /** * 获取实际的servant * @return diff --git a/servant/servant/ServantProxy.h b/servant/servant/ServantProxy.h index 89dd00ae..4bbc0954 100644 --- a/servant/servant/ServantProxy.h +++ b/servant/servant/ServantProxy.h @@ -28,6 +28,7 @@ #include "servant/AppProtocol.h" #include "servant/Current.h" #include "servant/EndpointInfo.h" + #include #include #include @@ -37,6 +38,22 @@ namespace tars class CommunicatorEpoll; class EndpointInfo; + +/////////////////////////////////////////// +/** + * 调用链追踪 + */ +#define TRACE_ANNOTATION_TS "ts" +#define TRACE_ANNOTATION_TE "te" +#define TRACE_ANNOTATION_CS "cs" +#define TRACE_ANNOTATION_CR "cr" +#define TRACE_ANNOTATION_SR "sr" +#define TRACE_ANNOTATION_SS "ss" + +#define TRACE_LOG_FILENAME "_t_trace_" +// traceKey: traceType-TraceID|SpanID|ParentSpanID +void TARS_TRACE(const string &traceKey, const char *annotation, const string &client, const string &server, const char* func, int ret, const string &data, const string &ex); + ///////////////////////////////////////////////////////////////////////// //seq 管理的类 @@ -600,7 +617,7 @@ class ServantProxyCallback : virtual public TC_HandleBase * 设置发起调用的servant * @param prx */ - void setServantPrx(const ServantPrx &prx) { _servantPrx = prx; } + void setServantPrx(const ServantPrx &prx); /** * 获取类型 @@ -673,6 +690,12 @@ class ServantProxyCallback : virtual public TC_HandleBase virtual void onConnect(const TC_Endpoint& ep, int fd) {} + /** + * get module name + * @return + */ + string getModuleName(); + friend class AdapterProxy; protected: @@ -696,6 +719,11 @@ class ServantProxyCallback : virtual public TC_HandleBase * servant prx */ ServantPrx _servantPrx; + + /** + * moduleName for trace + */ + shared_ptr _moduleName; }; /////////////////////////////////////////////////////////////////////////////////////////////// // for http @@ -951,6 +979,12 @@ class ServantProxy : public TC_HandleBase, public TC_ThreadMutex */ const string &tars_name() const; + /** + * 当前客户端的moduleName + * @return + */ + const string &tars_moduleName() const; + /** * set name * @return @@ -1430,6 +1464,10 @@ class ServantProxy : public TC_HandleBase, public TC_ThreadMutex */ vector _socketOpts; + /** + * 对应通信内部的moduleName + */ + string _moduleName; }; } #endif diff --git a/tools/tars2cpp/tars2cpp.cpp b/tools/tars2cpp/tars2cpp.cpp index 1859105b..a7075874 100755 --- a/tools/tars2cpp/tars2cpp.cpp +++ b/tools/tars2cpp/tars2cpp.cpp @@ -1425,7 +1425,7 @@ string Tars2Cpp::generateDispatchAsync(const OperationPtr& pPtr, const string& c DEL_TAB; s << TAB << "}" << endl; - s << TAB << "TARS_TRACE(_pSptd_->getTraceKey(ServantProxyThreadData::TraceContext::EST_CR), TRACE_ANNOTATION_CR, \"\", ServerConfig::Application + \".\" + ServerConfig::ServerName, \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl; + s << TAB << "TARS_TRACE(_pSptd_->getTraceKey(ServantProxyThreadData::TraceContext::EST_CR), TRACE_ANNOTATION_CR, \"\", getModuleName(), \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl; DEL_TAB; s << TAB << "}" << endl; s << endl; @@ -1843,7 +1843,7 @@ string Tars2Cpp::generateServantDispatch(const OperationPtr& pPtr, const string& DEL_TAB; s << TAB << "}" << endl; - s << TAB << "TARS_TRACE(_pSptd_->getTraceKey(ServantProxyThreadData::TraceContext::EST_SR), TRACE_ANNOTATION_SR, \"\", ServerConfig::Application + \".\" + ServerConfig::ServerName, \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl; + s << TAB << "TARS_TRACE(_pSptd_->getTraceKey(ServantProxyThreadData::TraceContext::EST_SR), TRACE_ANNOTATION_SR, \"\", getModuleName(), \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl; DEL_TAB; s << TAB << "}" << endl; s << endl; @@ -2035,7 +2035,7 @@ string Tars2Cpp::generateServantDispatch(const OperationPtr& pPtr, const string& s << TAB << "_trace_param_ = " << G_TRACE_PARAM_OVER_MAX_LEN << ";" << endl; DEL_TAB; s << TAB << "}" << endl; - s << TAB << "TARS_TRACE(_pSptd_->getTraceKey(ServantProxyThreadData::TraceContext::EST_SS), TRACE_ANNOTATION_SS, \"\", ServerConfig::Application + \".\" + ServerConfig::ServerName, \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl; + s << TAB << "TARS_TRACE(_pSptd_->getTraceKey(ServantProxyThreadData::TraceContext::EST_SS), TRACE_ANNOTATION_SS, \"\", getModuleName(), \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl; DEL_TAB; s << TAB << "}" << endl; s << endl; @@ -2205,7 +2205,7 @@ string Tars2Cpp::generateHAsync(const OperationPtr& pPtr, const string& cn) cons s << TAB << "_trace_param_ = " << G_TRACE_PARAM_OVER_MAX_LEN << ";" << endl; DEL_TAB; s << TAB << "}" << endl; - s << TAB << "TARS_TRACE(_pSptd_->getTraceKey(ServantProxyThreadData::TraceContext::EST_CS), TRACE_ANNOTATION_CS, ServerConfig::Application + \".\" + ServerConfig::ServerName, tars_name(), \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl; + s << TAB << "TARS_TRACE(_pSptd_->getTraceKey(ServantProxyThreadData::TraceContext::EST_CS), TRACE_ANNOTATION_CS, tars_moduleName(), tars_name(), \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl; DEL_TAB; s << TAB << "}" << endl; } @@ -2401,7 +2401,7 @@ string Tars2Cpp::generateH(const OperationPtr& pPtr, bool bVirtual, const string s << TAB << "_trace_param_ = " << G_TRACE_PARAM_OVER_MAX_LEN << ";" << endl; DEL_TAB; s << TAB << "}" << endl; - s << TAB << "TARS_TRACE(_pSptd_->getTraceKey(ServantProxyThreadData::TraceContext::EST_CS), TRACE_ANNOTATION_CS, ServerConfig::Application + \".\" + ServerConfig::ServerName, tars_name(), \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl; + s << TAB << "TARS_TRACE(_pSptd_->getTraceKey(ServantProxyThreadData::TraceContext::EST_CS), TRACE_ANNOTATION_CS, tars_moduleName(), tars_name(), \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl; DEL_TAB; s << TAB << "}" << endl; s << endl; @@ -2480,7 +2480,7 @@ string Tars2Cpp::generateH(const OperationPtr& pPtr, bool bVirtual, const string s << TAB << "_trace_param_ = " << G_TRACE_PARAM_OVER_MAX_LEN << ";" << endl; DEL_TAB; s << TAB << "}" << endl; - s << TAB << "TARS_TRACE(_pSptd_->getTraceKey(ServantProxyThreadData::TraceContext::EST_CR), TRACE_ANNOTATION_CR, ServerConfig::Application + \".\" + ServerConfig::ServerName, tars_name(), \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl; + s << TAB << "TARS_TRACE(_pSptd_->getTraceKey(ServantProxyThreadData::TraceContext::EST_CR), TRACE_ANNOTATION_CR, tars_moduleName(), tars_name(), \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl; DEL_TAB; s << TAB << "}" << endl; s << endl; @@ -2499,7 +2499,7 @@ string Tars2Cpp::generateH(const OperationPtr& pPtr, bool bVirtual, const string INC_TAB; s << TAB << "TARS_TRACE(_pSptd_->getTraceKey(ServantProxyThreadData::TraceContext::EST_CR), TRACE_ANNOTATION_CR, \"\", \"\", \"" << pPtr->getId() << "\", 0, \"\", \"\");" << endl; DEL_TAB; - s << "}" << endl; + s << TAB << "}" << endl; } DEL_TAB; s << TAB << "}" << endl; @@ -2669,7 +2669,12 @@ string Tars2Cpp::generateH(const OperationPtr& pPtr, bool bVirtual, const string s << TAB << "_trace_param_ = " << G_TRACE_PARAM_OVER_MAX_LEN << ";" << endl; DEL_TAB; s << TAB << "}" << endl; - s << TAB << "TARS_TRACE(_current_->getTraceKey(), TRACE_ANNOTATION_SS, \"\", ServerConfig::Application + \".\" + ServerConfig::ServerName, \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl; + s << TAB << "if(_current_->getServantHandle())" << endl; + s << TAB << "{" << endl; + INC_TAB; + s << TAB << "TARS_TRACE(_current_->getTraceKey(), TRACE_ANNOTATION_SS, \"\", _current_->getModuleName(), \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl; + DEL_TAB; + s << TAB << "}" << endl; DEL_TAB; s << TAB << "}" << endl; s << endl; @@ -3440,11 +3445,8 @@ void Tars2Cpp::generateH(const ContextPtr &pPtr) const { s << "#include \"servant/ServantProxy.h\"" << endl; s << "#include \"servant/Servant.h\"" << endl; - s << "#include \"promise/promise.h\"" << endl; - if (_bTrace) - { - s << "#include \"servant/Application.h\"" << endl; - } + s << "#include \"promise/promise.h\"" << endl; + break; } } diff --git a/tools/tarsgrammar/tars.tab.cpp b/tools/tarsgrammar/tars.tab.cpp index ee40db41..ea2659e4 100644 --- a/tools/tarsgrammar/tars.tab.cpp +++ b/tools/tarsgrammar/tars.tab.cpp @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.7.6. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, + 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 @@ -15,7 +16,7 @@ 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 . */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -33,6 +34,10 @@ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ + /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. @@ -40,11 +45,11 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -/* Identify Bison output. */ -#define YYBISON 1 +/* Identify Bison output, and Bison version. */ +#define YYBISON 30706 -/* Bison version. */ -#define YYBISON_VERSION "3.0.4" +/* Bison version string. */ +#define YYBISON_VERSION "3.7.6" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -61,8 +66,8 @@ -/* Copy the first part of user declarations. */ -#line 17 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:339 */ +/* First part of user prologue. */ +#line 17 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" #include #include @@ -76,119 +81,213 @@ using namespace std; #define YYDEBUG 1 #define YYINITDEPTH 10000 -#line 80 "tars.tab.cpp" /* yacc.c:339 */ +#line 85 "tars.tab.cpp" +# ifndef YY_CAST +# ifdef __cplusplus +# define YY_CAST(Type, Val) static_cast (Val) +# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val) +# else +# define YY_CAST(Type, Val) ((Type) (Val)) +# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) +# endif +# endif # ifndef YY_NULLPTR -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif # else -# define YY_NULLPTR 0 +# define YY_NULLPTR ((void*)0) # endif # endif -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* In a future release of Bison, this section will be replaced - by #include "tars.tab.hpp". */ -#ifndef YY_YY_TARS_TAB_HPP_INCLUDED -# define YY_YY_TARS_TAB_HPP_INCLUDED -/* Debug traces. */ -#ifndef YYDEBUG -# define YYDEBUG 1 -#endif -#if YYDEBUG -extern int yydebug; -#endif - -/* Token type. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - enum yytokentype - { - TARS_VOID = 258, - TARS_STRUCT = 259, - TARS_BOOL = 260, - TARS_BYTE = 261, - TARS_SHORT = 262, - TARS_INT = 263, - TARS_DOUBLE = 264, - TARS_FLOAT = 265, - TARS_LONG = 266, - TARS_STRING = 267, - TARS_VECTOR = 268, - TARS_MAP = 269, - TARS_NAMESPACE = 270, - TARS_INTERFACE = 271, - TARS_IDENTIFIER = 272, - TARS_OUT = 273, - TARS_OP = 274, - TARS_KEY = 275, - TARS_ROUTE_KEY = 276, - TARS_REQUIRE = 277, - TARS_OPTIONAL = 278, - TARS_CONST_INTEGER = 279, - TARS_CONST_FLOAT = 280, - TARS_FALSE = 281, - TARS_TRUE = 282, - TARS_STRING_LITERAL = 283, - TARS_SCOPE_DELIMITER = 284, - TARS_CONST = 285, - TARS_ENUM = 286, - TARS_UNSIGNED = 287, - BAD_CHAR = 288 - }; -#endif +#include "tars.tab.hpp" +/* Symbol kind. */ +enum yysymbol_kind_t +{ + YYSYMBOL_YYEMPTY = -2, + YYSYMBOL_YYEOF = 0, /* "end of file" */ + YYSYMBOL_YYerror = 1, /* error */ + YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ + YYSYMBOL_TARS_VOID = 3, /* TARS_VOID */ + YYSYMBOL_TARS_STRUCT = 4, /* TARS_STRUCT */ + YYSYMBOL_TARS_BOOL = 5, /* TARS_BOOL */ + YYSYMBOL_TARS_BYTE = 6, /* TARS_BYTE */ + YYSYMBOL_TARS_SHORT = 7, /* TARS_SHORT */ + YYSYMBOL_TARS_INT = 8, /* TARS_INT */ + YYSYMBOL_TARS_DOUBLE = 9, /* TARS_DOUBLE */ + YYSYMBOL_TARS_FLOAT = 10, /* TARS_FLOAT */ + YYSYMBOL_TARS_LONG = 11, /* TARS_LONG */ + YYSYMBOL_TARS_STRING = 12, /* TARS_STRING */ + YYSYMBOL_TARS_VECTOR = 13, /* TARS_VECTOR */ + YYSYMBOL_TARS_MAP = 14, /* TARS_MAP */ + YYSYMBOL_TARS_NAMESPACE = 15, /* TARS_NAMESPACE */ + YYSYMBOL_TARS_INTERFACE = 16, /* TARS_INTERFACE */ + YYSYMBOL_TARS_IDENTIFIER = 17, /* TARS_IDENTIFIER */ + YYSYMBOL_TARS_OUT = 18, /* TARS_OUT */ + YYSYMBOL_TARS_OP = 19, /* TARS_OP */ + YYSYMBOL_TARS_KEY = 20, /* TARS_KEY */ + YYSYMBOL_TARS_ROUTE_KEY = 21, /* TARS_ROUTE_KEY */ + YYSYMBOL_TARS_REQUIRE = 22, /* TARS_REQUIRE */ + YYSYMBOL_TARS_OPTIONAL = 23, /* TARS_OPTIONAL */ + YYSYMBOL_TARS_CONST_INTEGER = 24, /* TARS_CONST_INTEGER */ + YYSYMBOL_TARS_CONST_FLOAT = 25, /* TARS_CONST_FLOAT */ + YYSYMBOL_TARS_FALSE = 26, /* TARS_FALSE */ + YYSYMBOL_TARS_TRUE = 27, /* TARS_TRUE */ + YYSYMBOL_TARS_STRING_LITERAL = 28, /* TARS_STRING_LITERAL */ + YYSYMBOL_TARS_SCOPE_DELIMITER = 29, /* TARS_SCOPE_DELIMITER */ + YYSYMBOL_TARS_CONST = 30, /* TARS_CONST */ + YYSYMBOL_TARS_ENUM = 31, /* TARS_ENUM */ + YYSYMBOL_TARS_UNSIGNED = 32, /* TARS_UNSIGNED */ + YYSYMBOL_BAD_CHAR = 33, /* BAD_CHAR */ + YYSYMBOL_34_ = 34, /* ';' */ + YYSYMBOL_35_ = 35, /* '{' */ + YYSYMBOL_36_ = 36, /* '}' */ + YYSYMBOL_37_ = 37, /* ',' */ + YYSYMBOL_38_ = 38, /* '=' */ + YYSYMBOL_39_ = 39, /* '[' */ + YYSYMBOL_40_ = 40, /* ']' */ + YYSYMBOL_41_ = 41, /* ')' */ + YYSYMBOL_42_ = 42, /* '*' */ + YYSYMBOL_43_ = 43, /* ':' */ + YYSYMBOL_44_ = 44, /* '<' */ + YYSYMBOL_45_ = 45, /* '>' */ + YYSYMBOL_YYACCEPT = 46, /* $accept */ + YYSYMBOL_start = 47, /* start */ + YYSYMBOL_definitions = 48, /* definitions */ + YYSYMBOL_49_1 = 49, /* $@1 */ + YYSYMBOL_50_2 = 50, /* $@2 */ + YYSYMBOL_definition = 51, /* definition */ + YYSYMBOL_enum_def = 52, /* enum_def */ + YYSYMBOL_53_3 = 53, /* @3 */ + YYSYMBOL_enum_id = 54, /* enum_id */ + YYSYMBOL_enumerator_list = 55, /* enumerator_list */ + YYSYMBOL_enumerator = 56, /* enumerator */ + YYSYMBOL_namespace_def = 57, /* namespace_def */ + YYSYMBOL_58_4 = 58, /* @4 */ + YYSYMBOL_key_def = 59, /* key_def */ + YYSYMBOL_60_5 = 60, /* $@5 */ + YYSYMBOL_key_members = 61, /* key_members */ + YYSYMBOL_interface_def = 62, /* interface_def */ + YYSYMBOL_63_6 = 63, /* @6 */ + YYSYMBOL_interface_id = 64, /* interface_id */ + YYSYMBOL_interface_exports = 65, /* interface_exports */ + YYSYMBOL_interface_export = 66, /* interface_export */ + YYSYMBOL_operation = 67, /* operation */ + YYSYMBOL_operation_preamble = 68, /* operation_preamble */ + YYSYMBOL_return_type = 69, /* return_type */ + YYSYMBOL_parameters = 70, /* parameters */ + YYSYMBOL_routekey_qualifier = 71, /* routekey_qualifier */ + YYSYMBOL_out_qualifier = 72, /* out_qualifier */ + YYSYMBOL_struct_def = 73, /* struct_def */ + YYSYMBOL_74_7 = 74, /* @7 */ + YYSYMBOL_struct_id = 75, /* struct_id */ + YYSYMBOL_struct_exports = 76, /* struct_exports */ + YYSYMBOL_data_member = 77, /* data_member */ + YYSYMBOL_struct_type_id = 78, /* struct_type_id */ + YYSYMBOL_const_initializer = 79, /* const_initializer */ + YYSYMBOL_const_def = 80, /* const_def */ + YYSYMBOL_type_id = 81, /* type_id */ + YYSYMBOL_type = 82, /* type */ + YYSYMBOL_type_no = 83, /* type_no */ + YYSYMBOL_vector = 84, /* vector */ + YYSYMBOL_map = 85, /* map */ + YYSYMBOL_scoped_name = 86, /* scoped_name */ + YYSYMBOL_keyword = 87 /* keyword */ +}; +typedef enum yysymbol_kind_t yysymbol_kind_t; -/* Value type. */ -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef int YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define YYSTYPE_IS_DECLARED 1 -#endif -extern YYSTYPE yylval; -int yyparse (void); +#ifdef short +# undef short +#endif -#endif /* !YY_YY_TARS_TAB_HPP_INCLUDED */ +/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure + and (if available) are included + so that the code can choose integer types of a good width. */ -/* Copy the second part of user declarations. */ +#ifndef __PTRDIFF_MAX__ +# include /* INFRINGES ON USER NAME SPACE */ +# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_STDINT_H +# endif +#endif -#line 165 "tars.tab.cpp" /* yacc.c:358 */ +/* Narrow types that promote to a signed type and that can represent a + signed or unsigned integer of at least N bits. In tables they can + save space and decrease cache pressure. Promoting to a signed type + helps avoid bugs in integer arithmetic. */ -#ifdef short -# undef short +#ifdef __INT_LEAST8_MAX__ +typedef __INT_LEAST8_TYPE__ yytype_int8; +#elif defined YY_STDINT_H +typedef int_least8_t yytype_int8; +#else +typedef signed char yytype_int8; #endif -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; +#ifdef __INT_LEAST16_MAX__ +typedef __INT_LEAST16_TYPE__ yytype_int16; +#elif defined YY_STDINT_H +typedef int_least16_t yytype_int16; #else -typedef unsigned char yytype_uint8; +typedef short yytype_int16; #endif -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; -#else -typedef signed char yytype_int8; +/* Work around bug in HP-UX 11.23, which defines these macros + incorrectly for preprocessor constants. This workaround can likely + be removed in 2023, as HPE has promised support for HP-UX 11.23 + (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of + . */ +#ifdef __hpux +# undef UINT_LEAST8_MAX +# undef UINT_LEAST16_MAX +# define UINT_LEAST8_MAX 255 +# define UINT_LEAST16_MAX 65535 #endif -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; +#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST8_TYPE__ yytype_uint8; +#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST8_MAX <= INT_MAX) +typedef uint_least8_t yytype_uint8; +#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX +typedef unsigned char yytype_uint8; #else -typedef unsigned short int yytype_uint16; +typedef short yytype_uint8; #endif -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; +#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST16_TYPE__ yytype_uint16; +#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST16_MAX <= INT_MAX) +typedef uint_least16_t yytype_uint16; +#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX +typedef unsigned short yytype_uint16; #else -typedef short int yytype_int16; +typedef int yytype_uint16; +#endif + +#ifndef YYPTRDIFF_T +# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ +# define YYPTRDIFF_T __PTRDIFF_TYPE__ +# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ +# elif defined PTRDIFF_MAX +# ifndef ptrdiff_t +# include /* INFRINGES ON USER NAME SPACE */ +# endif +# define YYPTRDIFF_T ptrdiff_t +# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX +# else +# define YYPTRDIFF_T long +# define YYPTRDIFF_MAXIMUM LONG_MAX +# endif #endif #ifndef YYSIZE_T @@ -196,15 +295,28 @@ typedef short int yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T +# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) +#define YYSIZE_MAXIMUM \ + YY_CAST (YYPTRDIFF_T, \ + (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ + ? YYPTRDIFF_MAXIMUM \ + : YY_CAST (YYSIZE_T, -1))) + +#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) + + +/* Stored state numbers (used for stacks). */ +typedef yytype_uint8 yy_state_t; + +/* State numbers in computations. */ +typedef int yy_state_fast_t; #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS @@ -218,47 +330,37 @@ typedef short int yytype_int16; # endif #endif -#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) -# else -# define YY_ATTRIBUTE(Spec) /* empty */ -# endif -#endif #ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define YY_ATTRIBUTE_PURE +# endif #endif #ifndef YY_ATTRIBUTE_UNUSED -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) -#endif - -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) +# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) # else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# define YY_ATTRIBUTE_UNUSED # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YYUSE(E) ((void) (E)) +# define YY_USE(E) ((void) (E)) #else -# define YYUSE(E) /* empty */ +# define YY_USE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value @@ -271,8 +373,22 @@ typedef short int yytype_int16; # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif +#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ +# define YY_IGNORE_USELESS_CAST_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") +# define YY_IGNORE_USELESS_CAST_END \ + _Pragma ("GCC diagnostic pop") +#endif +#ifndef YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_END +#endif + -#if ! defined yyoverflow || YYERROR_VERBOSE +#define YY_ASSERT(E) ((void) (0 && (E))) + +#if !defined yyoverflow /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -337,8 +453,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - +#endif /* !defined yyoverflow */ #if (! defined yyoverflow \ && (! defined __cplusplus \ @@ -347,17 +462,17 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss_alloc; + yy_state_t yyss_alloc; YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) +# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 @@ -370,11 +485,11 @@ union yyalloc # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ - YYSIZE_T yynewbytes; \ + YYPTRDIFF_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ + yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / YYSIZEOF (*yyptr); \ } \ while (0) @@ -386,12 +501,12 @@ union yyalloc # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) + __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ - YYSIZE_T yyi; \ + YYPTRDIFF_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ @@ -414,17 +529,20 @@ union yyalloc /* YYNSTATES -- Number of states. */ #define YYNSTATES 199 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ -#define YYUNDEFTOK 2 +/* YYMAXUTOK -- Last valid token kind. */ #define YYMAXUTOK 288 -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ +#define YYTRANSLATE(YYX) \ + (0 <= (YYX) && (YYX) <= YYMAXUTOK \ + ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \ + : YYSYMBOL_YYUNDEF) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ -static const yytype_uint8 yytranslate[] = + as returned by yylex. */ +static const yytype_int8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -459,7 +577,7 @@ static const yytype_uint8 yytranslate[] = #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = +static const yytype_int16 yyrline[] = { 0, 68, 68, 75, 74, 79, 78, 83, 88, 95, 99, 103, 107, 110, 114, 124, 123, 146, 159, 170, @@ -478,35 +596,48 @@ static const yytype_uint16 yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE || 0 +/** Accessing symbol of state STATE. */ +#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) + +#if YYDEBUG || 0 +/* The user-facing name of the symbol whose (internal) number is + YYSYMBOL. No bounds checking. */ +static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; + /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$end", "error", "$undefined", "TARS_VOID", "TARS_STRUCT", "TARS_BOOL", - "TARS_BYTE", "TARS_SHORT", "TARS_INT", "TARS_DOUBLE", "TARS_FLOAT", - "TARS_LONG", "TARS_STRING", "TARS_VECTOR", "TARS_MAP", "TARS_NAMESPACE", - "TARS_INTERFACE", "TARS_IDENTIFIER", "TARS_OUT", "TARS_OP", "TARS_KEY", - "TARS_ROUTE_KEY", "TARS_REQUIRE", "TARS_OPTIONAL", "TARS_CONST_INTEGER", - "TARS_CONST_FLOAT", "TARS_FALSE", "TARS_TRUE", "TARS_STRING_LITERAL", - "TARS_SCOPE_DELIMITER", "TARS_CONST", "TARS_ENUM", "TARS_UNSIGNED", - "BAD_CHAR", "';'", "'{'", "'}'", "','", "'='", "'['", "']'", "')'", - "'*'", "':'", "'<'", "'>'", "$accept", "start", "definitions", "$@1", - "$@2", "definition", "enum_def", "@3", "enum_id", "enumerator_list", - "enumerator", "namespace_def", "@4", "key_def", "$@5", "key_members", - "interface_def", "@6", "interface_id", "interface_exports", - "interface_export", "operation", "operation_preamble", "return_type", - "parameters", "routekey_qualifier", "out_qualifier", "struct_def", "@7", - "struct_id", "struct_exports", "data_member", "struct_type_id", - "const_initializer", "const_def", "type_id", "type", "type_no", "vector", - "map", "scoped_name", "keyword", YY_NULLPTR + "\"end of file\"", "error", "\"invalid token\"", "TARS_VOID", + "TARS_STRUCT", "TARS_BOOL", "TARS_BYTE", "TARS_SHORT", "TARS_INT", + "TARS_DOUBLE", "TARS_FLOAT", "TARS_LONG", "TARS_STRING", "TARS_VECTOR", + "TARS_MAP", "TARS_NAMESPACE", "TARS_INTERFACE", "TARS_IDENTIFIER", + "TARS_OUT", "TARS_OP", "TARS_KEY", "TARS_ROUTE_KEY", "TARS_REQUIRE", + "TARS_OPTIONAL", "TARS_CONST_INTEGER", "TARS_CONST_FLOAT", "TARS_FALSE", + "TARS_TRUE", "TARS_STRING_LITERAL", "TARS_SCOPE_DELIMITER", "TARS_CONST", + "TARS_ENUM", "TARS_UNSIGNED", "BAD_CHAR", "';'", "'{'", "'}'", "','", + "'='", "'['", "']'", "')'", "'*'", "':'", "'<'", "'>'", "$accept", + "start", "definitions", "$@1", "$@2", "definition", "enum_def", "@3", + "enum_id", "enumerator_list", "enumerator", "namespace_def", "@4", + "key_def", "$@5", "key_members", "interface_def", "@6", "interface_id", + "interface_exports", "interface_export", "operation", + "operation_preamble", "return_type", "parameters", "routekey_qualifier", + "out_qualifier", "struct_def", "@7", "struct_id", "struct_exports", + "data_member", "struct_type_id", "const_initializer", "const_def", + "type_id", "type", "type_no", "vector", "map", "scoped_name", "keyword", YY_NULLPTR }; + +static const char * +yysymbol_name (yysymbol_kind_t yysymbol) +{ + return yytname[yysymbol]; +} #endif -# ifdef YYPRINT +#ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ -static const yytype_uint16 yytoknum[] = +static const yytype_int16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, @@ -514,16 +645,16 @@ static const yytype_uint16 yytoknum[] = 285, 286, 287, 288, 59, 123, 125, 44, 61, 91, 93, 41, 42, 58, 60, 62 }; -# endif +#endif -#define YYPACT_NINF -146 +#define YYPACT_NINF (-146) -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-146))) +#define yypact_value_is_default(Yyn) \ + ((Yyn) == YYPACT_NINF) -#define YYTABLE_NINF -113 +#define YYTABLE_NINF (-113) -#define yytable_value_is_error(Yytable_value) \ +#define yytable_value_is_error(Yyn) \ 0 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing @@ -590,9 +721,9 @@ static const yytype_int16 yypgoto[] = }; /* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int16 yydefgoto[] = +static const yytype_uint8 yydefgoto[] = { - -1, 8, 9, 76, 80, 10, 11, 77, 12, 123, + 0, 8, 9, 76, 80, 10, 11, 77, 12, 123, 124, 13, 81, 14, 142, 171, 15, 78, 16, 128, 129, 130, 131, 132, 157, 158, 159, 17, 79, 18, 137, 138, 139, 113, 19, 140, 68, 69, 70, 71, @@ -726,7 +857,7 @@ static const yytype_int16 yycheck[] = /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = +static const yytype_int8 yystos[] = { 0, 1, 4, 15, 16, 20, 30, 31, 47, 48, 51, 52, 54, 57, 59, 62, 64, 73, 75, 80, @@ -751,7 +882,7 @@ static const yytype_uint8 yystos[] = }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = +static const yytype_int8 yyr1[] = { 0, 46, 47, 49, 48, 50, 48, 48, 48, 51, 51, 51, 51, 51, 51, 53, 52, 54, 54, 55, @@ -770,7 +901,7 @@ static const yytype_uint8 yyr1[] = }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = +static const yytype_int8 yyr2[] = { 0, 2, 1, 0, 4, 0, 4, 1, 0, 1, 1, 1, 1, 1, 1, 0, 5, 2, 2, 3, @@ -789,10 +920,10 @@ static const yytype_uint8 yyr2[] = }; +enum { YYENOMEM = -2 }; + #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab @@ -801,27 +932,26 @@ static const yytype_uint8 yyr2[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) - -/* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 - +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) + +/* Backward compatibility with an undocumented macro. + Use YYerror or YYUNDEF. */ +#define YYERRCODE YYUNDEF /* Enable debugging if requested. */ @@ -839,54 +969,58 @@ do { \ } while (0) /* This macro is provided for backward compatibility. */ -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif +# ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Type, Value); \ + Kind, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/ static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_value_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) { - FILE *yyo = yyoutput; - YYUSE (yyo); + FILE *yyoutput = yyo; + YY_USE (yyoutput); if (!yyvaluep) return; # ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); + if (yykind < YYNTOKENS) + YYPRINT (yyo, yytoknum[yykind], *yyvaluep); # endif - YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YY_USE (yykind); + YY_IGNORE_MAYBE_UNINITIALIZED_END } -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/ static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) { - YYFPRINTF (yyoutput, "%s %s (", - yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + YYFPRINTF (yyo, "%s %s (", + yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); + yy_symbol_value_print (yyo, yykind, yyvaluep); + YYFPRINTF (yyo, ")"); } /*------------------------------------------------------------------. @@ -895,7 +1029,7 @@ yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) `------------------------------------------------------------------*/ static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -918,21 +1052,21 @@ do { \ `------------------------------------------------*/ static void -yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, + int yyrule) { - unsigned long int yylno = yyrline[yyrule]; + int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, - yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); + YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), + &yyvsp[(yyi + 1) - (yynrhs)]); YYFPRINTF (stderr, "\n"); } } @@ -947,8 +1081,8 @@ do { \ multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YYDPRINTF(Args) ((void) 0) +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ @@ -971,249 +1105,30 @@ int yydebug; #endif -#if YYERROR_VERBOSE -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -yystrlen (const char *yystr) -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -yystpcpy (char *yydest, const char *yysrc) -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. - - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) -{ - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); - YYSIZE_T yysize = yysize0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat. */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ - int yycount = 0; - - /* There are many possibilities here to consider: - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yytoken != YYEMPTY) - { - int yyn = yypact[*yyssp]; - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - } - } - } - - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ - } - - { - YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; - } - - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyformat += 2; - } - else - { - yyp++; - yyformat++; - } - } - return 0; -} -#endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +yydestruct (const char *yymsg, + yysymbol_kind_t yykind, YYSTYPE *yyvaluep) { - YYUSE (yyvaluep); + YY_USE (yyvaluep); if (!yymsg) yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YYUSE (yytype); + YY_USE (yykind); YY_IGNORE_MAYBE_UNINITIALIZED_END } - - -/* The lookahead symbol. */ +/* Lookahead token kind. */ int yychar; /* The semantic value of the lookahead symbol. */ @@ -1222,6 +1137,8 @@ YYSTYPE yylval; int yynerrs; + + /*----------. | yyparse. | `----------*/ @@ -1229,43 +1146,36 @@ int yynerrs; int yyparse (void) { - int yystate; + yy_state_fast_t yystate = 0; /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; + int yyerrstatus = 0; - /* The stacks and their tools: - 'yyss': related to states. - 'yyvs': related to semantic values. - - Refer to the stacks through separate pointers, to allow yyoverflow + /* Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; + /* Their size. */ + YYPTRDIFF_T yystacksize = YYINITDEPTH; - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; + /* The state stack: array, bottom, top. */ + yy_state_t yyssa[YYINITDEPTH]; + yy_state_t *yyss = yyssa; + yy_state_t *yyssp = yyss; - YYSIZE_T yystacksize; + /* The semantic value stack: array, bottom, top. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp = yyvs; int yyn; + /* The return value of yyparse. */ int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; + /* Lookahead symbol kind. */ + yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif + #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) @@ -1273,58 +1183,60 @@ yyparse (void) Keep to zero when no symbol should be popped. */ int yylen = 0; - yyssp = yyss = yyssa; - yyvsp = yyvs = yyvsa; - yystacksize = YYINITDEPTH; - YYDPRINTF ((stderr, "Starting parse\n")); - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; + /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - yysetstate: - *yyssp = yystate; + +/*--------------------------------------------------------------------. +| yysetstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YY_ASSERT (0 <= yystate && yystate < YYNSTATES); + YY_IGNORE_USELESS_CAST_BEGIN + *yyssp = YY_CAST (yy_state_t, yystate); + YY_IGNORE_USELESS_CAST_END + YY_STACK_PRINT (yyss, yyssp); if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + goto yyexhaustedlab; +#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + YYPTRDIFF_T yysize = yyssp - yyss + 1; -#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ + yy_state_t *yyss1 = yyss; YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), + &yyss1, yysize * YYSIZEOF (*yyssp), + &yyvs1, yysize * YYSIZEOF (*yyvsp), &yystacksize); - yyss = yyss1; yyvs = yyvs1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1333,9 +1245,10 @@ yyparse (void) yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; + yy_state_t *yyss1 = yyss; union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + YY_CAST (union yyalloc *, + YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); @@ -1345,30 +1258,30 @@ yyparse (void) YYSTACK_FREE (yyss1); } # endif -#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + YY_IGNORE_USELESS_CAST_BEGIN + YYDPRINTF ((stderr, "Stack size increased to %ld\n", + YY_CAST (long, yystacksize))); + YY_IGNORE_USELESS_CAST_END if (yyss + yystacksize - 1 <= yyssp) YYABORT; } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ if (yystate == YYFINAL) YYACCEPT; goto yybackup; + /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1379,18 +1292,29 @@ yyparse (void) /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ if (yychar == YYEMPTY) { - YYDPRINTF ((stderr, "Reading a token: ")); + YYDPRINTF ((stderr, "Reading a token\n")); yychar = yylex (); } if (yychar <= YYEOF) { - yychar = yytoken = YYEOF; + yychar = YYEOF; + yytoken = YYSYMBOL_YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } + else if (yychar == YYerror) + { + /* The scanner already issued an error message, process directly + to error recovery. But do not keep the error token as + lookahead, it is too special and may lead us to an endless + loop in error recovery. */ + yychar = YYUNDEF; + yytoken = YYSYMBOL_YYerror; + goto yyerrlab1; + } else { yytoken = YYTRANSLATE (yychar); @@ -1418,15 +1342,13 @@ yyparse (void) /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END + /* Discard the shifted token. */ + yychar = YYEMPTY; goto yynewstate; @@ -1441,7 +1363,7 @@ yyparse (void) /*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1461,238 +1383,238 @@ yyparse (void) YY_REDUCE_PRINT (yyn); switch (yyn) { - case 3: -#line 75 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 3: /* $@1: %empty */ +#line 75 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1469 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1391 "tars.tab.cpp" break; - case 5: -#line 79 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 5: /* $@2: %empty */ +#line 79 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ yyerrok; } -#line 1477 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1399 "tars.tab.cpp" break; - case 7: -#line 84 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 7: /* definitions: definition */ +#line 84 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("`;' missing after definition"); } -#line 1485 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1407 "tars.tab.cpp" break; - case 8: -#line 88 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 8: /* definitions: %empty */ +#line 88 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1492 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1414 "tars.tab.cpp" break; - case 9: -#line 96 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - assert((yyvsp[0]) == 0 || NamespacePtr::dynamicCast((yyvsp[0]))); + case 9: /* definition: namespace_def */ +#line 96 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + assert(yyvsp[0] == 0 || NamespacePtr::dynamicCast(yyvsp[0])); } -#line 1500 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1422 "tars.tab.cpp" break; - case 10: -#line 100 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - assert((yyvsp[0]) == 0 || InterfacePtr::dynamicCast((yyvsp[0]))); + case 10: /* definition: interface_def */ +#line 100 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + assert(yyvsp[0] == 0 || InterfacePtr::dynamicCast(yyvsp[0])); } -#line 1508 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1430 "tars.tab.cpp" break; - case 11: -#line 104 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - assert((yyvsp[0]) == 0 || StructPtr::dynamicCast((yyvsp[0]))); + case 11: /* definition: struct_def */ +#line 104 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + assert(yyvsp[0] == 0 || StructPtr::dynamicCast(yyvsp[0])); } -#line 1516 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1438 "tars.tab.cpp" break; - case 12: -#line 108 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 12: /* definition: key_def */ +#line 108 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1523 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1445 "tars.tab.cpp" break; - case 13: -#line 111 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - assert((yyvsp[0]) == 0 || EnumPtr::dynamicCast((yyvsp[0]))); + case 13: /* definition: enum_def */ +#line 111 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + assert(yyvsp[0] == 0 || EnumPtr::dynamicCast(yyvsp[0])); } -#line 1531 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1453 "tars.tab.cpp" break; - case 14: -#line 115 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - assert((yyvsp[0]) == 0 || ConstPtr::dynamicCast((yyvsp[0]))); + case 14: /* definition: const_def */ +#line 115 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + assert(yyvsp[0] == 0 || ConstPtr::dynamicCast(yyvsp[0])); } -#line 1539 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1461 "tars.tab.cpp" break; - case 15: -#line 124 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = (yyvsp[0]); + case 15: /* @3: %empty */ +#line 124 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = yyvsp[0]; } -#line 1547 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1469 "tars.tab.cpp" break; - case 16: -#line 128 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - if((yyvsp[-2])) + case 16: /* enum_def: enum_id @3 '{' enumerator_list '}' */ +#line 128 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + if(yyvsp[-2]) { g_parse->popContainer(); - (yyval) = (yyvsp[-2]); + yyval = yyvsp[-2]; } else { - (yyval) = 0; + yyval = 0; } - (yyval) = (yyvsp[-3]); + yyval = yyvsp[-3]; } -#line 1565 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1487 "tars.tab.cpp" break; - case 17: -#line 147 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 17: /* enum_id: TARS_ENUM TARS_IDENTIFIER */ +#line 147 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ NamespacePtr c = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!c) { g_parse->error("enum must define in namespace"); } - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); EnumPtr e = c->createEnum(ident->v); g_parse->pushContainer(e); - (yyval) = e; + yyval = e; } -#line 1582 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1504 "tars.tab.cpp" break; - case 18: -#line 160 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 18: /* enum_id: TARS_ENUM keyword */ +#line 160 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumeration name"); - (yyval) = (yyvsp[0]); + yyval = yyvsp[0]; } -#line 1592 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1514 "tars.tab.cpp" break; - case 19: -#line 171 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = (yyvsp[-1]); + case 19: /* enumerator_list: enumerator ',' enumerator_list */ +#line 171 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = yyvsp[-1]; } -#line 1600 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1522 "tars.tab.cpp" break; - case 20: -#line 175 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 20: /* enumerator_list: enumerator */ +#line 175 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1607 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1529 "tars.tab.cpp" break; - case 21: -#line 183 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 21: /* enumerator: TARS_IDENTIFIER */ +#line 183 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypeIdPtr tPtr = new TypeId(type, ident->v); tPtr->disableDefault(); EnumPtr e = EnumPtr::dynamicCast(g_parse->currentContainer()); assert(e); e->addMember(tPtr); - (yyval) = e; + yyval = e; } -#line 1622 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1544 "tars.tab.cpp" break; - case 22: -#line 194 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 22: /* enumerator: keyword */ +#line 194 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumerator"); } -#line 1631 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1553 "tars.tab.cpp" break; - case 23: -#line 199 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 23: /* enumerator: TARS_IDENTIFIER '=' const_initializer */ +#line 199 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[-2])); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); TypeIdPtr tPtr = new TypeId(type, ident->v); - ConstGrammarPtr sPtr = ConstGrammarPtr::dynamicCast((yyvsp[0])); + ConstGrammarPtr sPtr = ConstGrammarPtr::dynamicCast(yyvsp[0]); g_parse->checkConstValue(tPtr, sPtr->t); tPtr->setDefault(sPtr->v); EnumPtr e = EnumPtr::dynamicCast(g_parse->currentContainer()); assert(e); e->addMember(tPtr); - (yyval) = e; + yyval = e; } -#line 1648 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1570 "tars.tab.cpp" break; - case 24: -#line 212 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 24: /* enumerator: %empty */ +#line 212 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1655 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1577 "tars.tab.cpp" break; - case 25: -#line 220 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 25: /* @4: %empty */ +#line 220 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ContainerPtr c = g_parse->currentContainer(); NamespacePtr n = c->createNamespace(ident->v); if(n) { g_parse->pushContainer(n); - (yyval) = GrammarBasePtr::dynamicCast(n); + yyval = GrammarBasePtr::dynamicCast(n); } else { - (yyval) = 0; + yyval = 0; } } -#line 1674 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1596 "tars.tab.cpp" break; - case 26: -#line 235 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - if((yyvsp[-3])) + case 26: /* namespace_def: TARS_NAMESPACE TARS_IDENTIFIER @4 '{' definitions '}' */ +#line 235 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + if(yyvsp[-3]) { g_parse->popContainer(); - (yyval) = (yyvsp[-3]); + yyval = yyvsp[-3]; } else { - (yyval) = 0; + yyval = 0; } } -#line 1690 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1612 "tars.tab.cpp" break; - case 27: -#line 253 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[-1])); + case 27: /* $@5: %empty */ +#line 253 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-1]); StructPtr sp = StructPtr::dynamicCast(g_parse->findUserType(ident->v)); if(!sp) { @@ -1701,20 +1623,20 @@ yyparse (void) g_parse->setKeyStruct(sp); } -#line 1705 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1627 "tars.tab.cpp" break; - case 28: -#line 264 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 28: /* key_def: TARS_KEY '[' scoped_name ',' $@5 key_members ']' */ +#line 264 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1712 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1634 "tars.tab.cpp" break; - case 29: -#line 272 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 29: /* key_members: TARS_IDENTIFIER */ +#line 272 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); if(np) { @@ -1722,16 +1644,16 @@ yyparse (void) } else { - (yyval) = 0; + yyval = 0; } } -#line 1729 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1651 "tars.tab.cpp" break; - case 30: -#line 285 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 30: /* key_members: key_members ',' TARS_IDENTIFIER */ +#line 285 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); if(np) { @@ -1739,16 +1661,16 @@ yyparse (void) } else { - (yyval) = 0; + yyval = 0; } } -#line 1746 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1668 "tars.tab.cpp" break; - case 31: -#line 304 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 31: /* @6: %empty */ +#line 304 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); NamespacePtr c = NamespacePtr::dynamicCast(g_parse->currentContainer()); @@ -1756,100 +1678,100 @@ yyparse (void) if(cl) { g_parse->pushContainer(cl); - (yyval) = GrammarBasePtr::dynamicCast(cl); + yyval = GrammarBasePtr::dynamicCast(cl); } else { - (yyval) = 0; + yyval = 0; } } -#line 1767 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1689 "tars.tab.cpp" break; - case 32: -#line 321 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - if((yyvsp[-3])) + case 32: /* interface_def: interface_id @6 '{' interface_exports '}' */ +#line 321 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + if(yyvsp[-3]) { g_parse->popContainer(); - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[-3])); + yyval = GrammarBasePtr::dynamicCast(yyvsp[-3]); } else { - (yyval) = 0; + yyval = 0; } } -#line 1783 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1705 "tars.tab.cpp" break; - case 33: -#line 338 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = (yyvsp[0]); + case 33: /* interface_id: TARS_INTERFACE TARS_IDENTIFIER */ +#line 338 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = yyvsp[0]; } -#line 1791 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1713 "tars.tab.cpp" break; - case 34: -#line 342 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 34: /* interface_id: TARS_INTERFACE keyword */ +#line 342 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as interface name"); - (yyval) = (yyvsp[0]); + yyval = yyvsp[0]; } -#line 1801 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1723 "tars.tab.cpp" break; - case 35: -#line 353 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 35: /* interface_exports: interface_export ';' interface_exports */ +#line 353 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1808 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1730 "tars.tab.cpp" break; - case 36: -#line 356 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 36: /* interface_exports: error ';' interface_exports */ +#line 356 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1815 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1737 "tars.tab.cpp" break; - case 37: -#line 359 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 37: /* interface_exports: interface_export */ +#line 359 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("`;' missing after definition"); } -#line 1823 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1745 "tars.tab.cpp" break; - case 38: -#line 363 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 38: /* interface_exports: %empty */ +#line 363 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1830 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1752 "tars.tab.cpp" break; - case 40: -#line 377 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - if((yyvsp[-2])) + case 40: /* operation: operation_preamble parameters ')' */ +#line 377 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + if(yyvsp[-2]) { g_parse->popContainer(); - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[-2])); + yyval = GrammarBasePtr::dynamicCast(yyvsp[-2]); } else { - (yyval) = 0; + yyval = 0; } } -#line 1846 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1768 "tars.tab.cpp" break; - case 41: -#line 394 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - TypePtr returnType = TypePtr::dynamicCast((yyvsp[-1])); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 41: /* operation_preamble: return_type TARS_OP */ +#line 394 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); string name = ident->v; InterfacePtr cl = InterfacePtr::dynamicCast(g_parse->currentContainer()); if(cl) @@ -1858,40 +1780,40 @@ yyparse (void) if(op) { g_parse->pushContainer(op); - (yyval) = GrammarBasePtr::dynamicCast(op); + yyval = GrammarBasePtr::dynamicCast(op); } else { - (yyval) = 0; + yyval = 0; } } else { - (yyval) = 0; + yyval = 0; } } -#line 1874 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1796 "tars.tab.cpp" break; - case 43: -#line 424 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = 0; + case 43: /* return_type: TARS_VOID */ +#line 424 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = 0; } -#line 1882 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1804 "tars.tab.cpp" break; - case 44: -#line 434 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 44: /* parameters: %empty */ +#line 434 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1889 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1811 "tars.tab.cpp" break; - case 45: -#line 437 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - TypeIdPtr tsp = TypeIdPtr::dynamicCast((yyvsp[0])); + case 45: /* parameters: type_id */ +#line 437 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); OperationPtr op = OperationPtr::dynamicCast(g_parse->currentContainer()); assert(op); @@ -1900,13 +1822,13 @@ yyparse (void) op->createParamDecl(tsp, false, false); } } -#line 1904 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1826 "tars.tab.cpp" break; - case 46: -#line 448 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - TypeIdPtr tsp = TypeIdPtr::dynamicCast((yyvsp[0])); + case 46: /* parameters: parameters ',' type_id */ +#line 448 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); OperationPtr op = OperationPtr::dynamicCast(g_parse->currentContainer()); assert(op); @@ -1915,14 +1837,14 @@ yyparse (void) op->createParamDecl(tsp, false, false); } } -#line 1919 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1841 "tars.tab.cpp" break; - case 47: -#line 459 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast((yyvsp[-1])); - TypeIdPtr tsp = TypeIdPtr::dynamicCast((yyvsp[0])); + case 47: /* parameters: out_qualifier type_id */ +#line 459 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); + TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); OperationPtr op = OperationPtr::dynamicCast(g_parse->currentContainer()); assert(op); @@ -1931,14 +1853,14 @@ yyparse (void) op->createParamDecl(tsp, isOutParam->v, false); } } -#line 1935 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1857 "tars.tab.cpp" break; - case 48: -#line 471 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast((yyvsp[-1])); - TypeIdPtr tsp = TypeIdPtr::dynamicCast((yyvsp[0])); + case 48: /* parameters: parameters ',' out_qualifier type_id */ +#line 471 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); + TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); OperationPtr op = OperationPtr::dynamicCast(g_parse->currentContainer()); assert(op); @@ -1947,14 +1869,14 @@ yyparse (void) op->createParamDecl(tsp, isOutParam->v, false); } } -#line 1951 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1873 "tars.tab.cpp" break; - case 49: -#line 483 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast((yyvsp[-1])); - TypeIdPtr tsp = TypeIdPtr::dynamicCast((yyvsp[0])); + case 49: /* parameters: routekey_qualifier type_id */ +#line 483 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); + TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); OperationPtr op = OperationPtr::dynamicCast(g_parse->currentContainer()); assert(op); @@ -1963,14 +1885,14 @@ yyparse (void) op->createParamDecl(tsp, false, isRouteKeyParam->v); } } -#line 1967 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1889 "tars.tab.cpp" break; - case 50: -#line 495 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast((yyvsp[-1])); - TypeIdPtr tsp = TypeIdPtr::dynamicCast((yyvsp[0])); + case 50: /* parameters: parameters ',' routekey_qualifier type_id */ +#line 495 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); + TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); OperationPtr op = OperationPtr::dynamicCast(g_parse->currentContainer()); assert(op); @@ -1979,49 +1901,49 @@ yyparse (void) op->createParamDecl(tsp, false, isRouteKeyParam->v); } } -#line 1983 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1905 "tars.tab.cpp" break; - case 51: -#line 507 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 51: /* parameters: out_qualifier */ +#line 507 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("'out' must be defined with a type"); } -#line 1991 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1913 "tars.tab.cpp" break; - case 52: -#line 511 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 52: /* parameters: routekey_qualifier */ +#line 511 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("'routekey' must be defined with a type"); } -#line 1999 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1921 "tars.tab.cpp" break; - case 53: -#line 520 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 53: /* routekey_qualifier: TARS_ROUTE_KEY */ +#line 520 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ BoolGrammarPtr routekey = new BoolGrammar; routekey->v = true; - (yyval) = GrammarBasePtr::dynamicCast(routekey); + yyval = GrammarBasePtr::dynamicCast(routekey); } -#line 2009 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1931 "tars.tab.cpp" break; - case 54: -#line 531 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 54: /* out_qualifier: TARS_OUT */ +#line 531 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ BoolGrammarPtr out = new BoolGrammar; out->v = true; - (yyval) = GrammarBasePtr::dynamicCast(out); + yyval = GrammarBasePtr::dynamicCast(out); } -#line 2019 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1941 "tars.tab.cpp" break; - case 55: -#line 542 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 55: /* @7: %empty */ +#line 542 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(np) { @@ -2029,11 +1951,11 @@ yyparse (void) if(sp) { g_parse->pushContainer(sp); - (yyval) = GrammarBasePtr::dynamicCast(sp); + yyval = GrammarBasePtr::dynamicCast(sp); } else { - (yyval) = 0; + yyval = 0; } } else @@ -2041,280 +1963,280 @@ yyparse (void) g_parse->error("struct '" + ident->v + "' must definition in namespace"); } } -#line 2045 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1967 "tars.tab.cpp" break; - case 56: -#line 564 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - if((yyvsp[-3])) + case 56: /* struct_def: struct_id @7 '{' struct_exports '}' */ +#line 564 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + if(yyvsp[-3]) { g_parse->popContainer(); } - (yyval) = (yyvsp[-3]); + yyval = yyvsp[-3]; - StructPtr st = StructPtr::dynamicCast((yyval)); + StructPtr st = StructPtr::dynamicCast(yyval); assert(st); if(st->getAllMemberPtr().size() == 0) { g_parse->error("struct `" + st->getSid() + "' must have at least one member"); } } -#line 2064 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1986 "tars.tab.cpp" break; - case 57: -#line 584 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = (yyvsp[0]); + case 57: /* struct_id: TARS_STRUCT TARS_IDENTIFIER */ +#line 584 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = yyvsp[0]; } -#line 2072 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1994 "tars.tab.cpp" break; - case 58: -#line 588 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 58: /* struct_id: TARS_STRUCT keyword */ +#line 588 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as struct name"); } -#line 2082 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2004 "tars.tab.cpp" break; - case 59: -#line 594 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 59: /* struct_id: TARS_STRUCT error */ +#line 594 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("abstract declarator '' used as declaration"); } -#line 2090 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2012 "tars.tab.cpp" break; - case 60: -#line 603 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 60: /* struct_exports: data_member ';' struct_exports */ +#line 603 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2098 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2020 "tars.tab.cpp" break; - case 61: -#line 607 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 61: /* struct_exports: data_member */ +#line 607 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("';' missing after definition"); } -#line 2106 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2028 "tars.tab.cpp" break; - case 62: -#line 611 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 62: /* struct_exports: %empty */ +#line 611 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2113 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2035 "tars.tab.cpp" break; - case 63: -#line 621 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[0])); + case 63: /* data_member: struct_type_id */ +#line 621 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } -#line 2121 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2043 "tars.tab.cpp" break; - case 64: -#line 630 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 64: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id */ +#line 630 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) { - IntergerGrammarPtr iPtr = IntergerGrammarPtr::dynamicCast((yyvsp[-2])); + IntergerGrammarPtr iPtr = IntergerGrammarPtr::dynamicCast(yyvsp[-2]); g_parse->checkTag(iPtr->v); - TypeIdPtr tPtr = TypeIdPtr::dynamicCast((yyvsp[0])); + TypeIdPtr tPtr = TypeIdPtr::dynamicCast(yyvsp[0]); tPtr->setRequire(iPtr->v); np->addTypeId(tPtr); - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[0])); + yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } else { - (yyval) = 0; + yyval = 0; } } -#line 2143 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2065 "tars.tab.cpp" break; - case 65: -#line 648 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 65: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id '=' const_initializer */ +#line 648 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) { - IntergerGrammarPtr iPtr = IntergerGrammarPtr::dynamicCast((yyvsp[-4])); + IntergerGrammarPtr iPtr = IntergerGrammarPtr::dynamicCast(yyvsp[-4]); g_parse->checkTag(iPtr->v); - TypeIdPtr tPtr = TypeIdPtr::dynamicCast((yyvsp[-2])); - ConstGrammarPtr sPtr = ConstGrammarPtr::dynamicCast((yyvsp[0])); + TypeIdPtr tPtr = TypeIdPtr::dynamicCast(yyvsp[-2]); + ConstGrammarPtr sPtr = ConstGrammarPtr::dynamicCast(yyvsp[0]); g_parse->checkConstValue(tPtr, sPtr->t); tPtr->setRequire(iPtr->v); tPtr->setDefault(sPtr->v); np->addTypeId(tPtr); - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[-2])); + yyval = GrammarBasePtr::dynamicCast(yyvsp[-2]); } else { - (yyval) = 0; + yyval = 0; } } -#line 2169 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2091 "tars.tab.cpp" break; - case 66: -#line 670 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 66: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id '=' const_initializer */ +#line 670 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) { - IntergerGrammarPtr iPtr = IntergerGrammarPtr::dynamicCast((yyvsp[-4])); + IntergerGrammarPtr iPtr = IntergerGrammarPtr::dynamicCast(yyvsp[-4]); g_parse->checkTag(iPtr->v); - TypeIdPtr tPtr = TypeIdPtr::dynamicCast((yyvsp[-2])); - ConstGrammarPtr sPtr = ConstGrammarPtr::dynamicCast((yyvsp[0])); + TypeIdPtr tPtr = TypeIdPtr::dynamicCast(yyvsp[-2]); + ConstGrammarPtr sPtr = ConstGrammarPtr::dynamicCast(yyvsp[0]); g_parse->checkConstValue(tPtr, sPtr->t); tPtr->setOptional(iPtr->v); tPtr->setDefault(sPtr->v); np->addTypeId(tPtr); - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[-2])); + yyval = GrammarBasePtr::dynamicCast(yyvsp[-2]); } else { - (yyval) = 0; + yyval = 0; } } -#line 2195 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2117 "tars.tab.cpp" break; - case 67: -#line 692 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 67: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id */ +#line 692 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) { - IntergerGrammarPtr iPtr = IntergerGrammarPtr::dynamicCast((yyvsp[-2])); + IntergerGrammarPtr iPtr = IntergerGrammarPtr::dynamicCast(yyvsp[-2]); g_parse->checkTag(iPtr->v); - TypeIdPtr tPtr = TypeIdPtr::dynamicCast((yyvsp[0])); + TypeIdPtr tPtr = TypeIdPtr::dynamicCast(yyvsp[0]); tPtr->setOptional(iPtr->v); np->addTypeId(tPtr); - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[0])); + yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } else { - (yyval) = 0; + yyval = 0; } } -#line 2216 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2138 "tars.tab.cpp" break; - case 68: -#line 709 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 68: /* struct_type_id: TARS_REQUIRE type_id */ +#line 709 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("struct member need 'tag'"); } -#line 2224 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2146 "tars.tab.cpp" break; - case 69: -#line 713 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 69: /* struct_type_id: TARS_OPTIONAL type_id */ +#line 713 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("struct member need 'tag'"); } -#line 2232 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2154 "tars.tab.cpp" break; - case 70: -#line 717 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 70: /* struct_type_id: TARS_CONST_INTEGER type_id */ +#line 717 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("struct member need 'require' or 'optional'"); } -#line 2240 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2162 "tars.tab.cpp" break; - case 71: -#line 721 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 71: /* struct_type_id: type_id */ +#line 721 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("struct member need 'tag' or 'require' or 'optional'"); } -#line 2248 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2170 "tars.tab.cpp" break; - case 72: -#line 730 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - IntergerGrammarPtr intVal = IntergerGrammarPtr::dynamicCast((yyvsp[0])); + case 72: /* const_initializer: TARS_CONST_INTEGER */ +#line 730 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + IntergerGrammarPtr intVal = IntergerGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; sstr << intVal->v; ConstGrammarPtr c = new ConstGrammar(); c->t = ConstGrammar::VALUE; c->v = sstr.str(); - (yyval) = c; + yyval = c; } -#line 2262 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2184 "tars.tab.cpp" break; - case 73: -#line 740 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - FloatGrammarPtr floatVal = FloatGrammarPtr::dynamicCast((yyvsp[0])); + case 73: /* const_initializer: TARS_CONST_FLOAT */ +#line 740 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + FloatGrammarPtr floatVal = FloatGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; sstr << floatVal->v; ConstGrammarPtr c = new ConstGrammar(); c->t = ConstGrammar::VALUE; c->v = sstr.str(); - (yyval) = c; + yyval = c; } -#line 2276 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2198 "tars.tab.cpp" break; - case 74: -#line 750 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 74: /* const_initializer: TARS_STRING_LITERAL */ +#line 750 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); c->t = ConstGrammar::STRING; c->v = ident->v; - (yyval) = c; + yyval = c; } -#line 2288 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2210 "tars.tab.cpp" break; - case 75: -#line 758 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 75: /* const_initializer: TARS_FALSE */ +#line 758 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); c->t = ConstGrammar::BOOL; c->v = ident->v; - (yyval) = c; + yyval = c; } -#line 2300 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2222 "tars.tab.cpp" break; - case 76: -#line 766 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 76: /* const_initializer: TARS_TRUE */ +#line 766 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); c->t = ConstGrammar::BOOL; c->v = ident->v; - (yyval) = c; + yyval = c; } -#line 2312 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2234 "tars.tab.cpp" break; - case 77: -#line 774 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 77: /* const_initializer: TARS_IDENTIFIER */ +#line 774 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); if (g_parse->checkEnum(ident->v) == false) { @@ -2323,17 +2245,17 @@ yyparse (void) ConstGrammarPtr c = new ConstGrammar(); c->t = ConstGrammar::ENUM; c->v = ident->v; - (yyval) = c; + yyval = c; } -#line 2329 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2251 "tars.tab.cpp" break; - case 78: -#line 787 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 78: /* const_initializer: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ +#line 787 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ - StringGrammarPtr scoped = StringGrammarPtr::dynamicCast((yyvsp[-2])); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); if (g_parse->checkEnum(ident->v) == false) { @@ -2342,511 +2264,512 @@ yyparse (void) ConstGrammarPtr c = new ConstGrammar(); c->t = ConstGrammar::ENUM; c->v = scoped->v + "::" + ident->v; - (yyval) = c; + yyval = c; } -#line 2348 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2270 "tars.tab.cpp" break; - case 79: -#line 807 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 79: /* const_def: TARS_CONST type_id '=' const_initializer */ +#line 807 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!np) { g_parse->error("const type must define in namespace"); } - TypeIdPtr t = TypeIdPtr::dynamicCast((yyvsp[-2])); - ConstGrammarPtr c = ConstGrammarPtr::dynamicCast((yyvsp[0])); + TypeIdPtr t = TypeIdPtr::dynamicCast(yyvsp[-2]); + ConstGrammarPtr c = ConstGrammarPtr::dynamicCast(yyvsp[0]); ConstPtr cPtr = np->createConst(t, c); - (yyval) = cPtr; + yyval = cPtr; } -#line 2365 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2287 "tars.tab.cpp" break; - case 80: -#line 825 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - TypePtr type = TypePtr::dynamicCast((yyvsp[-1])); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 80: /* type_id: type TARS_IDENTIFIER */ +#line 825 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypeIdPtr typeIdPtr = new TypeId(type, ident->v); - (yyval) = GrammarBasePtr::dynamicCast(typeIdPtr); + yyval = GrammarBasePtr::dynamicCast(typeIdPtr); } -#line 2378 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2300 "tars.tab.cpp" break; - case 81: -#line 834 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - TypePtr type = g_parse->createVector(TypePtr::dynamicCast((yyvsp[-4]))); - IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast((yyvsp[-1])); + case 81: /* type_id: type TARS_IDENTIFIER '[' TARS_CONST_INTEGER ']' */ +#line 834 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-4])); + IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast(yyvsp[-1]); g_parse->checkArrayVaid(type,iPtrSize->v); type->setArray(iPtrSize->v); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[-3])); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-3]); TypeIdPtr typeIdPtr = new TypeId(type, ident->v); - (yyval) = GrammarBasePtr::dynamicCast(typeIdPtr); + yyval = GrammarBasePtr::dynamicCast(typeIdPtr); } -#line 2392 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2314 "tars.tab.cpp" break; - case 82: -#line 844 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - TypePtr type = g_parse->createVector(TypePtr::dynamicCast((yyvsp[-2]))); + case 82: /* type_id: type '*' TARS_IDENTIFIER */ +#line 844 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-2])); //IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast($4); g_parse->checkPointerVaid(type); type->setPointer(true); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypeIdPtr typeIdPtr = new TypeId(type, ident->v); - (yyval) = GrammarBasePtr::dynamicCast(typeIdPtr); + yyval = GrammarBasePtr::dynamicCast(typeIdPtr); } -#line 2406 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2328 "tars.tab.cpp" break; - case 83: -#line 854 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - TypePtr type = TypePtr::dynamicCast((yyvsp[-3])); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[-2])); + case 83: /* type_id: type TARS_IDENTIFIER ':' TARS_CONST_INTEGER */ +#line 854 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + TypePtr type = TypePtr::dynamicCast(yyvsp[-3]); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); TypeIdPtr typeIdPtr = new TypeId(type, ident->v); - IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast((yyvsp[-1])); + IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast(yyvsp[-1]); g_parse->checkArrayVaid(type,iPtrSize->v); - (yyval) = GrammarBasePtr::dynamicCast(typeIdPtr); + yyval = GrammarBasePtr::dynamicCast(typeIdPtr); } -#line 2419 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2341 "tars.tab.cpp" break; - case 84: -#line 863 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 84: /* type_id: type keyword */ +#line 863 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as data member name"); } -#line 2428 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2350 "tars.tab.cpp" break; - case 85: -#line 868 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 85: /* type_id: type */ +#line 868 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("missing data member name"); } -#line 2436 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2358 "tars.tab.cpp" break; - case 86: -#line 872 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 86: /* type_id: error */ +#line 872 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("unkown type"); } -#line 2444 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2366 "tars.tab.cpp" break; - case 87: -#line 881 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 87: /* type: type_no ':' TARS_CONST_INTEGER */ +#line 881 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ - TypePtr type = TypePtr::dynamicCast((yyvsp[-2])); - IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast((yyvsp[0])); + TypePtr type = TypePtr::dynamicCast(yyvsp[-2]); + IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast(yyvsp[0]); g_parse->checkArrayVaid(type,iPtrSize->v); type->setArray(iPtrSize->v); - (yyval) = type; + yyval = type; } -#line 2457 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2379 "tars.tab.cpp" break; - case 88: -#line 890 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = (yyvsp[0]); + case 88: /* type: type_no */ +#line 890 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = yyvsp[0]; } -#line 2465 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2387 "tars.tab.cpp" break; - case 89: -#line 894 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 89: /* type: type_no ':' error */ +#line 894 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("array missing size"); } -#line 2473 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2395 "tars.tab.cpp" break; - case 90: -#line 903 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindBool); + case 90: /* type_no: TARS_BOOL */ +#line 903 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindBool); } -#line 2481 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2403 "tars.tab.cpp" break; - case 91: -#line 907 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindByte); + case 91: /* type_no: TARS_BYTE */ +#line 907 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindByte); } -#line 2489 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2411 "tars.tab.cpp" break; - case 92: -#line 911 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindShort,true); + case 92: /* type_no: TARS_UNSIGNED TARS_BYTE */ +#line 911 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindShort,true); } -#line 2497 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2419 "tars.tab.cpp" break; - case 93: -#line 915 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindShort); + case 93: /* type_no: TARS_SHORT */ +#line 915 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindShort); } -#line 2505 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2427 "tars.tab.cpp" break; - case 94: -#line 919 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindInt,true); + case 94: /* type_no: TARS_UNSIGNED TARS_SHORT */ +#line 919 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindInt,true); } -#line 2513 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2435 "tars.tab.cpp" break; - case 95: -#line 923 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindInt); + case 95: /* type_no: TARS_INT */ +#line 923 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindInt); } -#line 2521 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2443 "tars.tab.cpp" break; - case 96: -#line 927 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindLong,true); + case 96: /* type_no: TARS_UNSIGNED TARS_INT */ +#line 927 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindLong,true); } -#line 2529 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2451 "tars.tab.cpp" break; - case 97: -#line 931 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindLong); + case 97: /* type_no: TARS_LONG */ +#line 931 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindLong); } -#line 2537 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2459 "tars.tab.cpp" break; - case 98: -#line 935 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindFloat); + case 98: /* type_no: TARS_FLOAT */ +#line 935 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindFloat); } -#line 2545 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2467 "tars.tab.cpp" break; - case 99: -#line 939 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindDouble); + case 99: /* type_no: TARS_DOUBLE */ +#line 939 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindDouble); } -#line 2553 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2475 "tars.tab.cpp" break; - case 100: -#line 943 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindString); + case 100: /* type_no: TARS_STRING */ +#line 943 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindString); } -#line 2561 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2483 "tars.tab.cpp" break; - case 101: -#line 947 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[0])); + case 101: /* type_no: vector */ +#line 947 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } -#line 2569 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2491 "tars.tab.cpp" break; - case 102: -#line 951 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[0])); + case 102: /* type_no: map */ +#line 951 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } -#line 2577 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2499 "tars.tab.cpp" break; - case 103: -#line 955 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 103: /* type_no: scoped_name */ +#line 955 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypePtr sp = g_parse->findUserType(ident->v); if(sp) { - (yyval) = GrammarBasePtr::dynamicCast(sp); + yyval = GrammarBasePtr::dynamicCast(sp); } else { g_parse->error("'" + ident->v + "' undefined!"); } } -#line 2594 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2516 "tars.tab.cpp" break; - case 104: -#line 973 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = GrammarBasePtr::dynamicCast(g_parse->createVector(TypePtr::dynamicCast((yyvsp[-1])))); + case 104: /* vector: TARS_VECTOR '<' type '>' */ +#line 973 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = GrammarBasePtr::dynamicCast(g_parse->createVector(TypePtr::dynamicCast(yyvsp[-1]))); } -#line 2602 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2524 "tars.tab.cpp" break; - case 105: -#line 977 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 105: /* vector: TARS_VECTOR '<' error */ +#line 977 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("vector error"); } -#line 2610 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2532 "tars.tab.cpp" break; - case 106: -#line 981 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 106: /* vector: TARS_VECTOR '<' type error */ +#line 981 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("vector missing '>'"); } -#line 2618 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2540 "tars.tab.cpp" break; - case 107: -#line 985 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 107: /* vector: TARS_VECTOR error */ +#line 985 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("vector missing type"); } -#line 2626 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2548 "tars.tab.cpp" break; - case 108: -#line 994 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = GrammarBasePtr::dynamicCast(g_parse->createMap(TypePtr::dynamicCast((yyvsp[-3])), TypePtr::dynamicCast((yyvsp[-1])))); + case 108: /* map: TARS_MAP '<' type ',' type '>' */ +#line 994 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = GrammarBasePtr::dynamicCast(g_parse->createMap(TypePtr::dynamicCast(yyvsp[-3]), TypePtr::dynamicCast(yyvsp[-1]))); } -#line 2634 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2556 "tars.tab.cpp" break; - case 109: -#line 998 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 109: /* map: TARS_MAP '<' error */ +#line 998 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("map error"); } -#line 2642 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2564 "tars.tab.cpp" break; - case 110: -#line 1007 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 110: /* scoped_name: TARS_IDENTIFIER */ +#line 1007 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2649 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2571 "tars.tab.cpp" break; - case 111: -#line 1010 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 111: /* scoped_name: TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ +#line 1010 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ident->v = "::" + ident->v; - (yyval) = GrammarBasePtr::dynamicCast(ident); + yyval = GrammarBasePtr::dynamicCast(ident); } -#line 2659 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2581 "tars.tab.cpp" break; - case 112: -#line 1016 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr scoped = StringGrammarPtr::dynamicCast((yyvsp[-2])); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 112: /* scoped_name: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ +#line 1016 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); scoped->v += "::"; scoped->v += ident->v; - (yyval) = GrammarBasePtr::dynamicCast(scoped); + yyval = GrammarBasePtr::dynamicCast(scoped); } -#line 2671 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2593 "tars.tab.cpp" break; - case 113: -#line 1029 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 113: /* keyword: TARS_STRUCT */ +#line 1029 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2678 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2600 "tars.tab.cpp" break; - case 114: -#line 1032 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 114: /* keyword: TARS_VOID */ +#line 1032 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2685 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2607 "tars.tab.cpp" break; - case 115: -#line 1035 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 115: /* keyword: TARS_BOOL */ +#line 1035 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2692 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2614 "tars.tab.cpp" break; - case 116: -#line 1038 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 116: /* keyword: TARS_BYTE */ +#line 1038 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2699 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2621 "tars.tab.cpp" break; - case 117: -#line 1041 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 117: /* keyword: TARS_SHORT */ +#line 1041 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2706 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2628 "tars.tab.cpp" break; - case 118: -#line 1044 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 118: /* keyword: TARS_INT */ +#line 1044 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2713 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2635 "tars.tab.cpp" break; - case 119: -#line 1047 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 119: /* keyword: TARS_FLOAT */ +#line 1047 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2720 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2642 "tars.tab.cpp" break; - case 120: -#line 1050 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 120: /* keyword: TARS_DOUBLE */ +#line 1050 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2727 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2649 "tars.tab.cpp" break; - case 121: -#line 1053 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 121: /* keyword: TARS_STRING */ +#line 1053 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2734 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2656 "tars.tab.cpp" break; - case 122: -#line 1056 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 122: /* keyword: TARS_VECTOR */ +#line 1056 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2741 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2663 "tars.tab.cpp" break; - case 123: -#line 1059 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 123: /* keyword: TARS_KEY */ +#line 1059 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2748 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2670 "tars.tab.cpp" break; - case 124: -#line 1062 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 124: /* keyword: TARS_MAP */ +#line 1062 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2755 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2677 "tars.tab.cpp" break; - case 125: -#line 1065 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 125: /* keyword: TARS_NAMESPACE */ +#line 1065 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2762 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2684 "tars.tab.cpp" break; - case 126: -#line 1068 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 126: /* keyword: TARS_INTERFACE */ +#line 1068 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2769 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2691 "tars.tab.cpp" break; - case 127: -#line 1071 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 127: /* keyword: TARS_OUT */ +#line 1071 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2776 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2698 "tars.tab.cpp" break; - case 128: -#line 1074 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 128: /* keyword: TARS_REQUIRE */ +#line 1074 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2783 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2705 "tars.tab.cpp" break; - case 129: -#line 1077 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 129: /* keyword: TARS_OPTIONAL */ +#line 1077 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2790 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2712 "tars.tab.cpp" break; - case 130: -#line 1080 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 130: /* keyword: TARS_CONST_INTEGER */ +#line 1080 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2797 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2719 "tars.tab.cpp" break; - case 131: -#line 1083 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 131: /* keyword: TARS_CONST_FLOAT */ +#line 1083 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2804 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2726 "tars.tab.cpp" break; - case 132: -#line 1086 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 132: /* keyword: TARS_FALSE */ +#line 1086 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2811 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2733 "tars.tab.cpp" break; - case 133: -#line 1089 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 133: /* keyword: TARS_TRUE */ +#line 1089 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2818 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2740 "tars.tab.cpp" break; - case 134: -#line 1092 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 134: /* keyword: TARS_STRING_LITERAL */ +#line 1092 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2825 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2747 "tars.tab.cpp" break; - case 135: -#line 1095 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 135: /* keyword: TARS_CONST */ +#line 1095 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2832 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2754 "tars.tab.cpp" break; - case 136: -#line 1098 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 136: /* keyword: TARS_ENUM */ +#line 1098 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2839 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2761 "tars.tab.cpp" break; - case 137: -#line 1101 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 137: /* keyword: TARS_UNSIGNED */ +#line 1101 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2846 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2768 "tars.tab.cpp" break; -#line 2850 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2772 "tars.tab.cpp" + default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -2860,25 +2783,23 @@ yyparse (void) case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; - YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; + { + const int yylhs = yyr1[yyn] - YYNTOKENS; + const int yyi = yypgoto[yylhs] + *yyssp; + yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp + ? yytable[yyi] + : yydefgoto[yylhs]); + } goto yynewstate; @@ -2889,50 +2810,14 @@ yyparse (void) yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - + yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; -#if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); -#else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyssp, yytoken) - { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - yyerror (yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; - } -# undef YYSYNTAX_ERROR -#endif } - - if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an @@ -2961,12 +2846,10 @@ yyparse (void) | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -2983,13 +2866,14 @@ yyparse (void) yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ + /* Pop stack until we find a state that shifts the error token. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + yyn += YYSYMBOL_YYerror; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) { yyn = yytable[yyn]; if (0 < yyn) @@ -3003,7 +2887,7 @@ yyparse (void) yydestruct ("Error: popping", - yystos[yystate], yyvsp); + YY_ACCESSING_SYMBOL (yystate), yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -3015,7 +2899,7 @@ yyparse (void) /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -3028,6 +2912,7 @@ yyparse (void) yyresult = 0; goto yyreturn; + /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -3035,16 +2920,21 @@ yyparse (void) yyresult = 1; goto yyreturn; -#if !defined yyoverflow || YYERROR_VERBOSE + +#if !defined yyoverflow /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; - /* Fall through. */ + goto yyreturn; #endif + +/*-------------------------------------------------------. +| yyreturn -- parsing is finished, clean up and return. | +`-------------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -3061,20 +2951,18 @@ yyparse (void) while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); + YY_ACCESSING_SYMBOL (+*yyssp), yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif + return yyresult; } -#line 1105 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1906 */ + +#line 1105 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" diff --git a/tools/tarsparse/tars.lex.cpp b/tools/tarsparse/tars.lex.cpp index 4c5d318c..bbba0ba7 100644 --- a/tools/tarsparse/tars.lex.cpp +++ b/tools/tarsparse/tars.lex.cpp @@ -1,6 +1,6 @@ -#line 2 "tars.lex.cpp" +#line 1 "tars.lex.cpp" -#line 4 "tars.lex.cpp" +#line 3 "tars.lex.cpp" #define YY_INT_ALIGNED short int @@ -47,6 +47,7 @@ typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; @@ -155,7 +156,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef size_t yy_size_t; #endif -extern int yyleng; +extern yy_size_t yyleng; extern FILE *yyin, *yyout; @@ -172,7 +173,7 @@ extern FILE *yyin, *yyout; */ #define YY_LESS_LINENO(n) \ do { \ - int yyl;\ + yy_size_t yyl;\ for ( yyl = n; yyl < yyleng; ++yyl )\ if ( yytext[yyl] == '\n' )\ --yylineno;\ @@ -217,7 +218,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - int yy_n_chars; + yy_size_t yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -286,8 +287,8 @@ static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; -static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int yyleng; +static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ +yy_size_t yyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = NULL; @@ -314,7 +315,7 @@ static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len ); void *yyalloc ( yy_size_t ); void *yyrealloc ( void *, yy_size_t ); @@ -367,7 +368,7 @@ static void yynoreturn yy_fatal_error ( const char* msg ); */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; @@ -510,7 +511,7 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 1 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" /** * Tencent is pleased to support the open source community by making Tars available. * @@ -526,7 +527,7 @@ char *yytext; * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -#line 20 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 20 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" #include #include #include @@ -597,7 +598,7 @@ FILE *yyget_out ( void ); void yyset_out ( FILE * _out_str ); - int yyget_leng ( void ); + yy_size_t yyget_leng ( void ); char *yyget_text ( void ); @@ -666,7 +667,7 @@ static int input ( void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - int n; \ + yy_size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -775,7 +776,7 @@ YY_DECL } { -#line 67 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 67 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" #line 782 "tars.lex.cpp" @@ -826,7 +827,7 @@ YY_DECL if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { - int yyl; + yy_size_t yyl; for ( yyl = 0; yyl < yyleng; ++yyl ) if ( yytext[yyl] == '\n' ) @@ -847,12 +848,12 @@ YY_DECL case 1: YY_RULE_SETUP -#line 69 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 69 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" { BEGIN(INCL); } YY_BREAK case 2: YY_RULE_SETUP -#line 71 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 71 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" { if ( include_file_stack_ptr >= MAX_INCLUDE_DEPTH ) { @@ -885,7 +886,7 @@ YY_RULE_SETUP YY_BREAK case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INCL): -#line 101 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 101 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" { --include_file_stack_ptr; if ( include_file_stack_ptr < 0 ) @@ -904,14 +905,14 @@ case YY_STATE_EOF(INCL): YY_BREAK case 3: YY_RULE_SETUP -#line 117 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 117 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" { return TARS_SCOPE_DELIMITER; } YY_BREAK case 4: YY_RULE_SETUP -#line 121 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 121 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" { // C++ comment bool e = false; @@ -932,7 +933,7 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 139 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 139 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" { // C comment bool e = false; @@ -983,7 +984,7 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 187 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 187 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" { StringGrammarPtr ident = new StringGrammar; ident->v = yytext; @@ -994,7 +995,7 @@ YY_RULE_SETUP case 7: /* rule 7 can match eol */ YY_RULE_SETUP -#line 194 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 194 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" { StringGrammarPtr ident = new StringGrammar; ident->v = yytext; @@ -1007,7 +1008,7 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 204 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 204 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" { StringGrammarPtr str = new StringGrammar; bool e = false; @@ -1122,7 +1123,7 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 316 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 316 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" { errno = 0; IntergerGrammarPtr ptr = new IntergerGrammar; @@ -1147,7 +1148,7 @@ YY_RULE_SETUP YY_BREAK case 10: YY_RULE_SETUP -#line 338 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 338 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" { errno = 0; FloatGrammarPtr ptr = new FloatGrammar; @@ -1182,7 +1183,7 @@ YY_RULE_SETUP case 11: /* rule 11 can match eol */ YY_RULE_SETUP -#line 369 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 369 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" { if(yytext[0] == '\n') { @@ -1192,7 +1193,7 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 376 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 376 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" { if(yytext[0] < 32 || yytext[0] > 126) { @@ -1211,7 +1212,7 @@ YY_RULE_SETUP YY_BREAK case 13: YY_RULE_SETUP -#line 392 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 392 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" ECHO; YY_BREAK #line 1218 "tars.lex.cpp" @@ -1399,7 +1400,7 @@ static int yy_get_next_buffer (void) else { - int num_to_read = + yy_size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -1413,7 +1414,7 @@ static int yy_get_next_buffer (void) if ( b->yy_is_our_buffer ) { - int new_size = b->yy_buf_size * 2; + yy_size_t new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -1471,7 +1472,7 @@ static int yy_get_next_buffer (void) if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ - int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) @@ -1560,7 +1561,7 @@ static int yy_get_next_buffer (void) if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - int number_to_move = (yy_n_chars) + 2; + yy_size_t number_to_move = (yy_n_chars) + 2; char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; char *source = @@ -1615,7 +1616,7 @@ static int yy_get_next_buffer (void) else { /* need more input */ - int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) @@ -1989,12 +1990,12 @@ YY_BUFFER_STATE yy_scan_string (const char * yystr ) * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len ) { YY_BUFFER_STATE b; char *buf; yy_size_t n; - int i; + yy_size_t i; /* Get memory for full buffer, including space for trailing EOB's. */ n = (yy_size_t) (_yybytes_len + 2); @@ -2036,7 +2037,7 @@ static void yynoreturn yy_fatal_error (const char* msg ) do \ { \ /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ + yy_size_t yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = (yy_hold_char); \ (yy_c_buf_p) = yytext + yyless_macro_arg; \ @@ -2076,7 +2077,7 @@ FILE *yyget_out (void) /** Get the length of the current token. * */ -int yyget_leng (void) +yy_size_t yyget_leng (void) { return yyleng; } @@ -2229,7 +2230,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 392 "/root/boat/TarsCpp/tools/tarsgrammar/tars.l" +#line 392 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" diff --git a/tools/tarsparse/tars.tab.cpp b/tools/tarsparse/tars.tab.cpp index ee40db41..ea2659e4 100644 --- a/tools/tarsparse/tars.tab.cpp +++ b/tools/tarsparse/tars.tab.cpp @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.7.6. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, + 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 @@ -15,7 +16,7 @@ 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 . */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -33,6 +34,10 @@ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ + /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. @@ -40,11 +45,11 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -/* Identify Bison output. */ -#define YYBISON 1 +/* Identify Bison output, and Bison version. */ +#define YYBISON 30706 -/* Bison version. */ -#define YYBISON_VERSION "3.0.4" +/* Bison version string. */ +#define YYBISON_VERSION "3.7.6" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -61,8 +66,8 @@ -/* Copy the first part of user declarations. */ -#line 17 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:339 */ +/* First part of user prologue. */ +#line 17 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" #include #include @@ -76,119 +81,213 @@ using namespace std; #define YYDEBUG 1 #define YYINITDEPTH 10000 -#line 80 "tars.tab.cpp" /* yacc.c:339 */ +#line 85 "tars.tab.cpp" +# ifndef YY_CAST +# ifdef __cplusplus +# define YY_CAST(Type, Val) static_cast (Val) +# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val) +# else +# define YY_CAST(Type, Val) ((Type) (Val)) +# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) +# endif +# endif # ifndef YY_NULLPTR -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif # else -# define YY_NULLPTR 0 +# define YY_NULLPTR ((void*)0) # endif # endif -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* In a future release of Bison, this section will be replaced - by #include "tars.tab.hpp". */ -#ifndef YY_YY_TARS_TAB_HPP_INCLUDED -# define YY_YY_TARS_TAB_HPP_INCLUDED -/* Debug traces. */ -#ifndef YYDEBUG -# define YYDEBUG 1 -#endif -#if YYDEBUG -extern int yydebug; -#endif - -/* Token type. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - enum yytokentype - { - TARS_VOID = 258, - TARS_STRUCT = 259, - TARS_BOOL = 260, - TARS_BYTE = 261, - TARS_SHORT = 262, - TARS_INT = 263, - TARS_DOUBLE = 264, - TARS_FLOAT = 265, - TARS_LONG = 266, - TARS_STRING = 267, - TARS_VECTOR = 268, - TARS_MAP = 269, - TARS_NAMESPACE = 270, - TARS_INTERFACE = 271, - TARS_IDENTIFIER = 272, - TARS_OUT = 273, - TARS_OP = 274, - TARS_KEY = 275, - TARS_ROUTE_KEY = 276, - TARS_REQUIRE = 277, - TARS_OPTIONAL = 278, - TARS_CONST_INTEGER = 279, - TARS_CONST_FLOAT = 280, - TARS_FALSE = 281, - TARS_TRUE = 282, - TARS_STRING_LITERAL = 283, - TARS_SCOPE_DELIMITER = 284, - TARS_CONST = 285, - TARS_ENUM = 286, - TARS_UNSIGNED = 287, - BAD_CHAR = 288 - }; -#endif +#include "tars.tab.hpp" +/* Symbol kind. */ +enum yysymbol_kind_t +{ + YYSYMBOL_YYEMPTY = -2, + YYSYMBOL_YYEOF = 0, /* "end of file" */ + YYSYMBOL_YYerror = 1, /* error */ + YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ + YYSYMBOL_TARS_VOID = 3, /* TARS_VOID */ + YYSYMBOL_TARS_STRUCT = 4, /* TARS_STRUCT */ + YYSYMBOL_TARS_BOOL = 5, /* TARS_BOOL */ + YYSYMBOL_TARS_BYTE = 6, /* TARS_BYTE */ + YYSYMBOL_TARS_SHORT = 7, /* TARS_SHORT */ + YYSYMBOL_TARS_INT = 8, /* TARS_INT */ + YYSYMBOL_TARS_DOUBLE = 9, /* TARS_DOUBLE */ + YYSYMBOL_TARS_FLOAT = 10, /* TARS_FLOAT */ + YYSYMBOL_TARS_LONG = 11, /* TARS_LONG */ + YYSYMBOL_TARS_STRING = 12, /* TARS_STRING */ + YYSYMBOL_TARS_VECTOR = 13, /* TARS_VECTOR */ + YYSYMBOL_TARS_MAP = 14, /* TARS_MAP */ + YYSYMBOL_TARS_NAMESPACE = 15, /* TARS_NAMESPACE */ + YYSYMBOL_TARS_INTERFACE = 16, /* TARS_INTERFACE */ + YYSYMBOL_TARS_IDENTIFIER = 17, /* TARS_IDENTIFIER */ + YYSYMBOL_TARS_OUT = 18, /* TARS_OUT */ + YYSYMBOL_TARS_OP = 19, /* TARS_OP */ + YYSYMBOL_TARS_KEY = 20, /* TARS_KEY */ + YYSYMBOL_TARS_ROUTE_KEY = 21, /* TARS_ROUTE_KEY */ + YYSYMBOL_TARS_REQUIRE = 22, /* TARS_REQUIRE */ + YYSYMBOL_TARS_OPTIONAL = 23, /* TARS_OPTIONAL */ + YYSYMBOL_TARS_CONST_INTEGER = 24, /* TARS_CONST_INTEGER */ + YYSYMBOL_TARS_CONST_FLOAT = 25, /* TARS_CONST_FLOAT */ + YYSYMBOL_TARS_FALSE = 26, /* TARS_FALSE */ + YYSYMBOL_TARS_TRUE = 27, /* TARS_TRUE */ + YYSYMBOL_TARS_STRING_LITERAL = 28, /* TARS_STRING_LITERAL */ + YYSYMBOL_TARS_SCOPE_DELIMITER = 29, /* TARS_SCOPE_DELIMITER */ + YYSYMBOL_TARS_CONST = 30, /* TARS_CONST */ + YYSYMBOL_TARS_ENUM = 31, /* TARS_ENUM */ + YYSYMBOL_TARS_UNSIGNED = 32, /* TARS_UNSIGNED */ + YYSYMBOL_BAD_CHAR = 33, /* BAD_CHAR */ + YYSYMBOL_34_ = 34, /* ';' */ + YYSYMBOL_35_ = 35, /* '{' */ + YYSYMBOL_36_ = 36, /* '}' */ + YYSYMBOL_37_ = 37, /* ',' */ + YYSYMBOL_38_ = 38, /* '=' */ + YYSYMBOL_39_ = 39, /* '[' */ + YYSYMBOL_40_ = 40, /* ']' */ + YYSYMBOL_41_ = 41, /* ')' */ + YYSYMBOL_42_ = 42, /* '*' */ + YYSYMBOL_43_ = 43, /* ':' */ + YYSYMBOL_44_ = 44, /* '<' */ + YYSYMBOL_45_ = 45, /* '>' */ + YYSYMBOL_YYACCEPT = 46, /* $accept */ + YYSYMBOL_start = 47, /* start */ + YYSYMBOL_definitions = 48, /* definitions */ + YYSYMBOL_49_1 = 49, /* $@1 */ + YYSYMBOL_50_2 = 50, /* $@2 */ + YYSYMBOL_definition = 51, /* definition */ + YYSYMBOL_enum_def = 52, /* enum_def */ + YYSYMBOL_53_3 = 53, /* @3 */ + YYSYMBOL_enum_id = 54, /* enum_id */ + YYSYMBOL_enumerator_list = 55, /* enumerator_list */ + YYSYMBOL_enumerator = 56, /* enumerator */ + YYSYMBOL_namespace_def = 57, /* namespace_def */ + YYSYMBOL_58_4 = 58, /* @4 */ + YYSYMBOL_key_def = 59, /* key_def */ + YYSYMBOL_60_5 = 60, /* $@5 */ + YYSYMBOL_key_members = 61, /* key_members */ + YYSYMBOL_interface_def = 62, /* interface_def */ + YYSYMBOL_63_6 = 63, /* @6 */ + YYSYMBOL_interface_id = 64, /* interface_id */ + YYSYMBOL_interface_exports = 65, /* interface_exports */ + YYSYMBOL_interface_export = 66, /* interface_export */ + YYSYMBOL_operation = 67, /* operation */ + YYSYMBOL_operation_preamble = 68, /* operation_preamble */ + YYSYMBOL_return_type = 69, /* return_type */ + YYSYMBOL_parameters = 70, /* parameters */ + YYSYMBOL_routekey_qualifier = 71, /* routekey_qualifier */ + YYSYMBOL_out_qualifier = 72, /* out_qualifier */ + YYSYMBOL_struct_def = 73, /* struct_def */ + YYSYMBOL_74_7 = 74, /* @7 */ + YYSYMBOL_struct_id = 75, /* struct_id */ + YYSYMBOL_struct_exports = 76, /* struct_exports */ + YYSYMBOL_data_member = 77, /* data_member */ + YYSYMBOL_struct_type_id = 78, /* struct_type_id */ + YYSYMBOL_const_initializer = 79, /* const_initializer */ + YYSYMBOL_const_def = 80, /* const_def */ + YYSYMBOL_type_id = 81, /* type_id */ + YYSYMBOL_type = 82, /* type */ + YYSYMBOL_type_no = 83, /* type_no */ + YYSYMBOL_vector = 84, /* vector */ + YYSYMBOL_map = 85, /* map */ + YYSYMBOL_scoped_name = 86, /* scoped_name */ + YYSYMBOL_keyword = 87 /* keyword */ +}; +typedef enum yysymbol_kind_t yysymbol_kind_t; -/* Value type. */ -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef int YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define YYSTYPE_IS_DECLARED 1 -#endif -extern YYSTYPE yylval; -int yyparse (void); +#ifdef short +# undef short +#endif -#endif /* !YY_YY_TARS_TAB_HPP_INCLUDED */ +/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure + and (if available) are included + so that the code can choose integer types of a good width. */ -/* Copy the second part of user declarations. */ +#ifndef __PTRDIFF_MAX__ +# include /* INFRINGES ON USER NAME SPACE */ +# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_STDINT_H +# endif +#endif -#line 165 "tars.tab.cpp" /* yacc.c:358 */ +/* Narrow types that promote to a signed type and that can represent a + signed or unsigned integer of at least N bits. In tables they can + save space and decrease cache pressure. Promoting to a signed type + helps avoid bugs in integer arithmetic. */ -#ifdef short -# undef short +#ifdef __INT_LEAST8_MAX__ +typedef __INT_LEAST8_TYPE__ yytype_int8; +#elif defined YY_STDINT_H +typedef int_least8_t yytype_int8; +#else +typedef signed char yytype_int8; #endif -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; +#ifdef __INT_LEAST16_MAX__ +typedef __INT_LEAST16_TYPE__ yytype_int16; +#elif defined YY_STDINT_H +typedef int_least16_t yytype_int16; #else -typedef unsigned char yytype_uint8; +typedef short yytype_int16; #endif -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; -#else -typedef signed char yytype_int8; +/* Work around bug in HP-UX 11.23, which defines these macros + incorrectly for preprocessor constants. This workaround can likely + be removed in 2023, as HPE has promised support for HP-UX 11.23 + (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of + . */ +#ifdef __hpux +# undef UINT_LEAST8_MAX +# undef UINT_LEAST16_MAX +# define UINT_LEAST8_MAX 255 +# define UINT_LEAST16_MAX 65535 #endif -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; +#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST8_TYPE__ yytype_uint8; +#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST8_MAX <= INT_MAX) +typedef uint_least8_t yytype_uint8; +#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX +typedef unsigned char yytype_uint8; #else -typedef unsigned short int yytype_uint16; +typedef short yytype_uint8; #endif -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; +#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST16_TYPE__ yytype_uint16; +#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST16_MAX <= INT_MAX) +typedef uint_least16_t yytype_uint16; +#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX +typedef unsigned short yytype_uint16; #else -typedef short int yytype_int16; +typedef int yytype_uint16; +#endif + +#ifndef YYPTRDIFF_T +# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ +# define YYPTRDIFF_T __PTRDIFF_TYPE__ +# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ +# elif defined PTRDIFF_MAX +# ifndef ptrdiff_t +# include /* INFRINGES ON USER NAME SPACE */ +# endif +# define YYPTRDIFF_T ptrdiff_t +# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX +# else +# define YYPTRDIFF_T long +# define YYPTRDIFF_MAXIMUM LONG_MAX +# endif #endif #ifndef YYSIZE_T @@ -196,15 +295,28 @@ typedef short int yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T +# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) +#define YYSIZE_MAXIMUM \ + YY_CAST (YYPTRDIFF_T, \ + (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ + ? YYPTRDIFF_MAXIMUM \ + : YY_CAST (YYSIZE_T, -1))) + +#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) + + +/* Stored state numbers (used for stacks). */ +typedef yytype_uint8 yy_state_t; + +/* State numbers in computations. */ +typedef int yy_state_fast_t; #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS @@ -218,47 +330,37 @@ typedef short int yytype_int16; # endif #endif -#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) -# else -# define YY_ATTRIBUTE(Spec) /* empty */ -# endif -#endif #ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define YY_ATTRIBUTE_PURE +# endif #endif #ifndef YY_ATTRIBUTE_UNUSED -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) -#endif - -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) +# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) # else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# define YY_ATTRIBUTE_UNUSED # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YYUSE(E) ((void) (E)) +# define YY_USE(E) ((void) (E)) #else -# define YYUSE(E) /* empty */ +# define YY_USE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value @@ -271,8 +373,22 @@ typedef short int yytype_int16; # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif +#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ +# define YY_IGNORE_USELESS_CAST_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") +# define YY_IGNORE_USELESS_CAST_END \ + _Pragma ("GCC diagnostic pop") +#endif +#ifndef YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_END +#endif + -#if ! defined yyoverflow || YYERROR_VERBOSE +#define YY_ASSERT(E) ((void) (0 && (E))) + +#if !defined yyoverflow /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -337,8 +453,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - +#endif /* !defined yyoverflow */ #if (! defined yyoverflow \ && (! defined __cplusplus \ @@ -347,17 +462,17 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss_alloc; + yy_state_t yyss_alloc; YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) +# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 @@ -370,11 +485,11 @@ union yyalloc # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ - YYSIZE_T yynewbytes; \ + YYPTRDIFF_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ + yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / YYSIZEOF (*yyptr); \ } \ while (0) @@ -386,12 +501,12 @@ union yyalloc # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) + __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ - YYSIZE_T yyi; \ + YYPTRDIFF_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ @@ -414,17 +529,20 @@ union yyalloc /* YYNSTATES -- Number of states. */ #define YYNSTATES 199 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ -#define YYUNDEFTOK 2 +/* YYMAXUTOK -- Last valid token kind. */ #define YYMAXUTOK 288 -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ +#define YYTRANSLATE(YYX) \ + (0 <= (YYX) && (YYX) <= YYMAXUTOK \ + ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \ + : YYSYMBOL_YYUNDEF) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ -static const yytype_uint8 yytranslate[] = + as returned by yylex. */ +static const yytype_int8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -459,7 +577,7 @@ static const yytype_uint8 yytranslate[] = #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = +static const yytype_int16 yyrline[] = { 0, 68, 68, 75, 74, 79, 78, 83, 88, 95, 99, 103, 107, 110, 114, 124, 123, 146, 159, 170, @@ -478,35 +596,48 @@ static const yytype_uint16 yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE || 0 +/** Accessing symbol of state STATE. */ +#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) + +#if YYDEBUG || 0 +/* The user-facing name of the symbol whose (internal) number is + YYSYMBOL. No bounds checking. */ +static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; + /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$end", "error", "$undefined", "TARS_VOID", "TARS_STRUCT", "TARS_BOOL", - "TARS_BYTE", "TARS_SHORT", "TARS_INT", "TARS_DOUBLE", "TARS_FLOAT", - "TARS_LONG", "TARS_STRING", "TARS_VECTOR", "TARS_MAP", "TARS_NAMESPACE", - "TARS_INTERFACE", "TARS_IDENTIFIER", "TARS_OUT", "TARS_OP", "TARS_KEY", - "TARS_ROUTE_KEY", "TARS_REQUIRE", "TARS_OPTIONAL", "TARS_CONST_INTEGER", - "TARS_CONST_FLOAT", "TARS_FALSE", "TARS_TRUE", "TARS_STRING_LITERAL", - "TARS_SCOPE_DELIMITER", "TARS_CONST", "TARS_ENUM", "TARS_UNSIGNED", - "BAD_CHAR", "';'", "'{'", "'}'", "','", "'='", "'['", "']'", "')'", - "'*'", "':'", "'<'", "'>'", "$accept", "start", "definitions", "$@1", - "$@2", "definition", "enum_def", "@3", "enum_id", "enumerator_list", - "enumerator", "namespace_def", "@4", "key_def", "$@5", "key_members", - "interface_def", "@6", "interface_id", "interface_exports", - "interface_export", "operation", "operation_preamble", "return_type", - "parameters", "routekey_qualifier", "out_qualifier", "struct_def", "@7", - "struct_id", "struct_exports", "data_member", "struct_type_id", - "const_initializer", "const_def", "type_id", "type", "type_no", "vector", - "map", "scoped_name", "keyword", YY_NULLPTR + "\"end of file\"", "error", "\"invalid token\"", "TARS_VOID", + "TARS_STRUCT", "TARS_BOOL", "TARS_BYTE", "TARS_SHORT", "TARS_INT", + "TARS_DOUBLE", "TARS_FLOAT", "TARS_LONG", "TARS_STRING", "TARS_VECTOR", + "TARS_MAP", "TARS_NAMESPACE", "TARS_INTERFACE", "TARS_IDENTIFIER", + "TARS_OUT", "TARS_OP", "TARS_KEY", "TARS_ROUTE_KEY", "TARS_REQUIRE", + "TARS_OPTIONAL", "TARS_CONST_INTEGER", "TARS_CONST_FLOAT", "TARS_FALSE", + "TARS_TRUE", "TARS_STRING_LITERAL", "TARS_SCOPE_DELIMITER", "TARS_CONST", + "TARS_ENUM", "TARS_UNSIGNED", "BAD_CHAR", "';'", "'{'", "'}'", "','", + "'='", "'['", "']'", "')'", "'*'", "':'", "'<'", "'>'", "$accept", + "start", "definitions", "$@1", "$@2", "definition", "enum_def", "@3", + "enum_id", "enumerator_list", "enumerator", "namespace_def", "@4", + "key_def", "$@5", "key_members", "interface_def", "@6", "interface_id", + "interface_exports", "interface_export", "operation", + "operation_preamble", "return_type", "parameters", "routekey_qualifier", + "out_qualifier", "struct_def", "@7", "struct_id", "struct_exports", + "data_member", "struct_type_id", "const_initializer", "const_def", + "type_id", "type", "type_no", "vector", "map", "scoped_name", "keyword", YY_NULLPTR }; + +static const char * +yysymbol_name (yysymbol_kind_t yysymbol) +{ + return yytname[yysymbol]; +} #endif -# ifdef YYPRINT +#ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ -static const yytype_uint16 yytoknum[] = +static const yytype_int16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, @@ -514,16 +645,16 @@ static const yytype_uint16 yytoknum[] = 285, 286, 287, 288, 59, 123, 125, 44, 61, 91, 93, 41, 42, 58, 60, 62 }; -# endif +#endif -#define YYPACT_NINF -146 +#define YYPACT_NINF (-146) -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-146))) +#define yypact_value_is_default(Yyn) \ + ((Yyn) == YYPACT_NINF) -#define YYTABLE_NINF -113 +#define YYTABLE_NINF (-113) -#define yytable_value_is_error(Yytable_value) \ +#define yytable_value_is_error(Yyn) \ 0 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing @@ -590,9 +721,9 @@ static const yytype_int16 yypgoto[] = }; /* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int16 yydefgoto[] = +static const yytype_uint8 yydefgoto[] = { - -1, 8, 9, 76, 80, 10, 11, 77, 12, 123, + 0, 8, 9, 76, 80, 10, 11, 77, 12, 123, 124, 13, 81, 14, 142, 171, 15, 78, 16, 128, 129, 130, 131, 132, 157, 158, 159, 17, 79, 18, 137, 138, 139, 113, 19, 140, 68, 69, 70, 71, @@ -726,7 +857,7 @@ static const yytype_int16 yycheck[] = /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = +static const yytype_int8 yystos[] = { 0, 1, 4, 15, 16, 20, 30, 31, 47, 48, 51, 52, 54, 57, 59, 62, 64, 73, 75, 80, @@ -751,7 +882,7 @@ static const yytype_uint8 yystos[] = }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = +static const yytype_int8 yyr1[] = { 0, 46, 47, 49, 48, 50, 48, 48, 48, 51, 51, 51, 51, 51, 51, 53, 52, 54, 54, 55, @@ -770,7 +901,7 @@ static const yytype_uint8 yyr1[] = }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = +static const yytype_int8 yyr2[] = { 0, 2, 1, 0, 4, 0, 4, 1, 0, 1, 1, 1, 1, 1, 1, 0, 5, 2, 2, 3, @@ -789,10 +920,10 @@ static const yytype_uint8 yyr2[] = }; +enum { YYENOMEM = -2 }; + #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab @@ -801,27 +932,26 @@ static const yytype_uint8 yyr2[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) - -/* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 - +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) + +/* Backward compatibility with an undocumented macro. + Use YYerror or YYUNDEF. */ +#define YYERRCODE YYUNDEF /* Enable debugging if requested. */ @@ -839,54 +969,58 @@ do { \ } while (0) /* This macro is provided for backward compatibility. */ -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif +# ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Type, Value); \ + Kind, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/ static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_value_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) { - FILE *yyo = yyoutput; - YYUSE (yyo); + FILE *yyoutput = yyo; + YY_USE (yyoutput); if (!yyvaluep) return; # ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); + if (yykind < YYNTOKENS) + YYPRINT (yyo, yytoknum[yykind], *yyvaluep); # endif - YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YY_USE (yykind); + YY_IGNORE_MAYBE_UNINITIALIZED_END } -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/ static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) { - YYFPRINTF (yyoutput, "%s %s (", - yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + YYFPRINTF (yyo, "%s %s (", + yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); + yy_symbol_value_print (yyo, yykind, yyvaluep); + YYFPRINTF (yyo, ")"); } /*------------------------------------------------------------------. @@ -895,7 +1029,7 @@ yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) `------------------------------------------------------------------*/ static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -918,21 +1052,21 @@ do { \ `------------------------------------------------*/ static void -yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, + int yyrule) { - unsigned long int yylno = yyrline[yyrule]; + int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, - yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); + YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), + &yyvsp[(yyi + 1) - (yynrhs)]); YYFPRINTF (stderr, "\n"); } } @@ -947,8 +1081,8 @@ do { \ multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YYDPRINTF(Args) ((void) 0) +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ @@ -971,249 +1105,30 @@ int yydebug; #endif -#if YYERROR_VERBOSE -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -yystrlen (const char *yystr) -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -yystpcpy (char *yydest, const char *yysrc) -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. - - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) -{ - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); - YYSIZE_T yysize = yysize0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat. */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ - int yycount = 0; - - /* There are many possibilities here to consider: - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yytoken != YYEMPTY) - { - int yyn = yypact[*yyssp]; - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - } - } - } - - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ - } - - { - YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; - } - - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyformat += 2; - } - else - { - yyp++; - yyformat++; - } - } - return 0; -} -#endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +yydestruct (const char *yymsg, + yysymbol_kind_t yykind, YYSTYPE *yyvaluep) { - YYUSE (yyvaluep); + YY_USE (yyvaluep); if (!yymsg) yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YYUSE (yytype); + YY_USE (yykind); YY_IGNORE_MAYBE_UNINITIALIZED_END } - - -/* The lookahead symbol. */ +/* Lookahead token kind. */ int yychar; /* The semantic value of the lookahead symbol. */ @@ -1222,6 +1137,8 @@ YYSTYPE yylval; int yynerrs; + + /*----------. | yyparse. | `----------*/ @@ -1229,43 +1146,36 @@ int yynerrs; int yyparse (void) { - int yystate; + yy_state_fast_t yystate = 0; /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; + int yyerrstatus = 0; - /* The stacks and their tools: - 'yyss': related to states. - 'yyvs': related to semantic values. - - Refer to the stacks through separate pointers, to allow yyoverflow + /* Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; + /* Their size. */ + YYPTRDIFF_T yystacksize = YYINITDEPTH; - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; + /* The state stack: array, bottom, top. */ + yy_state_t yyssa[YYINITDEPTH]; + yy_state_t *yyss = yyssa; + yy_state_t *yyssp = yyss; - YYSIZE_T yystacksize; + /* The semantic value stack: array, bottom, top. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp = yyvs; int yyn; + /* The return value of yyparse. */ int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; + /* Lookahead symbol kind. */ + yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif + #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) @@ -1273,58 +1183,60 @@ yyparse (void) Keep to zero when no symbol should be popped. */ int yylen = 0; - yyssp = yyss = yyssa; - yyvsp = yyvs = yyvsa; - yystacksize = YYINITDEPTH; - YYDPRINTF ((stderr, "Starting parse\n")); - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; + /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - yysetstate: - *yyssp = yystate; + +/*--------------------------------------------------------------------. +| yysetstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YY_ASSERT (0 <= yystate && yystate < YYNSTATES); + YY_IGNORE_USELESS_CAST_BEGIN + *yyssp = YY_CAST (yy_state_t, yystate); + YY_IGNORE_USELESS_CAST_END + YY_STACK_PRINT (yyss, yyssp); if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + goto yyexhaustedlab; +#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + YYPTRDIFF_T yysize = yyssp - yyss + 1; -#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ + yy_state_t *yyss1 = yyss; YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), + &yyss1, yysize * YYSIZEOF (*yyssp), + &yyvs1, yysize * YYSIZEOF (*yyvsp), &yystacksize); - yyss = yyss1; yyvs = yyvs1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1333,9 +1245,10 @@ yyparse (void) yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; + yy_state_t *yyss1 = yyss; union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + YY_CAST (union yyalloc *, + YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); @@ -1345,30 +1258,30 @@ yyparse (void) YYSTACK_FREE (yyss1); } # endif -#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + YY_IGNORE_USELESS_CAST_BEGIN + YYDPRINTF ((stderr, "Stack size increased to %ld\n", + YY_CAST (long, yystacksize))); + YY_IGNORE_USELESS_CAST_END if (yyss + yystacksize - 1 <= yyssp) YYABORT; } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ if (yystate == YYFINAL) YYACCEPT; goto yybackup; + /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1379,18 +1292,29 @@ yyparse (void) /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ if (yychar == YYEMPTY) { - YYDPRINTF ((stderr, "Reading a token: ")); + YYDPRINTF ((stderr, "Reading a token\n")); yychar = yylex (); } if (yychar <= YYEOF) { - yychar = yytoken = YYEOF; + yychar = YYEOF; + yytoken = YYSYMBOL_YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } + else if (yychar == YYerror) + { + /* The scanner already issued an error message, process directly + to error recovery. But do not keep the error token as + lookahead, it is too special and may lead us to an endless + loop in error recovery. */ + yychar = YYUNDEF; + yytoken = YYSYMBOL_YYerror; + goto yyerrlab1; + } else { yytoken = YYTRANSLATE (yychar); @@ -1418,15 +1342,13 @@ yyparse (void) /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END + /* Discard the shifted token. */ + yychar = YYEMPTY; goto yynewstate; @@ -1441,7 +1363,7 @@ yyparse (void) /*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1461,238 +1383,238 @@ yyparse (void) YY_REDUCE_PRINT (yyn); switch (yyn) { - case 3: -#line 75 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 3: /* $@1: %empty */ +#line 75 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1469 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1391 "tars.tab.cpp" break; - case 5: -#line 79 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 5: /* $@2: %empty */ +#line 79 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ yyerrok; } -#line 1477 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1399 "tars.tab.cpp" break; - case 7: -#line 84 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 7: /* definitions: definition */ +#line 84 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("`;' missing after definition"); } -#line 1485 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1407 "tars.tab.cpp" break; - case 8: -#line 88 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 8: /* definitions: %empty */ +#line 88 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1492 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1414 "tars.tab.cpp" break; - case 9: -#line 96 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - assert((yyvsp[0]) == 0 || NamespacePtr::dynamicCast((yyvsp[0]))); + case 9: /* definition: namespace_def */ +#line 96 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + assert(yyvsp[0] == 0 || NamespacePtr::dynamicCast(yyvsp[0])); } -#line 1500 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1422 "tars.tab.cpp" break; - case 10: -#line 100 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - assert((yyvsp[0]) == 0 || InterfacePtr::dynamicCast((yyvsp[0]))); + case 10: /* definition: interface_def */ +#line 100 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + assert(yyvsp[0] == 0 || InterfacePtr::dynamicCast(yyvsp[0])); } -#line 1508 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1430 "tars.tab.cpp" break; - case 11: -#line 104 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - assert((yyvsp[0]) == 0 || StructPtr::dynamicCast((yyvsp[0]))); + case 11: /* definition: struct_def */ +#line 104 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + assert(yyvsp[0] == 0 || StructPtr::dynamicCast(yyvsp[0])); } -#line 1516 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1438 "tars.tab.cpp" break; - case 12: -#line 108 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 12: /* definition: key_def */ +#line 108 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1523 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1445 "tars.tab.cpp" break; - case 13: -#line 111 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - assert((yyvsp[0]) == 0 || EnumPtr::dynamicCast((yyvsp[0]))); + case 13: /* definition: enum_def */ +#line 111 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + assert(yyvsp[0] == 0 || EnumPtr::dynamicCast(yyvsp[0])); } -#line 1531 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1453 "tars.tab.cpp" break; - case 14: -#line 115 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - assert((yyvsp[0]) == 0 || ConstPtr::dynamicCast((yyvsp[0]))); + case 14: /* definition: const_def */ +#line 115 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + assert(yyvsp[0] == 0 || ConstPtr::dynamicCast(yyvsp[0])); } -#line 1539 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1461 "tars.tab.cpp" break; - case 15: -#line 124 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = (yyvsp[0]); + case 15: /* @3: %empty */ +#line 124 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = yyvsp[0]; } -#line 1547 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1469 "tars.tab.cpp" break; - case 16: -#line 128 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - if((yyvsp[-2])) + case 16: /* enum_def: enum_id @3 '{' enumerator_list '}' */ +#line 128 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + if(yyvsp[-2]) { g_parse->popContainer(); - (yyval) = (yyvsp[-2]); + yyval = yyvsp[-2]; } else { - (yyval) = 0; + yyval = 0; } - (yyval) = (yyvsp[-3]); + yyval = yyvsp[-3]; } -#line 1565 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1487 "tars.tab.cpp" break; - case 17: -#line 147 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 17: /* enum_id: TARS_ENUM TARS_IDENTIFIER */ +#line 147 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ NamespacePtr c = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!c) { g_parse->error("enum must define in namespace"); } - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); EnumPtr e = c->createEnum(ident->v); g_parse->pushContainer(e); - (yyval) = e; + yyval = e; } -#line 1582 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1504 "tars.tab.cpp" break; - case 18: -#line 160 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 18: /* enum_id: TARS_ENUM keyword */ +#line 160 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumeration name"); - (yyval) = (yyvsp[0]); + yyval = yyvsp[0]; } -#line 1592 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1514 "tars.tab.cpp" break; - case 19: -#line 171 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = (yyvsp[-1]); + case 19: /* enumerator_list: enumerator ',' enumerator_list */ +#line 171 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = yyvsp[-1]; } -#line 1600 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1522 "tars.tab.cpp" break; - case 20: -#line 175 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 20: /* enumerator_list: enumerator */ +#line 175 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1607 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1529 "tars.tab.cpp" break; - case 21: -#line 183 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 21: /* enumerator: TARS_IDENTIFIER */ +#line 183 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypeIdPtr tPtr = new TypeId(type, ident->v); tPtr->disableDefault(); EnumPtr e = EnumPtr::dynamicCast(g_parse->currentContainer()); assert(e); e->addMember(tPtr); - (yyval) = e; + yyval = e; } -#line 1622 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1544 "tars.tab.cpp" break; - case 22: -#line 194 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 22: /* enumerator: keyword */ +#line 194 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumerator"); } -#line 1631 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1553 "tars.tab.cpp" break; - case 23: -#line 199 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 23: /* enumerator: TARS_IDENTIFIER '=' const_initializer */ +#line 199 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[-2])); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); TypeIdPtr tPtr = new TypeId(type, ident->v); - ConstGrammarPtr sPtr = ConstGrammarPtr::dynamicCast((yyvsp[0])); + ConstGrammarPtr sPtr = ConstGrammarPtr::dynamicCast(yyvsp[0]); g_parse->checkConstValue(tPtr, sPtr->t); tPtr->setDefault(sPtr->v); EnumPtr e = EnumPtr::dynamicCast(g_parse->currentContainer()); assert(e); e->addMember(tPtr); - (yyval) = e; + yyval = e; } -#line 1648 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1570 "tars.tab.cpp" break; - case 24: -#line 212 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 24: /* enumerator: %empty */ +#line 212 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1655 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1577 "tars.tab.cpp" break; - case 25: -#line 220 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 25: /* @4: %empty */ +#line 220 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ContainerPtr c = g_parse->currentContainer(); NamespacePtr n = c->createNamespace(ident->v); if(n) { g_parse->pushContainer(n); - (yyval) = GrammarBasePtr::dynamicCast(n); + yyval = GrammarBasePtr::dynamicCast(n); } else { - (yyval) = 0; + yyval = 0; } } -#line 1674 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1596 "tars.tab.cpp" break; - case 26: -#line 235 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - if((yyvsp[-3])) + case 26: /* namespace_def: TARS_NAMESPACE TARS_IDENTIFIER @4 '{' definitions '}' */ +#line 235 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + if(yyvsp[-3]) { g_parse->popContainer(); - (yyval) = (yyvsp[-3]); + yyval = yyvsp[-3]; } else { - (yyval) = 0; + yyval = 0; } } -#line 1690 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1612 "tars.tab.cpp" break; - case 27: -#line 253 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[-1])); + case 27: /* $@5: %empty */ +#line 253 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-1]); StructPtr sp = StructPtr::dynamicCast(g_parse->findUserType(ident->v)); if(!sp) { @@ -1701,20 +1623,20 @@ yyparse (void) g_parse->setKeyStruct(sp); } -#line 1705 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1627 "tars.tab.cpp" break; - case 28: -#line 264 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 28: /* key_def: TARS_KEY '[' scoped_name ',' $@5 key_members ']' */ +#line 264 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1712 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1634 "tars.tab.cpp" break; - case 29: -#line 272 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 29: /* key_members: TARS_IDENTIFIER */ +#line 272 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); if(np) { @@ -1722,16 +1644,16 @@ yyparse (void) } else { - (yyval) = 0; + yyval = 0; } } -#line 1729 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1651 "tars.tab.cpp" break; - case 30: -#line 285 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 30: /* key_members: key_members ',' TARS_IDENTIFIER */ +#line 285 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); if(np) { @@ -1739,16 +1661,16 @@ yyparse (void) } else { - (yyval) = 0; + yyval = 0; } } -#line 1746 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1668 "tars.tab.cpp" break; - case 31: -#line 304 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 31: /* @6: %empty */ +#line 304 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); NamespacePtr c = NamespacePtr::dynamicCast(g_parse->currentContainer()); @@ -1756,100 +1678,100 @@ yyparse (void) if(cl) { g_parse->pushContainer(cl); - (yyval) = GrammarBasePtr::dynamicCast(cl); + yyval = GrammarBasePtr::dynamicCast(cl); } else { - (yyval) = 0; + yyval = 0; } } -#line 1767 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1689 "tars.tab.cpp" break; - case 32: -#line 321 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - if((yyvsp[-3])) + case 32: /* interface_def: interface_id @6 '{' interface_exports '}' */ +#line 321 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + if(yyvsp[-3]) { g_parse->popContainer(); - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[-3])); + yyval = GrammarBasePtr::dynamicCast(yyvsp[-3]); } else { - (yyval) = 0; + yyval = 0; } } -#line 1783 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1705 "tars.tab.cpp" break; - case 33: -#line 338 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = (yyvsp[0]); + case 33: /* interface_id: TARS_INTERFACE TARS_IDENTIFIER */ +#line 338 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = yyvsp[0]; } -#line 1791 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1713 "tars.tab.cpp" break; - case 34: -#line 342 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 34: /* interface_id: TARS_INTERFACE keyword */ +#line 342 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as interface name"); - (yyval) = (yyvsp[0]); + yyval = yyvsp[0]; } -#line 1801 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1723 "tars.tab.cpp" break; - case 35: -#line 353 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 35: /* interface_exports: interface_export ';' interface_exports */ +#line 353 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1808 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1730 "tars.tab.cpp" break; - case 36: -#line 356 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 36: /* interface_exports: error ';' interface_exports */ +#line 356 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1815 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1737 "tars.tab.cpp" break; - case 37: -#line 359 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 37: /* interface_exports: interface_export */ +#line 359 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("`;' missing after definition"); } -#line 1823 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1745 "tars.tab.cpp" break; - case 38: -#line 363 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 38: /* interface_exports: %empty */ +#line 363 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1830 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1752 "tars.tab.cpp" break; - case 40: -#line 377 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - if((yyvsp[-2])) + case 40: /* operation: operation_preamble parameters ')' */ +#line 377 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + if(yyvsp[-2]) { g_parse->popContainer(); - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[-2])); + yyval = GrammarBasePtr::dynamicCast(yyvsp[-2]); } else { - (yyval) = 0; + yyval = 0; } } -#line 1846 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1768 "tars.tab.cpp" break; - case 41: -#line 394 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - TypePtr returnType = TypePtr::dynamicCast((yyvsp[-1])); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 41: /* operation_preamble: return_type TARS_OP */ +#line 394 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); string name = ident->v; InterfacePtr cl = InterfacePtr::dynamicCast(g_parse->currentContainer()); if(cl) @@ -1858,40 +1780,40 @@ yyparse (void) if(op) { g_parse->pushContainer(op); - (yyval) = GrammarBasePtr::dynamicCast(op); + yyval = GrammarBasePtr::dynamicCast(op); } else { - (yyval) = 0; + yyval = 0; } } else { - (yyval) = 0; + yyval = 0; } } -#line 1874 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1796 "tars.tab.cpp" break; - case 43: -#line 424 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = 0; + case 43: /* return_type: TARS_VOID */ +#line 424 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = 0; } -#line 1882 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1804 "tars.tab.cpp" break; - case 44: -#line 434 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 44: /* parameters: %empty */ +#line 434 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 1889 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1811 "tars.tab.cpp" break; - case 45: -#line 437 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - TypeIdPtr tsp = TypeIdPtr::dynamicCast((yyvsp[0])); + case 45: /* parameters: type_id */ +#line 437 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); OperationPtr op = OperationPtr::dynamicCast(g_parse->currentContainer()); assert(op); @@ -1900,13 +1822,13 @@ yyparse (void) op->createParamDecl(tsp, false, false); } } -#line 1904 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1826 "tars.tab.cpp" break; - case 46: -#line 448 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - TypeIdPtr tsp = TypeIdPtr::dynamicCast((yyvsp[0])); + case 46: /* parameters: parameters ',' type_id */ +#line 448 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); OperationPtr op = OperationPtr::dynamicCast(g_parse->currentContainer()); assert(op); @@ -1915,14 +1837,14 @@ yyparse (void) op->createParamDecl(tsp, false, false); } } -#line 1919 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1841 "tars.tab.cpp" break; - case 47: -#line 459 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast((yyvsp[-1])); - TypeIdPtr tsp = TypeIdPtr::dynamicCast((yyvsp[0])); + case 47: /* parameters: out_qualifier type_id */ +#line 459 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); + TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); OperationPtr op = OperationPtr::dynamicCast(g_parse->currentContainer()); assert(op); @@ -1931,14 +1853,14 @@ yyparse (void) op->createParamDecl(tsp, isOutParam->v, false); } } -#line 1935 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1857 "tars.tab.cpp" break; - case 48: -#line 471 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast((yyvsp[-1])); - TypeIdPtr tsp = TypeIdPtr::dynamicCast((yyvsp[0])); + case 48: /* parameters: parameters ',' out_qualifier type_id */ +#line 471 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); + TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); OperationPtr op = OperationPtr::dynamicCast(g_parse->currentContainer()); assert(op); @@ -1947,14 +1869,14 @@ yyparse (void) op->createParamDecl(tsp, isOutParam->v, false); } } -#line 1951 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1873 "tars.tab.cpp" break; - case 49: -#line 483 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast((yyvsp[-1])); - TypeIdPtr tsp = TypeIdPtr::dynamicCast((yyvsp[0])); + case 49: /* parameters: routekey_qualifier type_id */ +#line 483 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); + TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); OperationPtr op = OperationPtr::dynamicCast(g_parse->currentContainer()); assert(op); @@ -1963,14 +1885,14 @@ yyparse (void) op->createParamDecl(tsp, false, isRouteKeyParam->v); } } -#line 1967 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1889 "tars.tab.cpp" break; - case 50: -#line 495 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast((yyvsp[-1])); - TypeIdPtr tsp = TypeIdPtr::dynamicCast((yyvsp[0])); + case 50: /* parameters: parameters ',' routekey_qualifier type_id */ +#line 495 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); + TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); OperationPtr op = OperationPtr::dynamicCast(g_parse->currentContainer()); assert(op); @@ -1979,49 +1901,49 @@ yyparse (void) op->createParamDecl(tsp, false, isRouteKeyParam->v); } } -#line 1983 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1905 "tars.tab.cpp" break; - case 51: -#line 507 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 51: /* parameters: out_qualifier */ +#line 507 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("'out' must be defined with a type"); } -#line 1991 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1913 "tars.tab.cpp" break; - case 52: -#line 511 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 52: /* parameters: routekey_qualifier */ +#line 511 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("'routekey' must be defined with a type"); } -#line 1999 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1921 "tars.tab.cpp" break; - case 53: -#line 520 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 53: /* routekey_qualifier: TARS_ROUTE_KEY */ +#line 520 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ BoolGrammarPtr routekey = new BoolGrammar; routekey->v = true; - (yyval) = GrammarBasePtr::dynamicCast(routekey); + yyval = GrammarBasePtr::dynamicCast(routekey); } -#line 2009 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1931 "tars.tab.cpp" break; - case 54: -#line 531 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 54: /* out_qualifier: TARS_OUT */ +#line 531 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ BoolGrammarPtr out = new BoolGrammar; out->v = true; - (yyval) = GrammarBasePtr::dynamicCast(out); + yyval = GrammarBasePtr::dynamicCast(out); } -#line 2019 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1941 "tars.tab.cpp" break; - case 55: -#line 542 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 55: /* @7: %empty */ +#line 542 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(np) { @@ -2029,11 +1951,11 @@ yyparse (void) if(sp) { g_parse->pushContainer(sp); - (yyval) = GrammarBasePtr::dynamicCast(sp); + yyval = GrammarBasePtr::dynamicCast(sp); } else { - (yyval) = 0; + yyval = 0; } } else @@ -2041,280 +1963,280 @@ yyparse (void) g_parse->error("struct '" + ident->v + "' must definition in namespace"); } } -#line 2045 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1967 "tars.tab.cpp" break; - case 56: -#line 564 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - if((yyvsp[-3])) + case 56: /* struct_def: struct_id @7 '{' struct_exports '}' */ +#line 564 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + if(yyvsp[-3]) { g_parse->popContainer(); } - (yyval) = (yyvsp[-3]); + yyval = yyvsp[-3]; - StructPtr st = StructPtr::dynamicCast((yyval)); + StructPtr st = StructPtr::dynamicCast(yyval); assert(st); if(st->getAllMemberPtr().size() == 0) { g_parse->error("struct `" + st->getSid() + "' must have at least one member"); } } -#line 2064 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1986 "tars.tab.cpp" break; - case 57: -#line 584 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = (yyvsp[0]); + case 57: /* struct_id: TARS_STRUCT TARS_IDENTIFIER */ +#line 584 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = yyvsp[0]; } -#line 2072 "tars.tab.cpp" /* yacc.c:1646 */ +#line 1994 "tars.tab.cpp" break; - case 58: -#line 588 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 58: /* struct_id: TARS_STRUCT keyword */ +#line 588 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as struct name"); } -#line 2082 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2004 "tars.tab.cpp" break; - case 59: -#line 594 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 59: /* struct_id: TARS_STRUCT error */ +#line 594 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("abstract declarator '' used as declaration"); } -#line 2090 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2012 "tars.tab.cpp" break; - case 60: -#line 603 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 60: /* struct_exports: data_member ';' struct_exports */ +#line 603 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2098 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2020 "tars.tab.cpp" break; - case 61: -#line 607 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 61: /* struct_exports: data_member */ +#line 607 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("';' missing after definition"); } -#line 2106 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2028 "tars.tab.cpp" break; - case 62: -#line 611 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 62: /* struct_exports: %empty */ +#line 611 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2113 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2035 "tars.tab.cpp" break; - case 63: -#line 621 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[0])); + case 63: /* data_member: struct_type_id */ +#line 621 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } -#line 2121 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2043 "tars.tab.cpp" break; - case 64: -#line 630 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 64: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id */ +#line 630 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) { - IntergerGrammarPtr iPtr = IntergerGrammarPtr::dynamicCast((yyvsp[-2])); + IntergerGrammarPtr iPtr = IntergerGrammarPtr::dynamicCast(yyvsp[-2]); g_parse->checkTag(iPtr->v); - TypeIdPtr tPtr = TypeIdPtr::dynamicCast((yyvsp[0])); + TypeIdPtr tPtr = TypeIdPtr::dynamicCast(yyvsp[0]); tPtr->setRequire(iPtr->v); np->addTypeId(tPtr); - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[0])); + yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } else { - (yyval) = 0; + yyval = 0; } } -#line 2143 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2065 "tars.tab.cpp" break; - case 65: -#line 648 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 65: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id '=' const_initializer */ +#line 648 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) { - IntergerGrammarPtr iPtr = IntergerGrammarPtr::dynamicCast((yyvsp[-4])); + IntergerGrammarPtr iPtr = IntergerGrammarPtr::dynamicCast(yyvsp[-4]); g_parse->checkTag(iPtr->v); - TypeIdPtr tPtr = TypeIdPtr::dynamicCast((yyvsp[-2])); - ConstGrammarPtr sPtr = ConstGrammarPtr::dynamicCast((yyvsp[0])); + TypeIdPtr tPtr = TypeIdPtr::dynamicCast(yyvsp[-2]); + ConstGrammarPtr sPtr = ConstGrammarPtr::dynamicCast(yyvsp[0]); g_parse->checkConstValue(tPtr, sPtr->t); tPtr->setRequire(iPtr->v); tPtr->setDefault(sPtr->v); np->addTypeId(tPtr); - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[-2])); + yyval = GrammarBasePtr::dynamicCast(yyvsp[-2]); } else { - (yyval) = 0; + yyval = 0; } } -#line 2169 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2091 "tars.tab.cpp" break; - case 66: -#line 670 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 66: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id '=' const_initializer */ +#line 670 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) { - IntergerGrammarPtr iPtr = IntergerGrammarPtr::dynamicCast((yyvsp[-4])); + IntergerGrammarPtr iPtr = IntergerGrammarPtr::dynamicCast(yyvsp[-4]); g_parse->checkTag(iPtr->v); - TypeIdPtr tPtr = TypeIdPtr::dynamicCast((yyvsp[-2])); - ConstGrammarPtr sPtr = ConstGrammarPtr::dynamicCast((yyvsp[0])); + TypeIdPtr tPtr = TypeIdPtr::dynamicCast(yyvsp[-2]); + ConstGrammarPtr sPtr = ConstGrammarPtr::dynamicCast(yyvsp[0]); g_parse->checkConstValue(tPtr, sPtr->t); tPtr->setOptional(iPtr->v); tPtr->setDefault(sPtr->v); np->addTypeId(tPtr); - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[-2])); + yyval = GrammarBasePtr::dynamicCast(yyvsp[-2]); } else { - (yyval) = 0; + yyval = 0; } } -#line 2195 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2117 "tars.tab.cpp" break; - case 67: -#line 692 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 67: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id */ +#line 692 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) { - IntergerGrammarPtr iPtr = IntergerGrammarPtr::dynamicCast((yyvsp[-2])); + IntergerGrammarPtr iPtr = IntergerGrammarPtr::dynamicCast(yyvsp[-2]); g_parse->checkTag(iPtr->v); - TypeIdPtr tPtr = TypeIdPtr::dynamicCast((yyvsp[0])); + TypeIdPtr tPtr = TypeIdPtr::dynamicCast(yyvsp[0]); tPtr->setOptional(iPtr->v); np->addTypeId(tPtr); - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[0])); + yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } else { - (yyval) = 0; + yyval = 0; } } -#line 2216 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2138 "tars.tab.cpp" break; - case 68: -#line 709 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 68: /* struct_type_id: TARS_REQUIRE type_id */ +#line 709 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("struct member need 'tag'"); } -#line 2224 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2146 "tars.tab.cpp" break; - case 69: -#line 713 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 69: /* struct_type_id: TARS_OPTIONAL type_id */ +#line 713 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("struct member need 'tag'"); } -#line 2232 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2154 "tars.tab.cpp" break; - case 70: -#line 717 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 70: /* struct_type_id: TARS_CONST_INTEGER type_id */ +#line 717 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("struct member need 'require' or 'optional'"); } -#line 2240 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2162 "tars.tab.cpp" break; - case 71: -#line 721 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 71: /* struct_type_id: type_id */ +#line 721 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("struct member need 'tag' or 'require' or 'optional'"); } -#line 2248 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2170 "tars.tab.cpp" break; - case 72: -#line 730 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - IntergerGrammarPtr intVal = IntergerGrammarPtr::dynamicCast((yyvsp[0])); + case 72: /* const_initializer: TARS_CONST_INTEGER */ +#line 730 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + IntergerGrammarPtr intVal = IntergerGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; sstr << intVal->v; ConstGrammarPtr c = new ConstGrammar(); c->t = ConstGrammar::VALUE; c->v = sstr.str(); - (yyval) = c; + yyval = c; } -#line 2262 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2184 "tars.tab.cpp" break; - case 73: -#line 740 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - FloatGrammarPtr floatVal = FloatGrammarPtr::dynamicCast((yyvsp[0])); + case 73: /* const_initializer: TARS_CONST_FLOAT */ +#line 740 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + FloatGrammarPtr floatVal = FloatGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; sstr << floatVal->v; ConstGrammarPtr c = new ConstGrammar(); c->t = ConstGrammar::VALUE; c->v = sstr.str(); - (yyval) = c; + yyval = c; } -#line 2276 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2198 "tars.tab.cpp" break; - case 74: -#line 750 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 74: /* const_initializer: TARS_STRING_LITERAL */ +#line 750 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); c->t = ConstGrammar::STRING; c->v = ident->v; - (yyval) = c; + yyval = c; } -#line 2288 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2210 "tars.tab.cpp" break; - case 75: -#line 758 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 75: /* const_initializer: TARS_FALSE */ +#line 758 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); c->t = ConstGrammar::BOOL; c->v = ident->v; - (yyval) = c; + yyval = c; } -#line 2300 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2222 "tars.tab.cpp" break; - case 76: -#line 766 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 76: /* const_initializer: TARS_TRUE */ +#line 766 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); c->t = ConstGrammar::BOOL; c->v = ident->v; - (yyval) = c; + yyval = c; } -#line 2312 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2234 "tars.tab.cpp" break; - case 77: -#line 774 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 77: /* const_initializer: TARS_IDENTIFIER */ +#line 774 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); if (g_parse->checkEnum(ident->v) == false) { @@ -2323,17 +2245,17 @@ yyparse (void) ConstGrammarPtr c = new ConstGrammar(); c->t = ConstGrammar::ENUM; c->v = ident->v; - (yyval) = c; + yyval = c; } -#line 2329 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2251 "tars.tab.cpp" break; - case 78: -#line 787 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 78: /* const_initializer: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ +#line 787 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ - StringGrammarPtr scoped = StringGrammarPtr::dynamicCast((yyvsp[-2])); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); if (g_parse->checkEnum(ident->v) == false) { @@ -2342,511 +2264,512 @@ yyparse (void) ConstGrammarPtr c = new ConstGrammar(); c->t = ConstGrammar::ENUM; c->v = scoped->v + "::" + ident->v; - (yyval) = c; + yyval = c; } -#line 2348 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2270 "tars.tab.cpp" break; - case 79: -#line 807 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 79: /* const_def: TARS_CONST type_id '=' const_initializer */ +#line 807 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!np) { g_parse->error("const type must define in namespace"); } - TypeIdPtr t = TypeIdPtr::dynamicCast((yyvsp[-2])); - ConstGrammarPtr c = ConstGrammarPtr::dynamicCast((yyvsp[0])); + TypeIdPtr t = TypeIdPtr::dynamicCast(yyvsp[-2]); + ConstGrammarPtr c = ConstGrammarPtr::dynamicCast(yyvsp[0]); ConstPtr cPtr = np->createConst(t, c); - (yyval) = cPtr; + yyval = cPtr; } -#line 2365 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2287 "tars.tab.cpp" break; - case 80: -#line 825 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - TypePtr type = TypePtr::dynamicCast((yyvsp[-1])); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 80: /* type_id: type TARS_IDENTIFIER */ +#line 825 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypeIdPtr typeIdPtr = new TypeId(type, ident->v); - (yyval) = GrammarBasePtr::dynamicCast(typeIdPtr); + yyval = GrammarBasePtr::dynamicCast(typeIdPtr); } -#line 2378 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2300 "tars.tab.cpp" break; - case 81: -#line 834 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - TypePtr type = g_parse->createVector(TypePtr::dynamicCast((yyvsp[-4]))); - IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast((yyvsp[-1])); + case 81: /* type_id: type TARS_IDENTIFIER '[' TARS_CONST_INTEGER ']' */ +#line 834 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-4])); + IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast(yyvsp[-1]); g_parse->checkArrayVaid(type,iPtrSize->v); type->setArray(iPtrSize->v); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[-3])); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-3]); TypeIdPtr typeIdPtr = new TypeId(type, ident->v); - (yyval) = GrammarBasePtr::dynamicCast(typeIdPtr); + yyval = GrammarBasePtr::dynamicCast(typeIdPtr); } -#line 2392 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2314 "tars.tab.cpp" break; - case 82: -#line 844 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - TypePtr type = g_parse->createVector(TypePtr::dynamicCast((yyvsp[-2]))); + case 82: /* type_id: type '*' TARS_IDENTIFIER */ +#line 844 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-2])); //IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast($4); g_parse->checkPointerVaid(type); type->setPointer(true); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypeIdPtr typeIdPtr = new TypeId(type, ident->v); - (yyval) = GrammarBasePtr::dynamicCast(typeIdPtr); + yyval = GrammarBasePtr::dynamicCast(typeIdPtr); } -#line 2406 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2328 "tars.tab.cpp" break; - case 83: -#line 854 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - TypePtr type = TypePtr::dynamicCast((yyvsp[-3])); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[-2])); + case 83: /* type_id: type TARS_IDENTIFIER ':' TARS_CONST_INTEGER */ +#line 854 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + TypePtr type = TypePtr::dynamicCast(yyvsp[-3]); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); TypeIdPtr typeIdPtr = new TypeId(type, ident->v); - IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast((yyvsp[-1])); + IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast(yyvsp[-1]); g_parse->checkArrayVaid(type,iPtrSize->v); - (yyval) = GrammarBasePtr::dynamicCast(typeIdPtr); + yyval = GrammarBasePtr::dynamicCast(typeIdPtr); } -#line 2419 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2341 "tars.tab.cpp" break; - case 84: -#line 863 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 84: /* type_id: type keyword */ +#line 863 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as data member name"); } -#line 2428 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2350 "tars.tab.cpp" break; - case 85: -#line 868 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 85: /* type_id: type */ +#line 868 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("missing data member name"); } -#line 2436 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2358 "tars.tab.cpp" break; - case 86: -#line 872 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 86: /* type_id: error */ +#line 872 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("unkown type"); } -#line 2444 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2366 "tars.tab.cpp" break; - case 87: -#line 881 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 87: /* type: type_no ':' TARS_CONST_INTEGER */ +#line 881 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ - TypePtr type = TypePtr::dynamicCast((yyvsp[-2])); - IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast((yyvsp[0])); + TypePtr type = TypePtr::dynamicCast(yyvsp[-2]); + IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast(yyvsp[0]); g_parse->checkArrayVaid(type,iPtrSize->v); type->setArray(iPtrSize->v); - (yyval) = type; + yyval = type; } -#line 2457 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2379 "tars.tab.cpp" break; - case 88: -#line 890 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = (yyvsp[0]); + case 88: /* type: type_no */ +#line 890 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = yyvsp[0]; } -#line 2465 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2387 "tars.tab.cpp" break; - case 89: -#line 894 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 89: /* type: type_no ':' error */ +#line 894 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("array missing size"); } -#line 2473 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2395 "tars.tab.cpp" break; - case 90: -#line 903 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindBool); + case 90: /* type_no: TARS_BOOL */ +#line 903 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindBool); } -#line 2481 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2403 "tars.tab.cpp" break; - case 91: -#line 907 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindByte); + case 91: /* type_no: TARS_BYTE */ +#line 907 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindByte); } -#line 2489 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2411 "tars.tab.cpp" break; - case 92: -#line 911 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindShort,true); + case 92: /* type_no: TARS_UNSIGNED TARS_BYTE */ +#line 911 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindShort,true); } -#line 2497 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2419 "tars.tab.cpp" break; - case 93: -#line 915 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindShort); + case 93: /* type_no: TARS_SHORT */ +#line 915 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindShort); } -#line 2505 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2427 "tars.tab.cpp" break; - case 94: -#line 919 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindInt,true); + case 94: /* type_no: TARS_UNSIGNED TARS_SHORT */ +#line 919 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindInt,true); } -#line 2513 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2435 "tars.tab.cpp" break; - case 95: -#line 923 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindInt); + case 95: /* type_no: TARS_INT */ +#line 923 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindInt); } -#line 2521 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2443 "tars.tab.cpp" break; - case 96: -#line 927 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindLong,true); + case 96: /* type_no: TARS_UNSIGNED TARS_INT */ +#line 927 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindLong,true); } -#line 2529 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2451 "tars.tab.cpp" break; - case 97: -#line 931 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindLong); + case 97: /* type_no: TARS_LONG */ +#line 931 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindLong); } -#line 2537 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2459 "tars.tab.cpp" break; - case 98: -#line 935 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindFloat); + case 98: /* type_no: TARS_FLOAT */ +#line 935 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindFloat); } -#line 2545 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2467 "tars.tab.cpp" break; - case 99: -#line 939 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindDouble); + case 99: /* type_no: TARS_DOUBLE */ +#line 939 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindDouble); } -#line 2553 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2475 "tars.tab.cpp" break; - case 100: -#line 943 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = g_parse->createBuiltin(Builtin::KindString); + case 100: /* type_no: TARS_STRING */ +#line 943 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = g_parse->createBuiltin(Builtin::KindString); } -#line 2561 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2483 "tars.tab.cpp" break; - case 101: -#line 947 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[0])); + case 101: /* type_no: vector */ +#line 947 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } -#line 2569 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2491 "tars.tab.cpp" break; - case 102: -#line 951 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = GrammarBasePtr::dynamicCast((yyvsp[0])); + case 102: /* type_no: map */ +#line 951 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } -#line 2577 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2499 "tars.tab.cpp" break; - case 103: -#line 955 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 103: /* type_no: scoped_name */ +#line 955 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypePtr sp = g_parse->findUserType(ident->v); if(sp) { - (yyval) = GrammarBasePtr::dynamicCast(sp); + yyval = GrammarBasePtr::dynamicCast(sp); } else { g_parse->error("'" + ident->v + "' undefined!"); } } -#line 2594 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2516 "tars.tab.cpp" break; - case 104: -#line 973 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = GrammarBasePtr::dynamicCast(g_parse->createVector(TypePtr::dynamicCast((yyvsp[-1])))); + case 104: /* vector: TARS_VECTOR '<' type '>' */ +#line 973 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = GrammarBasePtr::dynamicCast(g_parse->createVector(TypePtr::dynamicCast(yyvsp[-1]))); } -#line 2602 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2524 "tars.tab.cpp" break; - case 105: -#line 977 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 105: /* vector: TARS_VECTOR '<' error */ +#line 977 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("vector error"); } -#line 2610 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2532 "tars.tab.cpp" break; - case 106: -#line 981 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 106: /* vector: TARS_VECTOR '<' type error */ +#line 981 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("vector missing '>'"); } -#line 2618 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2540 "tars.tab.cpp" break; - case 107: -#line 985 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 107: /* vector: TARS_VECTOR error */ +#line 985 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("vector missing type"); } -#line 2626 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2548 "tars.tab.cpp" break; - case 108: -#line 994 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - (yyval) = GrammarBasePtr::dynamicCast(g_parse->createMap(TypePtr::dynamicCast((yyvsp[-3])), TypePtr::dynamicCast((yyvsp[-1])))); + case 108: /* map: TARS_MAP '<' type ',' type '>' */ +#line 994 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + yyval = GrammarBasePtr::dynamicCast(g_parse->createMap(TypePtr::dynamicCast(yyvsp[-3]), TypePtr::dynamicCast(yyvsp[-1]))); } -#line 2634 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2556 "tars.tab.cpp" break; - case 109: -#line 998 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 109: /* map: TARS_MAP '<' error */ +#line 998 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ g_parse->error("map error"); } -#line 2642 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2564 "tars.tab.cpp" break; - case 110: -#line 1007 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 110: /* scoped_name: TARS_IDENTIFIER */ +#line 1007 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2649 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2571 "tars.tab.cpp" break; - case 111: -#line 1010 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 111: /* scoped_name: TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ +#line 1010 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ident->v = "::" + ident->v; - (yyval) = GrammarBasePtr::dynamicCast(ident); + yyval = GrammarBasePtr::dynamicCast(ident); } -#line 2659 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2581 "tars.tab.cpp" break; - case 112: -#line 1016 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { - StringGrammarPtr scoped = StringGrammarPtr::dynamicCast((yyvsp[-2])); - StringGrammarPtr ident = StringGrammarPtr::dynamicCast((yyvsp[0])); + case 112: /* scoped_name: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ +#line 1016 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ + StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); + StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); scoped->v += "::"; scoped->v += ident->v; - (yyval) = GrammarBasePtr::dynamicCast(scoped); + yyval = GrammarBasePtr::dynamicCast(scoped); } -#line 2671 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2593 "tars.tab.cpp" break; - case 113: -#line 1029 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 113: /* keyword: TARS_STRUCT */ +#line 1029 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2678 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2600 "tars.tab.cpp" break; - case 114: -#line 1032 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 114: /* keyword: TARS_VOID */ +#line 1032 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2685 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2607 "tars.tab.cpp" break; - case 115: -#line 1035 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 115: /* keyword: TARS_BOOL */ +#line 1035 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2692 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2614 "tars.tab.cpp" break; - case 116: -#line 1038 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 116: /* keyword: TARS_BYTE */ +#line 1038 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2699 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2621 "tars.tab.cpp" break; - case 117: -#line 1041 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 117: /* keyword: TARS_SHORT */ +#line 1041 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2706 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2628 "tars.tab.cpp" break; - case 118: -#line 1044 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 118: /* keyword: TARS_INT */ +#line 1044 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2713 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2635 "tars.tab.cpp" break; - case 119: -#line 1047 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 119: /* keyword: TARS_FLOAT */ +#line 1047 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2720 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2642 "tars.tab.cpp" break; - case 120: -#line 1050 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 120: /* keyword: TARS_DOUBLE */ +#line 1050 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2727 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2649 "tars.tab.cpp" break; - case 121: -#line 1053 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 121: /* keyword: TARS_STRING */ +#line 1053 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2734 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2656 "tars.tab.cpp" break; - case 122: -#line 1056 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 122: /* keyword: TARS_VECTOR */ +#line 1056 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2741 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2663 "tars.tab.cpp" break; - case 123: -#line 1059 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 123: /* keyword: TARS_KEY */ +#line 1059 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2748 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2670 "tars.tab.cpp" break; - case 124: -#line 1062 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 124: /* keyword: TARS_MAP */ +#line 1062 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2755 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2677 "tars.tab.cpp" break; - case 125: -#line 1065 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 125: /* keyword: TARS_NAMESPACE */ +#line 1065 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2762 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2684 "tars.tab.cpp" break; - case 126: -#line 1068 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 126: /* keyword: TARS_INTERFACE */ +#line 1068 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2769 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2691 "tars.tab.cpp" break; - case 127: -#line 1071 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 127: /* keyword: TARS_OUT */ +#line 1071 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2776 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2698 "tars.tab.cpp" break; - case 128: -#line 1074 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 128: /* keyword: TARS_REQUIRE */ +#line 1074 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2783 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2705 "tars.tab.cpp" break; - case 129: -#line 1077 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 129: /* keyword: TARS_OPTIONAL */ +#line 1077 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2790 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2712 "tars.tab.cpp" break; - case 130: -#line 1080 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 130: /* keyword: TARS_CONST_INTEGER */ +#line 1080 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2797 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2719 "tars.tab.cpp" break; - case 131: -#line 1083 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 131: /* keyword: TARS_CONST_FLOAT */ +#line 1083 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2804 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2726 "tars.tab.cpp" break; - case 132: -#line 1086 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 132: /* keyword: TARS_FALSE */ +#line 1086 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2811 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2733 "tars.tab.cpp" break; - case 133: -#line 1089 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 133: /* keyword: TARS_TRUE */ +#line 1089 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2818 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2740 "tars.tab.cpp" break; - case 134: -#line 1092 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 134: /* keyword: TARS_STRING_LITERAL */ +#line 1092 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2825 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2747 "tars.tab.cpp" break; - case 135: -#line 1095 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 135: /* keyword: TARS_CONST */ +#line 1095 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2832 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2754 "tars.tab.cpp" break; - case 136: -#line 1098 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 136: /* keyword: TARS_ENUM */ +#line 1098 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2839 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2761 "tars.tab.cpp" break; - case 137: -#line 1101 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1646 */ - { + case 137: /* keyword: TARS_UNSIGNED */ +#line 1101 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +{ } -#line 2846 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2768 "tars.tab.cpp" break; -#line 2850 "tars.tab.cpp" /* yacc.c:1646 */ +#line 2772 "tars.tab.cpp" + default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -2860,25 +2783,23 @@ yyparse (void) case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; - YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; + { + const int yylhs = yyr1[yyn] - YYNTOKENS; + const int yyi = yypgoto[yylhs] + *yyssp; + yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp + ? yytable[yyi] + : yydefgoto[yylhs]); + } goto yynewstate; @@ -2889,50 +2810,14 @@ yyparse (void) yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - + yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; -#if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); -#else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyssp, yytoken) - { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - yyerror (yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; - } -# undef YYSYNTAX_ERROR -#endif } - - if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an @@ -2961,12 +2846,10 @@ yyparse (void) | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -2983,13 +2866,14 @@ yyparse (void) yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ + /* Pop stack until we find a state that shifts the error token. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + yyn += YYSYMBOL_YYerror; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) { yyn = yytable[yyn]; if (0 < yyn) @@ -3003,7 +2887,7 @@ yyparse (void) yydestruct ("Error: popping", - yystos[yystate], yyvsp); + YY_ACCESSING_SYMBOL (yystate), yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -3015,7 +2899,7 @@ yyparse (void) /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -3028,6 +2912,7 @@ yyparse (void) yyresult = 0; goto yyreturn; + /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -3035,16 +2920,21 @@ yyparse (void) yyresult = 1; goto yyreturn; -#if !defined yyoverflow || YYERROR_VERBOSE + +#if !defined yyoverflow /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; - /* Fall through. */ + goto yyreturn; #endif + +/*-------------------------------------------------------. +| yyreturn -- parsing is finished, clean up and return. | +`-------------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -3061,20 +2951,18 @@ yyparse (void) while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); + YY_ACCESSING_SYMBOL (+*yyssp), yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif + return yyresult; } -#line 1105 "/root/boat/TarsCpp/tools/tarsgrammar/tars.y" /* yacc.c:1906 */ + +#line 1105 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" diff --git a/tools/tarsparse/tars.tab.hpp b/tools/tarsparse/tars.tab.hpp index 547e0174..7a3f80ae 100644 --- a/tools/tarsparse/tars.tab.hpp +++ b/tools/tarsparse/tars.tab.hpp @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.7.6. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, + 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 @@ -15,7 +16,7 @@ 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 . */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -30,6 +31,10 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ + #ifndef YY_YY_TARS_TAB_HPP_INCLUDED # define YY_YY_TARS_TAB_HPP_INCLUDED /* Debug traces. */ @@ -40,43 +45,48 @@ extern int yydebug; #endif -/* Token type. */ +/* Token kinds. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { - TARS_VOID = 258, - TARS_STRUCT = 259, - TARS_BOOL = 260, - TARS_BYTE = 261, - TARS_SHORT = 262, - TARS_INT = 263, - TARS_DOUBLE = 264, - TARS_FLOAT = 265, - TARS_LONG = 266, - TARS_STRING = 267, - TARS_VECTOR = 268, - TARS_MAP = 269, - TARS_NAMESPACE = 270, - TARS_INTERFACE = 271, - TARS_IDENTIFIER = 272, - TARS_OUT = 273, - TARS_OP = 274, - TARS_KEY = 275, - TARS_ROUTE_KEY = 276, - TARS_REQUIRE = 277, - TARS_OPTIONAL = 278, - TARS_CONST_INTEGER = 279, - TARS_CONST_FLOAT = 280, - TARS_FALSE = 281, - TARS_TRUE = 282, - TARS_STRING_LITERAL = 283, - TARS_SCOPE_DELIMITER = 284, - TARS_CONST = 285, - TARS_ENUM = 286, - TARS_UNSIGNED = 287, - BAD_CHAR = 288 + YYEMPTY = -2, + YYEOF = 0, /* "end of file" */ + YYerror = 256, /* error */ + YYUNDEF = 257, /* "invalid token" */ + TARS_VOID = 258, /* TARS_VOID */ + TARS_STRUCT = 259, /* TARS_STRUCT */ + TARS_BOOL = 260, /* TARS_BOOL */ + TARS_BYTE = 261, /* TARS_BYTE */ + TARS_SHORT = 262, /* TARS_SHORT */ + TARS_INT = 263, /* TARS_INT */ + TARS_DOUBLE = 264, /* TARS_DOUBLE */ + TARS_FLOAT = 265, /* TARS_FLOAT */ + TARS_LONG = 266, /* TARS_LONG */ + TARS_STRING = 267, /* TARS_STRING */ + TARS_VECTOR = 268, /* TARS_VECTOR */ + TARS_MAP = 269, /* TARS_MAP */ + TARS_NAMESPACE = 270, /* TARS_NAMESPACE */ + TARS_INTERFACE = 271, /* TARS_INTERFACE */ + TARS_IDENTIFIER = 272, /* TARS_IDENTIFIER */ + TARS_OUT = 273, /* TARS_OUT */ + TARS_OP = 274, /* TARS_OP */ + TARS_KEY = 275, /* TARS_KEY */ + TARS_ROUTE_KEY = 276, /* TARS_ROUTE_KEY */ + TARS_REQUIRE = 277, /* TARS_REQUIRE */ + TARS_OPTIONAL = 278, /* TARS_OPTIONAL */ + TARS_CONST_INTEGER = 279, /* TARS_CONST_INTEGER */ + TARS_CONST_FLOAT = 280, /* TARS_CONST_FLOAT */ + TARS_FALSE = 281, /* TARS_FALSE */ + TARS_TRUE = 282, /* TARS_TRUE */ + TARS_STRING_LITERAL = 283, /* TARS_STRING_LITERAL */ + TARS_SCOPE_DELIMITER = 284, /* TARS_SCOPE_DELIMITER */ + TARS_CONST = 285, /* TARS_CONST */ + TARS_ENUM = 286, /* TARS_ENUM */ + TARS_UNSIGNED = 287, /* TARS_UNSIGNED */ + BAD_CHAR = 288 /* BAD_CHAR */ }; + typedef enum yytokentype yytoken_kind_t; #endif /* Value type. */ From cf0c240f954f2176807e314727ecb00c086981d4 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 14 Nov 2023 09:53:09 +0800 Subject: [PATCH 04/81] fix tars-tools.cmake set TARS_SSL/TARS_MYSQL/TARS_HTTP2 depends tarscpp compiler parameters --- .gitignore | 2 ++ servant/CMakeLists.txt | 5 ++++- .../{tars-tools.cmake => tars-tools.cmake.in} | 16 +++++++--------- 3 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 .gitignore rename servant/makefile/{tars-tools.cmake => tars-tools.cmake.in} (98%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..b456bebb --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +servant/makefile/tars-tools.cmake +.idea \ No newline at end of file diff --git a/servant/CMakeLists.txt b/servant/CMakeLists.txt index 4238b6e8..eec543f4 100644 --- a/servant/CMakeLists.txt +++ b/servant/CMakeLists.txt @@ -61,6 +61,8 @@ macro(complice_tars OUT_DEPENDS_LIST HEADER INCLUDE) endmacro() +configure_file(${PROJECT_SOURCE_DIR}/makefile/tars-tools.cmake.in ${PROJECT_SOURCE_DIR}/makefile/tars-tools.cmake @ONLY) + add_subdirectory(protocol/servant) add_subdirectory(protocol/framework) add_subdirectory(tup) @@ -73,5 +75,6 @@ install(DIRECTORY jmem DESTINATION include) install(DIRECTORY script DESTINATION . PATTERN "*.sh" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE) -install(DIRECTORY makefile DESTINATION .) +#install(DIRECTORY makefile DESTINATION . EXCLUDE tars-tools.cmake.in ) +install(DIRECTORY makefile DESTINATION . PATTERN tars-tools.cmake.in EXCLUDE) diff --git a/servant/makefile/tars-tools.cmake b/servant/makefile/tars-tools.cmake.in similarity index 98% rename from servant/makefile/tars-tools.cmake rename to servant/makefile/tars-tools.cmake.in index 9fad7b57..fcd68397 100755 --- a/servant/makefile/tars-tools.cmake +++ b/servant/makefile/tars-tools.cmake.in @@ -3,15 +3,13 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -if(WIN32) - set(TARS2CPP "c:/tars/cpp/tools/tars2cpp.exe" CACHE STRING "set tars2cpp path") - set(TARSMERGE "c:/tars/cpp/tools/tarsmerge" CACHE STRING "set tarsmerge path") - set(TARS_PATH "c:/tars/cpp") -else() - set(TARS2CPP "/usr/local/tars/cpp/tools/tars2cpp" CACHE STRING "set tars2cpp path") - set(TARSMERGE "/usr/local/tars/cpp/tools/tarsmerge" CACHE STRING "set tarsmerge path") - set(TARS_PATH "/usr/local/tars/cpp") -endif() +set(TARS2CPP "@CMAKE_INSTALL_PREFIX@/tars2cpp.exe" CACHE STRING "set tars2cpp path") +set(TARSMERGE "@CMAKE_INSTALL_PREFIX@/tools/tarsmerge" CACHE STRING "set tarsmerge path") +set(TARS_PATH "@CMAKE_INSTALL_PREFIX@") + +optional(TARS_MYSQL "open mysql support" @TARS_MYSQL@) +optional(TARS_SSL "open ssl support" @TARS_SSL@) +optional(TARS_HTTP2 "open http2 support" @TARS_HTTP2@) set(TARS_INC "${TARS_PATH}/include") set(TARS_LIB_DIR "${TARS_PATH}/lib" ) From dfbb8943a2e1375ce018a1233e71c50abff5123c Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 14 Nov 2023 10:00:41 +0800 Subject: [PATCH 05/81] fix tars-tools.cmake.in --- servant/makefile/tars-tools.cmake.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/servant/makefile/tars-tools.cmake.in b/servant/makefile/tars-tools.cmake.in index fcd68397..8d9ab050 100755 --- a/servant/makefile/tars-tools.cmake.in +++ b/servant/makefile/tars-tools.cmake.in @@ -7,9 +7,9 @@ set(TARS2CPP "@CMAKE_INSTALL_PREFIX@/tars2cpp.exe" CACHE STRING "set tars2cpp pa set(TARSMERGE "@CMAKE_INSTALL_PREFIX@/tools/tarsmerge" CACHE STRING "set tarsmerge path") set(TARS_PATH "@CMAKE_INSTALL_PREFIX@") -optional(TARS_MYSQL "open mysql support" @TARS_MYSQL@) -optional(TARS_SSL "open ssl support" @TARS_SSL@) -optional(TARS_HTTP2 "open http2 support" @TARS_HTTP2@) +option(TARS_MYSQL "open mysql support" @TARS_MYSQL@) +option(TARS_SSL "open ssl support" @TARS_SSL@) +option(TARS_HTTP2 "open http2 support" @TARS_HTTP2@) set(TARS_INC "${TARS_PATH}/include") set(TARS_LIB_DIR "${TARS_PATH}/lib" ) From 83630b5bea837bc543e09ab03cac5981e0294bb8 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 14 Nov 2023 10:35:53 +0800 Subject: [PATCH 06/81] fix tars-tools.cmake.in add: list(APPEND TARS_TOOL_FLAG "") --- servant/makefile/tars-tools.cmake.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/servant/makefile/tars-tools.cmake.in b/servant/makefile/tars-tools.cmake.in index 8d9ab050..597d40b0 100755 --- a/servant/makefile/tars-tools.cmake.in +++ b/servant/makefile/tars-tools.cmake.in @@ -14,6 +14,9 @@ option(TARS_HTTP2 "open http2 support" @TARS_HTTP2@) set(TARS_INC "${TARS_PATH}/include") set(TARS_LIB_DIR "${TARS_PATH}/lib" ) +# set tars2cpp flag: list(APPEND TARS_TOOL_FLAG "--with-tars") +list(APPEND TARS_TOOL_FLAG "") + if(WIN32) set (LIB_TARS_SERVANT "${TARS_LIB_DIR}/tarsservant.lib") set (LIB_TARS_UTIL "${TARS_LIB_DIR}/tarsutil.lib") From 5911d2da2653a68532a35e436aca2da811324c3c Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 14 Nov 2023 16:47:10 +0800 Subject: [PATCH 07/81] rolllog only init once --- examples/UtilDemo/demo-server/demo_server.cpp | 2 +- servant/libservant/RemoteLogger.cpp | 11 ++++++++--- util/include/util/tc_logger.h | 12 ++++++++++-- util/src/tc_logger.cpp | 8 +++++++- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/examples/UtilDemo/demo-server/demo_server.cpp b/examples/UtilDemo/demo-server/demo_server.cpp index c6bf5797..6174df54 100644 --- a/examples/UtilDemo/demo-server/demo_server.cpp +++ b/examples/UtilDemo/demo-server/demo_server.cpp @@ -204,7 +204,7 @@ class MyServer : public TC_EpollServer void initialize() { - g_group.start(1); + g_group.start(); g_logger.init("./debug", 1024 * 1024, 10); g_logger.modFlag(TC_RollLogger::HAS_LEVEL | TC_RollLogger::HAS_PID, true); diff --git a/servant/libservant/RemoteLogger.cpp b/servant/libservant/RemoteLogger.cpp index d48bb585..5cdb49f4 100644 --- a/servant/libservant/RemoteLogger.cpp +++ b/servant/libservant/RemoteLogger.cpp @@ -127,6 +127,11 @@ void LocalRollLogger::terminate() void LocalRollLogger::setLogInfo(const string &sApp, const string &sServer, const string &sLogpath, int iMaxSize, int iMaxNum, const CommunicatorPtr &comm, const string &sLogObj) { + if (_local.isStart()) + { + return; + } + _app = sApp; _server = sServer; _logpath = sLogpath; @@ -142,7 +147,7 @@ void LocalRollLogger::setLogInfo(const string &sApp, const string &sServer, cons //生成目录 TC_File::makeDirRecursive(_logpath + FILE_SEP + _app + FILE_SEP + _server); - _local.start(1); + _local.start(); //初始化本地循环日志 _logger.init(_logpath + FILE_SEP + _app + FILE_SEP + _server + FILE_SEP + _app + "." + _server, iMaxSize, iMaxNum); @@ -235,8 +240,8 @@ LocalRollLogger::RollLogger *LocalRollLogger::logger(const string &suffix) TarsLoggerThread::TarsLoggerThread() { - _local.start(1); - _remote.start(1); + _local.start(); + _remote.start(); } TarsLoggerThread::~TarsLoggerThread() diff --git a/util/include/util/tc_logger.h b/util/include/util/tc_logger.h index daa8dbe7..583ff1f2 100644 --- a/util/include/util/tc_logger.h +++ b/util/include/util/tc_logger.h @@ -297,9 +297,9 @@ namespace tars * @brief 启动线程. * @brief Start Thread * - * @param iThreadNum线程数 + * @param iThreadNum线程数, 无效, 永远为1 */ - void start(size_t iThreadNum); + void start(int iThreadNum = 1); /** * @brief 注册logger对象. @@ -325,8 +325,16 @@ namespace tars */ void flush(); + /** + * 结束 + */ void terminate(); + /** + * 是否已经启动了 + * @return + */ + bool isStart(); protected: /** * @brief 写日志 diff --git a/util/src/tc_logger.cpp b/util/src/tc_logger.cpp index b7074935..e42327b2 100644 --- a/util/src/tc_logger.cpp +++ b/util/src/tc_logger.cpp @@ -121,7 +121,7 @@ TC_LoggerThreadGroup::~TC_LoggerThreadGroup() terminate(); } -void TC_LoggerThreadGroup::start(size_t iThreadNum) +void TC_LoggerThreadGroup::start(int iThreadNum) { if(!_thread) { @@ -129,6 +129,11 @@ void TC_LoggerThreadGroup::start(size_t iThreadNum) } } +bool TC_LoggerThreadGroup::isStart() +{ + return _thread.get() != nullptr; +} + void TC_LoggerThreadGroup::registerLogger(TC_LoggerRollPtr &l) { std::lock_guard lock(_mutex); @@ -159,6 +164,7 @@ void TC_LoggerThreadGroup::terminate() if (_thread) { _thread->join(); + _thread.reset(); } } From a7a933c55ab70aeeec572b5dfbba9a156818e0b5 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 14 Nov 2023 17:56:36 +0800 Subject: [PATCH 08/81] AppCache only initialize once --- servant/libservant/AppCache.cpp | 4 ++++ servant/libservant/EndpointManager.cpp | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/servant/libservant/AppCache.cpp b/servant/libservant/AppCache.cpp index 17de3824..8bd4ac04 100644 --- a/servant/libservant/AppCache.cpp +++ b/servant/libservant/AppCache.cpp @@ -28,6 +28,10 @@ void AppCache::setCacheInfo(const string &sFile,int32_t iSynInterval) { TC_LockT lock(*this); + if(!_file.empty()) + { + return; + } string sPath = TC_File::extractFilePath(sFile); TC_File::makeDirRecursive(sPath); diff --git a/servant/libservant/EndpointManager.cpp b/servant/libservant/EndpointManager.cpp index bbb3fc84..6e9b6637 100644 --- a/servant/libservant/EndpointManager.cpp +++ b/servant/libservant/EndpointManager.cpp @@ -153,10 +153,6 @@ bool QueryEpBase::init(const string & sObjName, const string& setName, bool root _rootServant = rootServant; - if(sObjName.find("UdpIpv6Obj") != string::npos) - { - LOG_CONSOLE_DEBUG << "QueryEpBase::init sObjName:" << sObjName << ", sLocator:" << _locator << ", setName:" << setName << ", rootServant: " << rootServant << endl; - } setObjName(sObjName); return true; From 5ee6b109da09e0e1d72a44f6105bd83a1def5d0f Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 14 Nov 2023 20:43:28 +0800 Subject: [PATCH 09/81] Optimize the logic for loading local ip list cache --- servant/libservant/EndpointManager.cpp | 73 +++++++++++++++++--------- servant/servant/EndpointManager.h | 4 ++ 2 files changed, 51 insertions(+), 26 deletions(-) diff --git a/servant/libservant/EndpointManager.cpp b/servant/libservant/EndpointManager.cpp index 6e9b6637..0a97ac49 100644 --- a/servant/libservant/EndpointManager.cpp +++ b/servant/libservant/EndpointManager.cpp @@ -158,12 +158,41 @@ bool QueryEpBase::init(const string & sObjName, const string& setName, bool root return true; } +void QueryEpBase::loadFromCache() +{ + string sLocatorKey = _locator; + + //如果启用set,则获取按set分组的缓存 + if (ClientConfig::SetOpen) + { + sLocatorKey += "_" + ClientConfig::SetDivision; + } + + string objName = _objName + string(_invokeSetId.empty() ? "" : ":") + _invokeSetId; + + string sEndpoints = AppCache::getInstance()->get(objName, sLocatorKey); + string sInactiveEndpoints = AppCache::getInstance()->get("inactive_" + objName, sLocatorKey); + + setEndpoints(sEndpoints,_activeEndpoints); + setEndpoints(sInactiveEndpoints,_inactiveEndpoints); + + if(!_activeEndpoints.empty()) + { + _valid = true; + } + + if((!_activeEndpoints.empty() || !_inactiveEndpoints.empty())) + { + //非直接指定端口, 且从cache中能查到服务端口的, 不需要通知所有ObjectProxy更新地址 + notifyEndpoints(_activeEndpoints,_inactiveEndpoints,true); + } +} + void QueryEpBase::setObjName(const string & sObjName) { string::size_type pos = sObjName.find_first_of('@'); string sEndpoints; - string sInactiveEndpoints; if (pos != string::npos) { @@ -189,6 +218,14 @@ void QueryEpBase::setObjName(const string & sObjName) } _valid = true; + + setEndpoints(sEndpoints, _activeEndpoints); + + if(!_activeEndpoints.empty()) + { + //非直接指定端口, 且从cache中能查到服务端口的, 不需要通知所有ObjectProxy更新地址 + notifyEndpoints(_activeEndpoints, _inactiveEndpoints, true); + } } else { @@ -214,37 +251,15 @@ void QueryEpBase::setObjName(const string & sObjName) _queryFPrx = _communicator->stringToProxy(_locator); _queryFPrx->tars_open_keepalive(false); - string sLocatorKey = _locator; - - //如果启用set,则获取按set分组的缓存 - if(ClientConfig::SetOpen) - { - sLocatorKey += "_" + ClientConfig::SetDivision; - } - - string objName = _objName + string(_invokeSetId.empty() ? "" : ":") + _invokeSetId; - //[间接连接]第一次使用cache,如果是接口级请求则不从缓存读取 if(!_interfaceReq) { - sEndpoints = AppCache::getInstance()->get(objName,sLocatorKey); - sInactiveEndpoints = AppCache::getInstance()->get("inactive_"+objName,sLocatorKey); + loadFromCache(); } } - setEndpoints(sEndpoints,_activeEndpoints); - setEndpoints(sInactiveEndpoints,_inactiveEndpoints); - - if(!_activeEndpoints.empty()) - { - _valid = true; - } - - if((!_activeEndpoints.empty() || !_inactiveEndpoints.empty())) - { - //非直接指定端口, 且从cache中能查到服务端口的, 不需要通知所有ObjectProxy更新地址 - notifyEndpoints(_activeEndpoints,_inactiveEndpoints,true); - } + //重置刷新时间, 保证会马上刷新主控ip list + _refreshTime = 0; } void QueryEpBase::setEndpoints(const string & sEndpoints, set & setEndpoints) @@ -576,6 +591,12 @@ void QueryEpBase::doEndpoints(const vector& activeEp, const vector Date: Tue, 14 Nov 2023 20:47:44 +0800 Subject: [PATCH 10/81] fix mistake bug --- servant/libservant/EndpointManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/servant/libservant/EndpointManager.cpp b/servant/libservant/EndpointManager.cpp index 0a97ac49..235e2ac2 100644 --- a/servant/libservant/EndpointManager.cpp +++ b/servant/libservant/EndpointManager.cpp @@ -591,11 +591,11 @@ void QueryEpBase::doEndpoints(const vector& activeEp, const vector Date: Wed, 15 Nov 2023 09:13:09 +0800 Subject: [PATCH 11/81] fix tars-tools.cmake.in --- servant/makefile/tars-tools.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servant/makefile/tars-tools.cmake.in b/servant/makefile/tars-tools.cmake.in index 597d40b0..c7e24e80 100755 --- a/servant/makefile/tars-tools.cmake.in +++ b/servant/makefile/tars-tools.cmake.in @@ -3,7 +3,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -set(TARS2CPP "@CMAKE_INSTALL_PREFIX@/tars2cpp.exe" CACHE STRING "set tars2cpp path") +set(TARS2CPP "@CMAKE_INSTALL_PREFIX@/tars2cpp" CACHE STRING "set tars2cpp path") set(TARSMERGE "@CMAKE_INSTALL_PREFIX@/tools/tarsmerge" CACHE STRING "set tarsmerge path") set(TARS_PATH "@CMAKE_INSTALL_PREFIX@") From 60c6006beb1c46f09c2a25c60a822829c793b930 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 15 Nov 2023 09:42:07 +0800 Subject: [PATCH 12/81] fix tars-tools.cmake.in --- servant/makefile/tars-tools.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servant/makefile/tars-tools.cmake.in b/servant/makefile/tars-tools.cmake.in index c7e24e80..8f2d1d85 100755 --- a/servant/makefile/tars-tools.cmake.in +++ b/servant/makefile/tars-tools.cmake.in @@ -3,7 +3,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -set(TARS2CPP "@CMAKE_INSTALL_PREFIX@/tars2cpp" CACHE STRING "set tars2cpp path") +set(TARS2CPP "@CMAKE_INSTALL_PREFIX@/tools/tars2cpp" CACHE STRING "set tars2cpp path") set(TARSMERGE "@CMAKE_INSTALL_PREFIX@/tools/tarsmerge" CACHE STRING "set tarsmerge path") set(TARS_PATH "@CMAKE_INSTALL_PREFIX@") From 000fdd8af776a361dd80b06ba434bb6b071aca21 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Fri, 17 Nov 2023 10:00:10 +0800 Subject: [PATCH 13/81] fix remote config, when tarsconfig timeout not use local config file bug --- servant/libservant/RemoteConfig.cpp | 132 ++++++++++++----------- servant/servant/RemoteConfig.h | 8 +- unit-test/rpc/test_win_server.cpp | 65 ++++++++++- unit-test/server/FrameworkServer.cpp | 4 +- unit-test/server/WinServer.cpp | 1 + unit-test/server/framework.conf | 2 +- unit-test/server/framework/ConfigImp.cpp | 11 ++ unit-test/server/framework/ConfigImp.h | 15 ++- unit-test/server/framework/DbHandle.cpp | 1 - unit-test/server/windows.conf | 2 - 10 files changed, 166 insertions(+), 75 deletions(-) create mode 100755 unit-test/server/framework/ConfigImp.cpp diff --git a/servant/libservant/RemoteConfig.cpp b/servant/libservant/RemoteConfig.cpp index bb20a2cb..6dbb40a0 100755 --- a/servant/libservant/RemoteConfig.cpp +++ b/servant/libservant/RemoteConfig.cpp @@ -25,39 +25,40 @@ namespace tars { -int RemoteConfig::setConfigInfo(const CommunicatorPtr &comm, const string &obj, const string & app, const string &serverName, const string& basePath,const string& setdivision, int maxBakNum) +int +RemoteConfig::setConfigInfo(const CommunicatorPtr &comm, const string &obj, const string &app, const string &serverName, + const string &basePath, const string &setdivision, int maxBakNum) { - _comm = comm; - if(!obj.empty()) + _comm = comm; + if (!obj.empty()) { - _configPrx = _comm->stringToProxy(obj); + _configPrx = _comm->stringToProxy(obj); _configPrx->tars_open_keepalive(false); } - _app = app; - _serverName = serverName; - _basePath = basePath; - _maxBakNum = maxBakNum; - _setdivision = setdivision; + _app = app; + _serverName = serverName; + _basePath = basePath; + _maxBakNum = maxBakNum; + _setdivision = setdivision; return 0; } -bool RemoteConfig::addConfig(const string & sFileName, string &buffer, bool bAppConfigOnly) +bool RemoteConfig::addConfig(const string &sFileName, string &buffer, bool bAppConfigOnly) { TC_LockT lock(_mutex); try { - string sFullFileName = _basePath + FILE_SEP + sFileName; + string sFullFileName = TC_File::simplifyDirectory(_basePath + FILE_SEP + sFileName); string newFile = getRemoteFile(sFileName, bAppConfigOnly); if (newFile.empty() || !TC_File::isFileExist(newFile))//拉取不到配置中心的配置文件 { - if(!TC_File::isFileExist(newFile)) //获取本地配置成功,返回成功,但需要告警一下。 + if (TC_File::isFileExist(sFullFileName)) //获取本地配置成功,返回成功,但需要告警一下。 { - buffer = "[fail] get remote config:" + sFileName + "fail,use the local config."; - + buffer = "[fail] get remote config:" + sFileName + "fail,use the local config: " + sFullFileName; return true; } throw runtime_error("access file error:" + newFile); @@ -69,7 +70,7 @@ bool RemoteConfig::addConfig(const string & sFileName, string &buffer, bool bApp { if (TC_File::isFileExist(index2file(sFullFileName, i))) { - localRename(index2file(sFullFileName, i), index2file(sFullFileName, i+1)); + localRename(index2file(sFullFileName, i), index2file(sFullFileName, i + 1)); } } @@ -81,14 +82,14 @@ bool RemoteConfig::addConfig(const string & sFileName, string &buffer, bool bApp localRename(newFile, sFullFileName); - assert(TC_File::isFileExist(sFullFileName)); + assert(TC_File::isFileExist(sFullFileName)); //assert(!access(sFullFileName.c_str(), R_OK)); buffer = "[succ] get remote config:" + sFileName; return true; } - catch (std::exception& e) + catch (std::exception &e) { buffer = "[fail] get remote config '" + sFileName + "' error:" + string(e.what()); } @@ -104,58 +105,63 @@ string RemoteConfig::getRemoteFile(const string &sFileName, bool bAppConfigOnly) { if (_configPrx) { - string stream; - int ret = -1; - - for(int i = 0; i < 2;i++) - { - try - { - if(_setdivision.empty()) - { - ret = _configPrx->loadConfig(_app, (bAppConfigOnly ? "" : _serverName), sFileName, stream, ServerConfig::Context); - } - else - { - struct ConfigInfo confInfo; - confInfo.appname = _app; - confInfo.servername = (bAppConfigOnly ? "" : _serverName); - confInfo.filename = sFileName; - confInfo.bAppOnly = bAppConfigOnly; - confInfo.setdivision = _setdivision; - ret = _configPrx->loadConfigByInfo(confInfo,stream, ServerConfig::Context); - } - - break; - }catch(std::exception& e){ - // - }catch (...){ - // - } - } - - if (ret != 0 || stream.empty()) - { - throw runtime_error("remote config file is empty:" + sFileName); - } - - string newFile = _basePath + FILE_SEP + sFileName + "." + TC_Common::tostr(time(NULL)); + string stream; + int ret = -1; + + for (int i = 0; i < 2; i++) + { + try + { + if (_setdivision.empty()) + { + ret = _configPrx->loadConfig(_app, (bAppConfigOnly ? "" : _serverName), sFileName, stream, + ServerConfig::Context); + } else + { + struct ConfigInfo confInfo; + confInfo.appname = _app; + confInfo.servername = (bAppConfigOnly ? "" : _serverName); + confInfo.filename = sFileName; + confInfo.bAppOnly = bAppConfigOnly; + confInfo.setdivision = _setdivision; + ret = _configPrx->loadConfigByInfo(confInfo, stream, ServerConfig::Context); + } + + break; + } catch (std::exception &e) + { + TLOG_ERROR("error:" << e.what() << endl); + // + } catch (...) + { + // + } + } + + if (ret != 0 || stream.empty()) + { + TLOG_ERROR("remote config file is empty:" + sFileName << endl); + return ""; +// throw runtime_error("remote config file is empty:" + sFileName); + } + + string newFile = TC_File::simplifyDirectory( + _basePath + FILE_SEP + sFileName + "." + TC_Common::tostr(time(NULL))); std::ofstream out(newFile.c_str()); - + string result; if (out) { out << stream;//如果硬盘满了,是否能写入成功需要进行判断。 out.flush(); - if(out.bad()) + if (out.bad()) { out.close(); - result = "[fail] copy stream to disk error." ; + result = "[fail] copy stream to disk error."; RemoteNotify::getInstance()->report(result); return ""; - } - else + } else { out.close(); return newFile; @@ -165,12 +171,12 @@ string RemoteConfig::getRemoteFile(const string &sFileName, bool bAppConfigOnly) return ""; } -string RemoteConfig::index2file(const string & sFullFileName, int index) +string RemoteConfig::index2file(const string &sFullFileName, int index) { - return sFullFileName + "." + TC_Common::tostr(index) + ".bak"; + return sFullFileName + "." + TC_Common::tostr(index) + ".bak"; } -void RemoteConfig::localRename(const string& oldFile, const string& newFile) +void RemoteConfig::localRename(const string &oldFile, const string &newFile) { #if TARGET_PLATFORM_WINDOWS //by goodenpei,windows下面先remove后rename,否则rename会失败 @@ -185,7 +191,7 @@ void RemoteConfig::localRename(const string& oldFile, const string& newFile) } } -string RemoteConfig::recoverSysConfig(const string & sFullFileName) +string RemoteConfig::recoverSysConfig(const string &sFullFileName) { try { @@ -199,7 +205,7 @@ string RemoteConfig::recoverSysConfig(const string & sFullFileName) } } } - catch (std::exception& e) + catch (std::exception &e) { return "[fail] recover config error:" + string(e.what()); } diff --git a/servant/servant/RemoteConfig.h b/servant/servant/RemoteConfig.h index 86b2088d..a0ee8e83 100644 --- a/servant/servant/RemoteConfig.h +++ b/servant/servant/RemoteConfig.h @@ -108,10 +108,10 @@ class SVT_DLL_API RemoteConfig : public TC_Singleton */ inline void localRename(const string& oldFile, const string& newFile); - /** - * 获取hostname, 给k8s版本使用 - */ - string getHostName(); +// /** +// * 获取hostname, 给k8s版本使用 +// */ +// string getHostName(); protected: diff --git a/unit-test/rpc/test_win_server.cpp b/unit-test/rpc/test_win_server.cpp index 7a9591cc..ecbe99f6 100644 --- a/unit-test/rpc/test_win_server.cpp +++ b/unit-test/rpc/test_win_server.cpp @@ -1,7 +1,9 @@  #include "hello_test.h" #include "../server/WinServer.h" - +#include "server/FrameworkServer.h" +#include "server/framework/DbHandle.h" +#include "server/framework/ConfigImp.h" TEST_F(HelloTest, winServerInCoroutine) @@ -360,3 +362,64 @@ TEST_F(HelloTest, winServerHashTag) stopServer(ws); } + +TEST_F(HelloTest, winServerConfig) +{ + TC_File::removeFile("./test.conf", true); + TC_File::removeFile("./test.conf.1.bak", true); + TC_File::removeFile("./test.conf.2.bak", true); + TC_File::removeFile("./test.conf.3.bak", true); + TC_File::removeFile("./test.conf.4.bak", true); + TC_File::removeFile("./FrameworkServer.tarsdat", true); + + FrameworkServer fs; + startServer(fs, FRAMEWORK_CONFIG()); + + { + WinServer ws; + + startServer(ws, WIN_CONFIG(), TC_EpollServer::NET_THREAD_MERGE_HANDLES_THREAD); + + ASSERT_TRUE(!TC_File::isFileExist("./test.conf")); + + stopServer(ws); + } + + CDbHandle::addActiveEndPoint("TestApp.FrameworkServer.ConfigObj", 11003, 1); + { + WinServer ws; + + startServer(ws, WIN_CONFIG(), TC_EpollServer::NET_THREAD_MERGE_HANDLES_THREAD); + + ASSERT_TRUE(TC_File::isFileExist("./test.conf")); + + stopServer(ws); + } + + CDbHandle::cleanEndPoint(); + + { + WinServer ws; + + startServer(ws, WIN_CONFIG(), TC_EpollServer::NET_THREAD_MERGE_HANDLES_THREAD); + + ASSERT_TRUE(TC_File::isFileExist("./test.conf")); + + stopServer(ws); + } + + ConfigImp::setConfigFile("test.conf", "content"); + { + WinServer ws; + + startServer(ws, WIN_CONFIG(), TC_EpollServer::NET_THREAD_MERGE_HANDLES_THREAD); + + ASSERT_TRUE(TC_File::isFileExist("./test.conf")); + ASSERT_TRUE(TC_File::isFileExist("./test.conf.1.bak")); + EXPECT_EQ(TC_File::load2str("./test.conf"), "content"); + + stopServer(ws); + } + stopServer(fs); +} + diff --git a/unit-test/server/FrameworkServer.cpp b/unit-test/server/FrameworkServer.cpp index 867be4e9..c6ddfcbb 100755 --- a/unit-test/server/FrameworkServer.cpp +++ b/unit-test/server/FrameworkServer.cpp @@ -21,7 +21,9 @@ FrameworkServer::~FrameworkServer() void FrameworkServer::initialize() { - addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".ConfigObj"); + ConfigImp::setConfigFile("test.conf", "test-content"); + + addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".ConfigObj"); addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".QueryObj"); addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".StatObj"); addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".LogObj"); diff --git a/unit-test/server/WinServer.cpp b/unit-test/server/WinServer.cpp index 74b18fb7..103b4445 100644 --- a/unit-test/server/WinServer.cpp +++ b/unit-test/server/WinServer.cpp @@ -15,6 +15,7 @@ WinServer::initialize() { addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".WinObj"); + addConfig("test.conf"); TARS_ADD_ADMIN_CMD_NORMAL("AdminCmdNormalTest", WinServer::cmdAdd); TARS_ADD_ADMIN_CMD_NORMAL("CmdToDelete", WinServer::cmdAdd); diff --git a/unit-test/server/framework.conf b/unit-test/server/framework.conf index 5ca3a9ff..6aa2e1d8 100755 --- a/unit-test/server/framework.conf +++ b/unit-test/server/framework.conf @@ -47,7 +47,7 @@ loglevel=TARS #本地管理套接字[可选] - local = tcp -h 127.0.0.1 -p 15701 -t 10000 + local = tcp -h 127.0.0.1 -p 15791 -t 10000 #本地node的ip:port:timeout[可选] # node = ServerObj@tcp -h 127.0.0.1 -p 2345 -t 10000 diff --git a/unit-test/server/framework/ConfigImp.cpp b/unit-test/server/framework/ConfigImp.cpp new file mode 100755 index 00000000..00c2f7c0 --- /dev/null +++ b/unit-test/server/framework/ConfigImp.cpp @@ -0,0 +1,11 @@ + +#include "ConfigImp.h" + +map ConfigImp::files; +std::mutex ConfigImp::_mutex; + +void ConfigImp::setConfigFile(const string &name, const string &content) +{ + std::lock_guard lock(_mutex); + files[name] = content; +} diff --git a/unit-test/server/framework/ConfigImp.h b/unit-test/server/framework/ConfigImp.h index 21d675f3..fb01ee62 100755 --- a/unit-test/server/framework/ConfigImp.h +++ b/unit-test/server/framework/ConfigImp.h @@ -27,7 +27,7 @@ class ConfigImp : public Config */ virtual void initialize() { - files["test.conf"] = "test-content"; + }; /** @@ -53,6 +53,8 @@ class ConfigImp : public Config { LOG_CONSOLE_DEBUG << app << ", " << server << ", " << filename << endl; + std::lock_guard lock(_mutex); + map::iterator it =files.find(filename); if(it!=files.end()){ config = it->second; @@ -144,8 +146,17 @@ class ConfigImp : public Config return 0; } + + /** + * + * @param name + * @param content + */ + static void setConfigFile(const string &name, const string &content); + private: - map files; + static std::mutex _mutex; + static map files; }; #endif /* TARS_TARS_TEST_TESTCODE_INCLUDE_STUB_CONFIGIMP_H_ */ diff --git a/unit-test/server/framework/DbHandle.cpp b/unit-test/server/framework/DbHandle.cpp index 70b1c605..6ee1e54f 100755 --- a/unit-test/server/framework/DbHandle.cpp +++ b/unit-test/server/framework/DbHandle.cpp @@ -618,7 +618,6 @@ void CDbHandle::updateDivisionCache(SetDivisionCache& setDivisionCache,bool upda } else if(tmpsetCache.count(it->first)) { - //�����������нڵ㶼û������set��ɾ�������е�set��Ϣ tmpsetCache.erase(it->first); } diff --git a/unit-test/server/windows.conf b/unit-test/server/windows.conf index c0cb9fc9..a76f3d95 100644 --- a/unit-test/server/windows.conf +++ b/unit-test/server/windows.conf @@ -19,8 +19,6 @@ asyncthread = 3 #网络线程个数 netthread = 1 - #合并回调线程和网络线程(以网络线程个数为准) - mergenetasync = 0 #模块名称 modulename = TestApp.WinServer From 42ccb981e9ba919a6600f77c936f4446c5239143 Mon Sep 17 00:00:00 2001 From: BeyondWUXF <46481385+BeyondWUXF@users.noreply.github.com> Date: Fri, 17 Nov 2023 17:00:18 +0800 Subject: [PATCH 14/81] gzip compress coredump --- util/src/tc_gzip.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/src/tc_gzip.cpp b/util/src/tc_gzip.cpp index 8f1a43e1..a77b090a 100644 --- a/util/src/tc_gzip.cpp +++ b/util/src/tc_gzip.cpp @@ -42,7 +42,7 @@ bool TC_GZip::compress(const char *src, size_t length, string& buffer) static char gz_simple_header[] = { '\037', '\213', '\010', '\000', '\000', '\000', '\000', '\000', '\002', '\377' }; size_t destLen = sizeof(gz_simple_header) + length * 2; - char *out = new char[destLen]; + char *out = new char[destLen + 1]; stream.next_out = (Bytef *)out; stream.avail_out = destLen; @@ -100,7 +100,7 @@ bool TC_GZip::compress(const char *src, size_t length, vector& buffer) static char gz_simple_header[] = { '\037', '\213', '\010', '\000', '\000', '\000', '\000', '\000', '\002', '\377' }; size_t destLen = sizeof(gz_simple_header) + length * 2; - char *out = new char[destLen]; + char *out = new char[destLen + 1]; stream.next_out = (Bytef *)out; stream.avail_out = destLen; From 4715075fc708fca2edf9f5eb18872680a8a4cfc2 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Sat, 25 Nov 2023 12:03:58 +0800 Subject: [PATCH 15/81] fix KeepAliveNodeFHelper no singleton --- servant/libservant/Application.cpp | 26 ++++++++++++++++---------- servant/libservant/ServantHandle.cpp | 2 +- servant/servant/Application.h | 23 ++++++++++++++--------- servant/servant/KeepAliveNodeF.h | 4 ++-- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/servant/libservant/Application.cpp b/servant/libservant/Application.cpp index eafd4176..da7726e8 100644 --- a/servant/libservant/Application.cpp +++ b/servant/libservant/Application.cpp @@ -200,11 +200,11 @@ void reportRspQueue(TC_EpollServer *epollServer) } } -void heartBeatFunc(const string& adapterName) -{ - TARS_KEEPALIVE(adapterName); -} - +//void heartBeatFunc(const string& adapterName) +//{ +// TARS_KEEPALIVE(adapterName); +//} +// void Application::manualListen() { vector v = getEpollServer()->getBindAdapters(); @@ -221,7 +221,9 @@ void Application::waitForShutdown() _epollServer->setCallbackFunctor(reportRspQueue); - _epollServer->setHeartBeatFunctor(heartBeatFunc); + _epollServer->setHeartBeatFunctor([&](const string &adapter){ + _keepAliveNodeFHelper->keepAlive(adapter); + }); _epollServer->setDestroyAppFunctor([&](TC_EpollServer *epollServer){ @@ -812,7 +814,8 @@ void Application::main(const string &config) do { //发送心跳给node, 表示正在启动 - TARS_KEEPACTIVING; + _keepAliveNodeFHelper->keepActiving(); +// TARS_KEEPACTIVING; //等待initialize初始化完毕 std::unique_lock lock(mtx); @@ -891,10 +894,12 @@ void Application::main(const string &config) TARS_ADD_ADMIN_CMD_PREFIX(TARS_CMD_RESOURCE, Application::cmdViewResource); //上报版本 - TARS_REPORTVERSION(TARS_VERSION); + _keepAliveNodeFHelper->reportVersion(TARS_VERSION); +// TARS_REPORTVERSION(TARS_VERSION); //发送心跳给node, 表示启动了 - TARS_KEEPALIVE(""); + _keepAliveNodeFHelper->keepAlive(); +// TARS_KEEPALIVE(""); //发送给notify表示服务启动了 RemoteNotify::getInstance()->report("restart"); @@ -1305,7 +1310,8 @@ void Application::initializeServer() /////////////////////////////////////////////////////////////////////////////////////////////////// //初始化到Node的代理 __out__.info() << OUT_LINE << "\n" << TC_Common::outfill("[set node proxy]") << "OK" << endl; - KeepAliveNodeFHelper::getInstance()->setNodeInfo(_communicator, ServerConfig::Node, ServerConfig::Application, ServerConfig::ServerName); + _keepAliveNodeFHelper = std::make_shared(); + _keepAliveNodeFHelper->setNodeInfo(_communicator, ServerConfig::Node, ServerConfig::Application, ServerConfig::ServerName); /////////////////////////////////////////////////////////////////////////////////////////////////// //初始化管理对象 diff --git a/servant/libservant/ServantHandle.cpp b/servant/libservant/ServantHandle.cpp index c218e332..0eb740c0 100644 --- a/servant/libservant/ServantHandle.cpp +++ b/servant/libservant/ServantHandle.cpp @@ -195,7 +195,7 @@ void ServantHandle::heartbeat() { _bindAdapter->setHeartBeatTime(fcur); - TARS_KEEPALIVE(_bindAdapter->getName()); + _application->_keepAliveNodeFHelper->keepAlive(_bindAdapter->getName()); //上报连接数 比率 if (_bindAdapter->_pReportConRate) diff --git a/servant/servant/Application.h b/servant/servant/Application.h index 3da00b64..0e52edd7 100644 --- a/servant/servant/Application.h +++ b/servant/servant/Application.h @@ -74,15 +74,15 @@ namespace tars //上报错误信息 #define TARS_NOTIFY_ERROR(info) {RemoteNotify::getInstance()->notify(NOTIFYERROR, info);} -//发送心跳给node 多个adapter分别上报 -#define TARS_KEEPALIVE(adapter) {KeepAliveNodeFHelper::getInstance()->keepAlive(adapter);} - -//发送激活信息 -#define TARS_KEEPACTIVING {KeepAliveNodeFHelper::getInstance()->keepActiving();} - -//发送TARS版本给node -#define TARS_REPORTVERSION(x) {KeepAliveNodeFHelper::getInstance()->reportVersion(TARS_VERSION);} - +////发送心跳给node 多个adapter分别上报 +//#define TARS_KEEPALIVE(adapter) {KeepAliveNodeFHelper::getInstance()->keepAlive(adapter);} +// +////发送激活信息 +//#define TARS_KEEPACTIVING {KeepAliveNodeFHelper::getInstance()->keepActiving();} +// +////发送TARS版本给node +//#define TARS_REPORTVERSION(x) {KeepAliveNodeFHelper::getInstance()->reportVersion(TARS_VERSION);} +// ////////////////////////////////////////////////////////////////////// /** * 添加前置的命令处理方法 @@ -192,6 +192,7 @@ struct SVT_DLL_API ServerConfig }; class PropertyReport; +class KeepAliveNodeFHelper; ////////////////////////////////////////////////////////////////////// /** @@ -608,6 +609,8 @@ class Application: public BaseNotify */ string setDivision(void); + friend class ServantHandle; + protected: /** @@ -653,6 +656,8 @@ class Application: public BaseNotify size_t _ctrlCId = -1; size_t _termId = -1; + shared_ptr _keepAliveNodeFHelper; + PropertyReport * _pReportQueue; PropertyReport * _pReportConRate; PropertyReport * _pReportTimeoutNum; diff --git a/servant/servant/KeepAliveNodeF.h b/servant/servant/KeepAliveNodeF.h index b4733a1e..26faaace 100644 --- a/servant/servant/KeepAliveNodeF.h +++ b/servant/servant/KeepAliveNodeF.h @@ -19,7 +19,7 @@ #include "servant/NodeF.h" #include "servant/Global.h" -#include "util/tc_singleton.h" +//#include "util/tc_singleton.h" namespace tars { @@ -28,7 +28,7 @@ namespace tars * 给node发送心跳 * 调用keepAlive异步发送心跳给node */ -class SVT_DLL_API KeepAliveNodeFHelper : public TC_Singleton,public TC_ThreadMutex +class SVT_DLL_API KeepAliveNodeFHelper : public TC_ThreadMutex { public: From 2eb42c3cb4c3bd58038bb83fe2023b4e57a18d0b Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Sat, 25 Nov 2023 17:28:21 +0800 Subject: [PATCH 16/81] fix push callback crash --- servant/libservant/ServantProxy.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/servant/libservant/ServantProxy.cpp b/servant/libservant/ServantProxy.cpp index 5a5712f5..4e08be66 100644 --- a/servant/libservant/ServantProxy.cpp +++ b/servant/libservant/ServantProxy.cpp @@ -341,6 +341,10 @@ string ServantProxyCallback::getModuleName() { auto moduleName = _moduleName; + if(!moduleName) + { + return ServerConfig::Application + "." + ServerConfig::ServerName; + } return *moduleName.get(); } @@ -811,6 +815,7 @@ uint32_t ServantProxy::tars_gen_requestid() void ServantProxy::tars_set_push_callback(const ServantProxyCallbackPtr & cb) { _pushCallback = cb; + cb->setServantPrx(this); } ServantProxyCallbackPtr ServantProxy::tars_get_push_callback() From d2cac22978b5599f4465a5e03ba9b223c8001e13 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Mon, 27 Nov 2023 11:18:05 +0800 Subject: [PATCH 17/81] RemoteConfig remove singleton --- servant/libservant/Application.cpp | 33 +++++++++++++------------- servant/libservant/EndpointManager.cpp | 20 ++++++++-------- servant/libservant/RemoteConfig.cpp | 10 ++++---- servant/libservant/RemoteNotify.cpp | 8 +++---- servant/servant/Application.h | 2 ++ servant/servant/RemoteConfig.h | 9 +++++-- 6 files changed, 45 insertions(+), 37 deletions(-) diff --git a/servant/libservant/Application.cpp b/servant/libservant/Application.cpp index da7726e8..fc51e7e8 100644 --- a/servant/libservant/Application.cpp +++ b/servant/libservant/Application.cpp @@ -437,7 +437,7 @@ bool Application::cmdLoadConfig(const string& command, const string& params, str string filename = TC_Common::trim(params); - if (RemoteConfig::getInstance()->addConfig(filename, result, false)) + if (_remoteConfig->addConfig(filename, result, false)) { RemoteNotify::getInstance()->report(result); @@ -541,22 +541,23 @@ bool Application::cmdLoadProperty(const string& command, const string& params, s _communicator->reloadProperty(sResult); //加载远程对象 - ServerConfig::Log = _conf.get("/tars/application/server"); + _serverBaseInfo.Log = _conf.get("/tars/application/server"); +// ServerConfig::Log = _serverBaseInfo.Log; - RemoteTimeLogger::getInstance()->setLogInfo(_communicator, ServerConfig::Log, ServerConfig::Application, ServerConfig::ServerName, ServerConfig::LogPath,setDivision()); + RemoteTimeLogger::getInstance()->setLogInfo(_communicator, _serverBaseInfo.Log, _serverBaseInfo.Application, _serverBaseInfo.ServerName, _serverBaseInfo.LogPath,setDivision()); - ServerConfig::Config = _conf.get("/tars/application/server"); + _serverBaseInfo.Config = _conf.get("/tars/application/server"); - RemoteConfig::getInstance()->setConfigInfo(_communicator, ServerConfig::Config, ServerConfig::Application, ServerConfig::ServerName, ServerConfig::BasePath,setDivision(), 5); + _remoteConfig->setConfigInfo(_communicator, _serverBaseInfo.Config, _serverBaseInfo.Application, _serverBaseInfo.ServerName, _serverBaseInfo.BasePath, setDivision(), 5, _serverBaseInfo.Context); - ServerConfig::Notify = _conf.get("/tars/application/server"); + _serverBaseInfo.Notify = _conf.get("/tars/application/server"); - RemoteNotify::getInstance()->setNotifyInfo(_communicator, ServerConfig::Notify, ServerConfig::Application, ServerConfig::ServerName, setDivision(), ServerConfig::LocalIp); + RemoteNotify::getInstance()->setNotifyInfo(_communicator, _serverBaseInfo.Notify, _serverBaseInfo.Application, _serverBaseInfo.ServerName, setDivision(), _serverBaseInfo.NodeName); result = "loaded config items:\r\n" + sResult + - "log=" + ServerConfig::Log + "\r\n" + - "config=" + ServerConfig::Config + "\r\n" + - "notify=" + ServerConfig::Notify + "\r\n"; + "log=" + _serverBaseInfo.Log + "\r\n" + + "config=" + _serverBaseInfo.Config + "\r\n" + + "notify=" + _serverBaseInfo.Notify + "\r\n"; } catch (TC_Config_Exception & ex) { @@ -699,7 +700,7 @@ bool Application::addConfig(const string &filename) { string result; - if (RemoteConfig::getInstance()->addConfig(filename, result, false)) + if (_remoteConfig->addConfig(filename, result, false)) { RemoteNotify::getInstance()->report(result); @@ -715,8 +716,7 @@ bool Application::addAppConfig(const string &filename) string result = ""; // true-只获取应用级别配置 - if (RemoteConfig::getInstance()->addConfig(filename, result, true)) - + if (_remoteConfig->addConfig(filename, result, true)) { RemoteNotify::getInstance()->report(result); @@ -1183,13 +1183,11 @@ void Application::initializeServer() ServerConfig::CoroutineMemSize = TC_Common::toSize(toDefault(_conf.get("/tars/application/server"), "1G"), 1024*1024*1024); ServerConfig::CoroutineStackSize= (uint32_t)TC_Common::toSize(toDefault(_conf.get("/tars/application/server"), "128K"), 1024*128); ServerConfig::ManualListen = _conf.get("/tars/application/server", "0") == "0" ? false : true; -// ServerConfig::MergeNetImp = _conf.get("/tars/application/server", "0") == "0" ? false : true; ServerConfig::NetThread = TC_Common::strto(toDefault(_conf.get("/tars/application/server"), "1")); ServerConfig::CloseCout = _conf.get("/tars/application/server","1")=="0"?0:1; ServerConfig::BackPacketLimit = TC_Common::strto(_conf.get("/tars/application/server", TC_Common::tostr(100*1024*1024))); ServerConfig::BackPacketMin = TC_Common::strto(_conf.get("/tars/application/server", "1024")); - ServerConfig::Context["node_name"] = ServerConfig::LocalIp; #if TARS_SSL ServerConfig::CA = _conf.get("/tars/application/server"); ServerConfig::Cert = _conf.get("/tars/application/server"); @@ -1207,7 +1205,6 @@ void Application::initializeServer() } #endif - if (ServerConfig::LocalIp.empty()) { // ServerConfig::LocalIp = "127.0.0.1"; @@ -1224,6 +1221,7 @@ void Application::initializeServer() } } } + ServerConfig::Context["node_name"] = ServerConfig::NodeName; onServerConfig(); @@ -1300,7 +1298,8 @@ void Application::initializeServer() /////////////////////////////////////////////////////////////////////////////////////////////////// //初始化到配置中心代理 __out__.info() << OUT_LINE << "\n" << TC_Common::outfill("[set remote config] ") << "OK" << endl; - RemoteConfig::getInstance()->setConfigInfo(_communicator, ServerConfig::Config, ServerConfig::Application, ServerConfig::ServerName, ServerConfig::BasePath,setDivision()); + _remoteConfig = std::make_shared(); + _remoteConfig->setConfigInfo(_communicator, ServerConfig::Config, ServerConfig::Application, ServerConfig::ServerName, ServerConfig::BasePath, setDivision(), 5, ServerConfig::Context); /////////////////////////////////////////////////////////////////////////////////////////////////// //初始化到信息中心代理 diff --git a/servant/libservant/EndpointManager.cpp b/servant/libservant/EndpointManager.cpp index 235e2ac2..9a8d8889 100644 --- a/servant/libservant/EndpointManager.cpp +++ b/servant/libservant/EndpointManager.cpp @@ -392,17 +392,17 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) { case E_ALL: { - iRet = _queryFPrx->findObjectById4Any(_objName,activeEp,inactiveEp, ServerConfig::Context); + iRet = _queryFPrx->findObjectById4Any(_objName,activeEp,inactiveEp); break; } case E_STATION: { - iRet = _queryFPrx->findObjectByIdInSameStation(_objName,sName,activeEp,inactiveEp, ServerConfig::Context); + iRet = _queryFPrx->findObjectByIdInSameStation(_objName,sName,activeEp,inactiveEp); break; } case E_SET: { - iRet = _queryFPrx->findObjectByIdInSameSet(_objName,sName,activeEp,inactiveEp, ServerConfig::Context); + iRet = _queryFPrx->findObjectByIdInSameSet(_objName,sName,activeEp,inactiveEp); break; } case E_DEFAULT: @@ -412,11 +412,11 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) { //指定set调用时,指定set的优先级最高 string setId = _invokeSetId.empty()?ClientConfig::SetDivision:_invokeSetId; - iRet = _queryFPrx->findObjectByIdInSameSet(_objName,setId,activeEp,inactiveEp, ServerConfig::Context); + iRet = _queryFPrx->findObjectByIdInSameSet(_objName,setId,activeEp,inactiveEp); } else { - iRet = _queryFPrx->findObjectByIdInSameGroup(_objName,activeEp,inactiveEp, ServerConfig::Context); + iRet = _queryFPrx->findObjectByIdInSameGroup(_objName,activeEp,inactiveEp); } break; } @@ -429,17 +429,17 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) { case E_ALL: { - _queryFPrx->async_findObjectById4Any(this,_objName, ServerConfig::Context); + _queryFPrx->async_findObjectById4Any(this,_objName); break; } case E_STATION: { - _queryFPrx->async_findObjectByIdInSameStation(this,_objName,sName, ServerConfig::Context); + _queryFPrx->async_findObjectByIdInSameStation(this,_objName,sName); break; } case E_SET: { - _queryFPrx->async_findObjectByIdInSameSet(this,_objName,sName, ServerConfig::Context); + _queryFPrx->async_findObjectByIdInSameSet(this,_objName,sName); break; } case E_DEFAULT: @@ -449,11 +449,11 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) { //指定set调用时,指定set的优先级最高 string setId = _invokeSetId.empty()?ClientConfig::SetDivision:_invokeSetId; - _queryFPrx->async_findObjectByIdInSameSet(this,_objName,setId, ServerConfig::Context); + _queryFPrx->async_findObjectByIdInSameSet(this,_objName,setId); } else { - _queryFPrx->async_findObjectByIdInSameGroup(this,_objName, ServerConfig::Context); + _queryFPrx->async_findObjectByIdInSameGroup(this,_objName); } break; } diff --git a/servant/libservant/RemoteConfig.cpp b/servant/libservant/RemoteConfig.cpp index 6dbb40a0..0b0f450a 100755 --- a/servant/libservant/RemoteConfig.cpp +++ b/servant/libservant/RemoteConfig.cpp @@ -27,8 +27,10 @@ namespace tars int RemoteConfig::setConfigInfo(const CommunicatorPtr &comm, const string &obj, const string &app, const string &serverName, - const string &basePath, const string &setdivision, int maxBakNum) + const string &basePath, const string &setdivision, int maxBakNum, const map &context) { + TC_LockT lock(_mutex); + _comm = comm; if (!obj.empty()) { @@ -39,6 +41,7 @@ RemoteConfig::setConfigInfo(const CommunicatorPtr &comm, const string &obj, cons _app = app; _serverName = serverName; _basePath = basePath; + _context = context; _maxBakNum = maxBakNum; _setdivision = setdivision; return 0; @@ -114,8 +117,7 @@ string RemoteConfig::getRemoteFile(const string &sFileName, bool bAppConfigOnly) { if (_setdivision.empty()) { - ret = _configPrx->loadConfig(_app, (bAppConfigOnly ? "" : _serverName), sFileName, stream, - ServerConfig::Context); + ret = _configPrx->loadConfig(_app, (bAppConfigOnly ? "" : _serverName), sFileName, stream, _context); } else { struct ConfigInfo confInfo; @@ -124,7 +126,7 @@ string RemoteConfig::getRemoteFile(const string &sFileName, bool bAppConfigOnly) confInfo.filename = sFileName; confInfo.bAppOnly = bAppConfigOnly; confInfo.setdivision = _setdivision; - ret = _configPrx->loadConfigByInfo(confInfo, stream, ServerConfig::Context); + ret = _configPrx->loadConfigByInfo(confInfo, stream, _context); } break; diff --git a/servant/libservant/RemoteNotify.cpp b/servant/libservant/RemoteNotify.cpp index 41fb7817..62004775 100644 --- a/servant/libservant/RemoteNotify.cpp +++ b/servant/libservant/RemoteNotify.cpp @@ -54,11 +54,11 @@ void RemoteNotify::report(const string &sResult, bool bSync) info.sNodeName = _nodeName; if(!bSync) { - _notifyPrx->async_reportNotifyInfo(NULL, info, ServerConfig::Context); + _notifyPrx->async_reportNotifyInfo(NULL, info); } else { - _notifyPrx->reportNotifyInfo(info, ServerConfig::Context); + _notifyPrx->reportNotifyInfo(info); } } } @@ -87,7 +87,7 @@ void RemoteNotify::notify(NOTIFYLEVEL level, const string &sMessage) info.sMessage = sMessage; info.eLevel = level; info.sNodeName = _nodeName; - _notifyPrx->async_reportNotifyInfo(NULL, info, ServerConfig::Context); + _notifyPrx->async_reportNotifyInfo(NULL, info); } } catch(exception &ex) @@ -113,7 +113,7 @@ void RemoteNotify::report(const string &sMessage, const string & app, const stri info.sSet = ""; info.sMessage = sMessage; info.sNodeName = sNodeName; - _notifyPrx->async_reportNotifyInfo(NULL, info, ServerConfig::Context); + _notifyPrx->async_reportNotifyInfo(NULL, info); } } catch(exception &ex) diff --git a/servant/servant/Application.h b/servant/servant/Application.h index 0e52edd7..33bfd4e7 100644 --- a/servant/servant/Application.h +++ b/servant/servant/Application.h @@ -658,6 +658,8 @@ class Application: public BaseNotify shared_ptr _keepAliveNodeFHelper; + shared_ptr _remoteConfig; + PropertyReport * _pReportQueue; PropertyReport * _pReportConRate; PropertyReport * _pReportTimeoutNum; diff --git a/servant/servant/RemoteConfig.h b/servant/servant/RemoteConfig.h index a0ee8e83..8eae8ed4 100644 --- a/servant/servant/RemoteConfig.h +++ b/servant/servant/RemoteConfig.h @@ -46,7 +46,7 @@ namespace tars class ConfigProxy; typedef tars::TC_AutoPtr ConfigPrx; -class SVT_DLL_API RemoteConfig : public TC_Singleton +class SVT_DLL_API RemoteConfig //: public TC_Singleton { public: /** @@ -60,7 +60,7 @@ class SVT_DLL_API RemoteConfig : public TC_Singleton * * @return int */ - int setConfigInfo(const CommunicatorPtr &comm, const string &obj, const string & app, const string &serverName, const string& basePath,const string& setdivision="",int maxBakNum = 5); + int setConfigInfo(const CommunicatorPtr &comm, const string &obj, const string & app, const string &serverName, const string& basePath, const string& setdivision="",int maxBakNum = 5, const map &context = {}); /** * 读取ConfigServer上配置文件到本地,并备份原文件 @@ -140,6 +140,11 @@ class SVT_DLL_API RemoteConfig : public TC_Singleton */ string _basePath; + /** + * + */ + map _context; + /** * set信息 */ From 8e92301aefd0879b8f3e4bdd8ddda7db16a7cf72 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 29 Nov 2023 11:24:34 +0800 Subject: [PATCH 18/81] fix When the server actively closes the connection, RPC may cause memory leak issues. --- servant/libservant/AdapterProxy.cpp | 2 ++ util/src/tc_transceiver.cpp | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/servant/libservant/AdapterProxy.cpp b/servant/libservant/AdapterProxy.cpp index 7d71aa23..9bff278f 100755 --- a/servant/libservant/AdapterProxy.cpp +++ b/servant/libservant/AdapterProxy.cpp @@ -374,6 +374,7 @@ int AdapterProxy::invoke_connection_serial(ReqMessage * msg) _requestMsg = NULL; msg->eStatus = ReqMessage::REQ_EXC; + msg->response->iRet = TARSSENDREQUESTERR; finishInvoke(msg); @@ -441,6 +442,7 @@ int AdapterProxy::invoke_connection_parallel(ReqMessage * msg) //发送出错了 msg->eStatus = ReqMessage::REQ_EXC; + msg->response->iRet = TARSSENDREQUESTERR; finishInvoke(msg); diff --git a/util/src/tc_transceiver.cpp b/util/src/tc_transceiver.cpp index 46bb4a54..2fee18bd 100644 --- a/util/src/tc_transceiver.cpp +++ b/util/src/tc_transceiver.cpp @@ -1044,8 +1044,9 @@ int TC_TCPTransceiver::send(const void* buf, uint32_t len, uint32_t flag) if (iRet < 0 && !TC_Socket::isPending()) { - THROW_ERROR(TC_Transceiver_Exception, CR_SEND, - "TC_TCPTransceiver::send, " + _desc + ", fd:" + TC_Common::tostr(_fd)); + tcpClose(false, CR_SEND, "TC_TCPTransceiver::send, " + _desc + ", fd:" + TC_Common::tostr(_fd)); + return -1; +// THROW_ERROR(TC_Transceiver_Exception, CR_SEND, "TC_TCPTransceiver::send, " + _desc + ", fd:" + TC_Common::tostr(_fd)); } #if TARGET_PLATFORM_WINDOWS From 65a7cb509c7d83e7027164ed53b90522d14e771b Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Fri, 1 Dec 2023 20:44:57 +0800 Subject: [PATCH 19/81] remove epoll server log --- util/src/tc_epoll_server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/src/tc_epoll_server.cpp b/util/src/tc_epoll_server.cpp index 75ac44c4..7a9d12f5 100644 --- a/util/src/tc_epoll_server.cpp +++ b/util/src/tc_epoll_server.cpp @@ -664,7 +664,7 @@ bool TC_EpollServer::Connection::handleInputImp(const shared_ptrerror(ex.what()); +// _logger->error(ex.what()); netThread->delConnection(this, true, EM_CLIENT_CLOSE); return false; } From 9927a669ed2cf8fe63c74df60902d9cad92790a2 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 5 Dec 2023 15:20:43 +0800 Subject: [PATCH 20/81] fix tc_option support " --- unit-test/util/test_tc_option.cpp | 98 +++++++++++++++++++++++++++++++ util/include/util/tc_option.h | 6 ++ util/src/tc_option.cpp | 35 ++++++++++- 3 files changed, 138 insertions(+), 1 deletion(-) create mode 100755 unit-test/util/test_tc_option.cpp diff --git a/unit-test/util/test_tc_option.cpp b/unit-test/util/test_tc_option.cpp new file mode 100755 index 00000000..14da3189 --- /dev/null +++ b/unit-test/util/test_tc_option.cpp @@ -0,0 +1,98 @@ +#include "util/tc_option.h" +#include "util/tc_common.h" +#include +#include "gtest/gtest.h" + +#include +#include + +using namespace std; +using namespace tars; + +class UtilOptionTest : public testing::Test +{ +public: + //添加日志 + static void SetUpTestCase() + { + } + static void TearDownTestCase() + { + } + virtual void SetUp() //TEST跑之前会执行SetUp + { + } + virtual void TearDown() //TEST跑完之后会执行TearDown + { + } +}; + +std::vector parseString(const std::string& input) +{ + std::vector result; + std::string currentString; + + bool insideQuotes = false; + + for (char c : input) { + if (c == ' ' && !insideQuotes) { + if (!currentString.empty()) { + result.push_back(currentString); + currentString.clear(); + } + } else if (c == '"' && !insideQuotes) { + currentString += c; + insideQuotes = true; + } else if (c == '"' && insideQuotes) { + currentString += c; + insideQuotes = false; + result.push_back(currentString); + currentString.clear(); + } else { + currentString += c; + } + } + + if (!currentString.empty()) { + result.push_back(currentString); + } + + return result; +} + +TEST_F(UtilOptionTest, option) +{ + string command = "server update --config=test.conf --abc --ep=\"tcp -h 127.0.0.1 -p 2345\""; + auto v = parseString(command.c_str()); + + EXPECT_EQ(v.size(), 5); +} + +TEST_F(UtilOptionTest, option_test) +{ + string command = "server update --config=test.conf --abc"; + + { + TC_Option option; + option.decode(command.c_str()); + + EXPECT_EQ(option.getSingle().size(), 2); + EXPECT_EQ(option.getSingle()[0], "server"); + EXPECT_EQ(option.getSingle()[1], "update"); + EXPECT_EQ(option.getValue("config"), "test.conf"); + EXPECT_EQ(option.hasParam("abc"), true); + } + + { + command = "server update --config=test.conf --abc --ep=\"tcp -h 127.0.0.1 -p 2345\""; + TC_Option option; + option.decode(command.c_str()); + EXPECT_EQ(option.getSingle().size(), 2); + EXPECT_EQ(option.getSingle()[0], "server"); + EXPECT_EQ(option.getSingle()[1], "update"); + EXPECT_EQ(option.getValue("config"), "test.conf"); + EXPECT_EQ(option.hasParam("abc"), true); + EXPECT_EQ(option.getValue("ep"), "tcp -h 127.0.0.1 -p 2345"); + } + +} diff --git a/util/include/util/tc_option.h b/util/include/util/tc_option.h index 92cb0cb2..c393b929 100644 --- a/util/include/util/tc_option.h +++ b/util/include/util/tc_option.h @@ -143,6 +143,12 @@ class TC_Option */ void parse(const string &s); + /** + * @brief 使用" \t"分割, 如果碰到"则不分割 + * @param input + * @return + */ + std::vector parseString(const std::string& input); protected: /** *存放标识和其对应参数的对应关系,例如:对于--name=value,存放name和value diff --git a/util/src/tc_option.cpp b/util/src/tc_option.cpp index 29bc5e70..820e235f 100644 --- a/util/src/tc_option.cpp +++ b/util/src/tc_option.cpp @@ -41,12 +41,45 @@ void TC_Option::decode(int argc, char *argv[]) } } } + +std::vector TC_Option::parseString(const std::string& input) +{ + std::vector result; + std::string currentString; + + bool insideQuotes = false; + + for (char c : input) { + if ((c == ' ' || c == '\t') && !insideQuotes) { + if (!currentString.empty()) { + result.push_back(currentString); + currentString.clear(); + } + } else if (c == '"' && !insideQuotes) { +// currentString += c; + insideQuotes = true; + } else if (c == '"' && insideQuotes) { +// currentString += c; + insideQuotes = false; + } else { + currentString += c; + } + } + + if (!currentString.empty()) { + result.push_back(currentString); + } + + return result; +} + void TC_Option::decode(const char *command) { _mParam.clear(); if(command == NULL) return; - vector v = TC_Common::sepstr(command, " \t"); +// vector v = TC_Common::sepstr(command, " \t"); + vector v = parseString(command); for(size_t i = 0; i < v.size(); i++) { From 19875423ddbb56f43c3d66c2b4f9795d639ee93f Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Fri, 8 Dec 2023 21:53:41 +0800 Subject: [PATCH 21/81] support master-slave mode in frameworkPro --- servant/libservant/Application.cpp | 185 +++++++++++++++++++++----- servant/protocol | 2 +- servant/servant/Application.h | 35 ++++- unit-test/server/framework/QueryImp.h | 24 ++++ 4 files changed, 208 insertions(+), 38 deletions(-) diff --git a/servant/libservant/Application.cpp b/servant/libservant/Application.cpp index fc51e7e8..459c31ae 100644 --- a/servant/libservant/Application.cpp +++ b/servant/libservant/Application.cpp @@ -30,8 +30,9 @@ #include "servant/RemoteLogger.h" #include "servant/RemoteConfig.h" #include "servant/RemoteNotify.h" +#include "servant/QueryF.h" -#include +#include #if TARGET_PLATFORM_LINUX #include #endif @@ -82,6 +83,9 @@ int ServerConfig::NetThread = 1; //servernet thread bool ServerConfig::CloseCout = true; int ServerConfig::BackPacketLimit = 0; int ServerConfig::BackPacketMin = 1024; +int ServerConfig::BakFlag = 0; +int ServerConfig::BakType = 0; + std::string ServerConfig::CA; std::string ServerConfig::Cert; std::string ServerConfig::Key; @@ -119,6 +123,9 @@ ServerBaseInfo ServerConfig::toServerBaseInfo() serverBaseInfo.ManualListen = ManualListen; serverBaseInfo.BackPacketLimit = BackPacketLimit; serverBaseInfo.BackPacketMin = BackPacketMin; + serverBaseInfo.BakFlag = BakFlag; + serverBaseInfo.BakType = BakType; + serverBaseInfo.CA = CA; serverBaseInfo.Cert = Cert; serverBaseInfo.Key = Key; @@ -129,9 +136,8 @@ ServerBaseInfo ServerConfig::toServerBaseInfo() return serverBaseInfo; } /////////////////////////////////////////////////////////////////////////////////////////// -//TC_Config Application::_conf; -//TC_EpollServerPtr Application::_epollServer = NULL; -CommunicatorPtr Application::_communicator = NULL; + +CommunicatorPtr Application::_communicator = nullptr; PropertyReportPtr g_pReportRspQueue; @@ -158,7 +164,7 @@ Application::~Application() if(_epollServer) { _epollServer->terminate(); - _epollServer = NULL; + _epollServer = nullptr; } #if TARGET_PLATFORM_WINDOWS WSACleanup(); @@ -191,9 +197,9 @@ void reportRspQueue(TC_EpollServer *epollServer) const vector &adapters = epollServer->getBindAdapters(); size_t n = 0; - for (size_t i = 0; i < adapters.size(); ++i) + for (const auto & adapter : adapters) { - n = n + adapters[i]->getSendBufferSize(); + n = n + adapter->getSendBufferSize(); } g_pReportRspQueue->report((int)n); @@ -237,7 +243,7 @@ void Application::waitForShutdown() TC_Port::unregisterCtrlC(_ctrlCId); TC_Port::unregisterTerm(_termId); - _epollServer = NULL; + _epollServer = nullptr; } void Application::waitForReady() @@ -252,6 +258,16 @@ void Application::terminate() { if (_epollServer && !_epollServer->isTerminate()) { + if(_masterSlaveCheckThread && _masterSlaveCheckThread->joinable()) + { + { + TC_ThreadLock::Lock lock(_masterSlaveLock); + _terminateCheckMasterSlave = true; + _masterSlaveLock.notify(); + } + + _masterSlaveCheckThread->join(); + } std::this_thread::sleep_for(std::chrono::milliseconds(100)); //稍微休息一下, 让当前处理包能够回复 _epollServer->terminate(); @@ -286,7 +302,7 @@ bool Application::cmdViewStatus(const string& command, const string& params, str bool Application::cmdCloseCoreDump(const string& command, const string& params, string& result) { #if TARGET_PLATFORM_LINUX || TARGET_PLATFORM_IOS - struct rlimit tlimit; + struct rlimit tlimit{}; int ret = 0; ostringstream os; @@ -413,7 +429,6 @@ bool Application::cmdEnableDayLog(const string& command, const string& params, s result = "set " + vParams[0] + " " + vParams[1] + " " + vParams[2] + " ok"; } - if (vParams[0] == "local") { RemoteTimeLogger::getInstance()->enableLocal(sFile, bEnable); @@ -520,7 +535,7 @@ bool Application::cmdViewBuildID(const string& command, const string& params, st char buildTime[50] = {0}; sprintf(buildTime, "%d.%02d%02d.%06d", YEARSUF, MONTH + 1, DAY, TIMEINT); - result = "$" + ServerConfig::Application + "." + ServerConfig::ServerName + "-" + string(buildTime) + "$"; + result = "$" + _serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + "-" + string(buildTime) + "$"; return true; } @@ -533,7 +548,7 @@ bool Application::cmdLoadProperty(const string& command, const string& params, s //重新解析配置文件 _conf.parseFile(ServerConfig::ConfigFile); - string sResult = ""; + string sResult; //加载通讯器属性 _communicator->setProperty(_conf); @@ -670,7 +685,7 @@ bool Application::cmdViewResource(const string& command, const string& params, s os << OUT_LINE << endl; vector adapters = _epollServer->getBindAdapters(); - for(auto adapter : adapters) + for(const auto& adapter : adapters) { outAdapter(os, _servantHelper->getAdapterServant(adapter->getName()), adapter); os << TC_Common::outfill("recv-buffer-count") << adapter->getRecvBufferSize() << endl; @@ -688,9 +703,9 @@ void Application::outAllAdapter(ostream &os) { auto m = _epollServer->getListenSocketInfo(); - for (auto it = m.begin(); it != m.end(); ++it) + for (auto & it : m) { - outAdapter(os, _servantHelper->getAdapterServant(it->second->getName()), it->second); + outAdapter(os, _servantHelper->getAdapterServant(it.second->getName()), it.second); os << OUT_LINE << endl; } @@ -713,7 +728,7 @@ bool Application::addConfig(const string &filename) bool Application::addAppConfig(const string &filename) { - string result = ""; + string result; // true-只获取应用级别配置 if (_remoteConfig->addConfig(filename, result, true)) @@ -749,7 +764,7 @@ void Application::main(const TC_Option &option) //加载配置文件 ServerConfig::ConfigFile = option.getValue("config"); - if (ServerConfig::ConfigFile == "") + if (ServerConfig::ConfigFile.empty()) { cerr << "start server with config, for example: exe --config=config.conf" << endl; @@ -767,8 +782,8 @@ void Application::main(const TC_Option &option) void Application::main(const string &config) { //增加一把全局静态锁, 避免一个进程内, 多个服务同时初始化时带来bug(一般测试中才会这样!) - static std::mutex mtx; - std::lock_guard lock(mtx); + static std::mutex gmtx; + std::lock_guard glock(gmtx); try { @@ -806,7 +821,7 @@ void Application::main(const string &config) { bool initing = true; - std::mutex mtx; + std::mutex kmtx; std::condition_variable cond; std::thread keepActiving([&] @@ -818,7 +833,7 @@ void Application::main(const string &config) // TARS_KEEPACTIVING; //等待initialize初始化完毕 - std::unique_lock lock(mtx); + std::unique_lock lock(kmtx); cond.wait_for(lock, std::chrono::seconds(5), [&](){ return !initing; }); @@ -833,7 +848,7 @@ void Application::main(const string &config) initialize(); { - std::unique_lock lock(mtx); + std::unique_lock lock(kmtx); initing = false; cond.notify_all(); } @@ -1043,7 +1058,7 @@ void Application::addServantProtocol(const string& servant, const TC_NetWorkBuff { string adapterName = _servantHelper->getServantAdapter(servant); - if (adapterName == "") + if (adapterName.empty()) { throw runtime_error("addServantProtocol fail, no found adapter for servant:" + servant); } @@ -1057,9 +1072,9 @@ void Application::addAcceptCallback(const TC_EpollServer::accept_callback_functo void Application::onAccept(TC_EpollServer::Connection* cPtr) { - for (size_t i = 0; i < _acceptFuncs.size(); ++i) + for (const auto & _acceptFunc : _acceptFuncs) { - _acceptFuncs[i](cPtr); + _acceptFunc(cPtr); } } @@ -1108,6 +1123,8 @@ void Application::outServer(ostream &os) os << TC_Common::outfill("ReportFlow(reportflow)") << ServerConfig::ReportFlow<< endl; os << TC_Common::outfill("BackPacketLimit(backpacketlimit)") << ServerConfig::BackPacketLimit<< endl; os << TC_Common::outfill("BackPacketMin(backpacketmin)") << ServerConfig::BackPacketMin<< endl; + os << TC_Common::outfill("BakType(baktype)") << ServerConfig::BakType << endl; + os << TC_Common::outfill("BakFlag(bakflag)") << ServerConfig::BakFlag << endl; #if TARS_SSL os << TC_Common::outfill("Ca(ca)") << ServerConfig::CA << endl; @@ -1127,7 +1144,7 @@ void Application::initializeServer() ServerConfig::Application = toDefault(_conf.get("/tars/application/server"), "UNKNOWN"); //缺省采用进程名称 - string exe = ""; + string exe; try { @@ -1167,6 +1184,8 @@ void Application::initializeServer() #endif ServerConfig::TarsPath = TC_File::simplifyDirectory(ServerConfig::LogPath + FILE_SEP + ".." + FILE_SEP) + FILE_SEP; + ServerConfig::BakFlag = TC_Common::strto(_conf.get("/tars/application/server", "0")); + ServerConfig::BakType = TC_Common::strto(_conf.get("/tars/application/server", "0")); ServerConfig::LogSize = TC_Common::toSize(toDefault(_conf.get("/tars/application/server"), "52428800"), 52428800); ServerConfig::LogNum = TC_Common::strto(toDefault(_conf.get("/tars/application/server"), "10")); @@ -1212,11 +1231,11 @@ void Application::initializeServer() ServerConfig::LocalIp = "127.0.0.1"; //获取第一个非127.0.0.1的IP - for(size_t i = 0; i < v.size(); i++) + for(const auto & i : v) { - if(v[i] != "127.0.0.1") + if(i != "127.0.0.1") { - ServerConfig::LocalIp = v[i]; + ServerConfig::LocalIp = i; break; } } @@ -1342,10 +1361,26 @@ void Application::initializeServer() } + if (!_communicator->getProperty("locator").empty() && _serverBaseInfo.BakType > 0) + { + int timeout = TC_Common::strto(_conf.get("/tars/application/server", "5000")); + if (timeout < 5000) + { + timeout = 5000; + } + + _masterSlaveCheckThread = new std::thread(std::bind(&Application::checkMasterSlave, this, timeout)); + } + else + { + // 非主备模式时,默认响应 onMaster + onMaster(); + } + //队列取平均值 if(!_communicator->getProperty("property").empty()) { - string sRspQueue(""); + string sRspQueue; sRspQueue += ServerConfig::Application; sRspQueue += "."; sRspQueue += ServerConfig::ServerName; @@ -1521,10 +1556,96 @@ void Application::outAdapter(ostream &os, const string &v, TC_EpollServer::BindA os << TC_Common::outfill("order") << (lsPtr->getOrder() == TC_EpollServer::BindAdapter::ALLOW_DENY ? "allow,deny" : "deny,allow") << endl; os << TC_Common::outfill("allow") << TC_Common::tostr(lsPtr->getAllow()) << endl; os << TC_Common::outfill("deny") << TC_Common::tostr(lsPtr->getDeny()) << endl; - // os << outfill("queuesize") << lsPtr->getRecvBufferSize() << endl; os << TC_Common::outfill("connections") << lsPtr->getNowConnection() << endl; os << TC_Common::outfill("protocol") << lsPtr->getProtocolName() << endl; os << TC_Common::outfill("handlethread") << lsPtr->getHandleNum() << endl; } -////////////////////////////////////////////////////////////////////////////////////////////////// + +void Application::checkMasterSlave(int timeout) +{ + time_t lastExceptionTime = 0; + + GetMasterSlaveLock req; + req.application = _serverBaseInfo.Application; + req.server_name = _serverBaseInfo.ServerName; + req.node_name = _serverBaseInfo.NodeName; + req.bakType = _serverBaseInfo.BakType; + req.isMaster = false; + req.lastErr = false; + req.timeout = timeout; + + bool firstCheck = true; + int checkInterval = timeout/2; + + QueryFPrx queryFPrx = Application::getCommunicator()->stringToProxy(Application::getCommunicator()->getProperty("locator")); + + do + { + try + { + int ret = queryFPrx->getLocker(req); + + if (0 == ret) + { + //抢到主了, 如果不是主, 则变成主, 且回调 + req.lastErr = false; + if (!req.isMaster) + { + req.isMaster = true; + TLOG_INFO("This service node has become the master node!" << endl); + TARS_NOTIFY_ERROR("Auto change to be master, This service node become the master!"); + onMaster(); + } + firstCheck = false; + } else if (1 == ret) + { + //没抢到主, 如果不是备, 则变成备, 且回调 + req.lastErr = false; + if (req.isMaster || firstCheck) + { + req.isMaster = false; + TLOG_ERROR("The service node has become the slave node." << endl); + TARS_NOTIFY_ERROR("Auto change to be slave, This service node become the slave!"); + onSlave(); + } + firstCheck = false; + } else if (2 == ret) + { + // 服务端内部异常,不做任何处理 + TLOG_ERROR("getLocker return exception, ret:" << ret << endl); + req.lastErr = true; + } else if (ret < 0) + { + TLOG_ERROR("getLocker return exception, ret:" << ret << endl); + req.lastErr = true; + } + } + catch (exception &ex) + { + TLOG_ERROR("getLocker call exception:" << ex.what() << endl); + if (req.isMaster) + { + if (lastExceptionTime == 0) + { + lastExceptionTime = TNOW; + } + else if (TNOW >= lastExceptionTime + timeout - checkInterval) + { + // 判断该服务其他机器能否通,如果能通,那么不变,不能通,则自己降为备 + // TODO,tars_ping 其他机器先不做,直接降为备机,因为这里调所有主控都失败才会切换 + req.isMaster = false; + TLOG_ERROR("The service node has become the slave node because call getLocker exception." << endl); + TARS_NOTIFY_ERROR( + "Auto change to be slave, This service node has become the slave node because call getLocker exception!"); + onSlave(); + } + } + } + + TC_ThreadLock::Lock lock(_masterSlaveLock); + _masterSlaveLock.timedWait(checkInterval); + } + while(!_terminateCheckMasterSlave); +} + } diff --git a/servant/protocol b/servant/protocol index 8afa10af..6ef296fe 160000 --- a/servant/protocol +++ b/servant/protocol @@ -1 +1 @@ -Subproject commit 8afa10af0b0521bc08af31fd8938f53779aded4b +Subproject commit 6ef296fed81169355e81ebead9d181325b8c26e7 diff --git a/servant/servant/Application.h b/servant/servant/Application.h index 33bfd4e7..d8f12b53 100644 --- a/servant/servant/Application.h +++ b/servant/servant/Application.h @@ -134,6 +134,8 @@ struct SVT_DLL_API ServerBaseInfo bool ManualListen; //是否启用手工端口监听 int BackPacketLimit; //回包积压检查 int BackPacketMin; //回包速度检查 + int BakFlag = 0; + int BakType = 0; std::string CA; std::string Cert; @@ -175,7 +177,8 @@ struct SVT_DLL_API ServerConfig static bool ManualListen; //是否启用手工端口监听 static int BackPacketLimit; //回包积压检查 static int BackPacketMin; //回包速度检查 - + static int BakFlag; //是否启用是备机: 0: 非备机, 1: 备机 + static int BakType; //主备切换类型: 0 不需要主备切换,1:自动主从切换, 2:自动切换但是不屏蔽主控路由 static std::string CA; //ssl ca static std::string Cert; //ssl 证书 static std::string Key; //ssl 私钥 @@ -377,7 +380,19 @@ class Application: public BaseNotify * 初始化ServerConfig之后, 给app调整自定义配置值的机会 */ virtual void onServerConfig(){}; - + + /** + * 成为主机(企业版功能) + * 一主多备模式下, 切换成主机模式下回调给业务 + */ + virtual void onMaster() {}; + + /** + * 成为备机(企业版功能) + * 一主多备模式下, 切换成备机模式下回调给业务 + */ + virtual void onSlave() {}; + /** * 处理加载配置的命令 * 处理完成后继续通知Servant @@ -611,6 +626,12 @@ class Application: public BaseNotify friend class ServantHandle; +private: + /** + * 检查主备状态(企业版框架才支持) + */ + void checkMasterSlave(int timeout); + protected: /** @@ -660,9 +681,13 @@ class Application: public BaseNotify shared_ptr _remoteConfig; - PropertyReport * _pReportQueue; - PropertyReport * _pReportConRate; - PropertyReport * _pReportTimeoutNum; + TC_ThreadLock _masterSlaveLock; + bool _terminateCheckMasterSlave = false; + std::thread *_masterSlaveCheckThread = nullptr; //主备模式检查线程(企业版框架功能) + +// PropertyReport * _pReportQueue{}; +// PropertyReport * _pReportConRate{}; +// PropertyReport * _pReportTimeoutNum{}; }; //////////////////////////////////////////////////////////////////// } diff --git a/unit-test/server/framework/QueryImp.h b/unit-test/server/framework/QueryImp.h index 7b662102..00289866 100755 --- a/unit-test/server/framework/QueryImp.h +++ b/unit-test/server/framework/QueryImp.h @@ -70,6 +70,30 @@ class QueryImp: public QueryF * 根据id获取对象同set endpoint列表 */ Int32 findObjectByIdInSameSet(const std::string & id,const std::string & setId,vector &activeEp,vector &inactiveEp, tars::CurrentPtr current); + + /** 注册id变化的通知, 通知时会通知所有的变化内容(企业版功能) + * + * @param ids 对象名称 + * @param name 当前模块名称 + * @return: 0-成功 others-失败 + */ + Int32 registerChange(const vector &ids, const string &name, CurrentPtr current) { return -1; }; + + /** 注册id变化的通知, 通知时后需要自己主动find(企业版功能) + * + * @param id 对象名称 + * @param name 当前模块名称 + * @return: 0-成功 others-失败 + */ + Int32 registerQuery(const string &id, const string &name, CurrentPtr current) { return -1; }; + + /** + * 获取锁, 实现业务服务一主多备的模式(企业版功能) + * @return 0: 获取锁成功; 1:获取锁失败; 2: 数据异常, -1:其他异常 + */ + Int32 getLocker(const tars::GetMasterSlaveLock &req, CurrentPtr current) { return -1;}; + + private: /** * 打印按天日志 From ebae7b6123c2b09bf857581611ad6ced3dc2b475 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Mon, 11 Dec 2023 20:04:23 +0800 Subject: [PATCH 22/81] fix master-slave mode bug --- servant/libservant/Application.cpp | 76 +++++++++++++----------------- 1 file changed, 34 insertions(+), 42 deletions(-) diff --git a/servant/libservant/Application.cpp b/servant/libservant/Application.cpp index 459c31ae..340bfea8 100644 --- a/servant/libservant/Application.cpp +++ b/servant/libservant/Application.cpp @@ -866,6 +866,22 @@ void Application::main(const string &config) } } + if (!_communicator->getProperty("locator").empty() && _serverBaseInfo.BakType > 0) + { + int timeout = TC_Common::strto(_conf.get("/tars/application/server", "5000")); + if (timeout < 5000) + { + timeout = 5000; + } + + _masterSlaveCheckThread = new std::thread(std::bind(&Application::checkMasterSlave, this, timeout)); + } + else + { + // 非主备模式时,默认响应 onMaster + onMaster(); + } + //动态加载配置文件 TARS_ADD_ADMIN_CMD_PREFIX(TARS_CMD_LOAD_CONFIG, Application::cmdLoadConfig); @@ -1361,22 +1377,6 @@ void Application::initializeServer() } - if (!_communicator->getProperty("locator").empty() && _serverBaseInfo.BakType > 0) - { - int timeout = TC_Common::strto(_conf.get("/tars/application/server", "5000")); - if (timeout < 5000) - { - timeout = 5000; - } - - _masterSlaveCheckThread = new std::thread(std::bind(&Application::checkMasterSlave, this, timeout)); - } - else - { - // 非主备模式时,默认响应 onMaster - onMaster(); - } - //队列取平均值 if(!_communicator->getProperty("property").empty()) { @@ -1563,7 +1563,7 @@ void Application::outAdapter(ostream &os, const string &v, TC_EpollServer::BindA void Application::checkMasterSlave(int timeout) { - time_t lastExceptionTime = 0; + int exceptionTimes = 0; GetMasterSlaveLock req; req.application = _serverBaseInfo.Application; @@ -1575,7 +1575,6 @@ void Application::checkMasterSlave(int timeout) req.timeout = timeout; bool firstCheck = true; - int checkInterval = timeout/2; QueryFPrx queryFPrx = Application::getCommunicator()->stringToProxy(Application::getCommunicator()->getProperty("locator")); @@ -1609,41 +1608,34 @@ void Application::checkMasterSlave(int timeout) onSlave(); } firstCheck = false; - } else if (2 == ret) - { - // 服务端内部异常,不做任何处理 - TLOG_ERROR("getLocker return exception, ret:" << ret << endl); - req.lastErr = true; - } else if (ret < 0) + } else { TLOG_ERROR("getLocker return exception, ret:" << ret << endl); req.lastErr = true; } + + exceptionTimes = 0; } catch (exception &ex) { + ++exceptionTimes; TLOG_ERROR("getLocker call exception:" << ex.what() << endl); - if (req.isMaster) - { - if (lastExceptionTime == 0) - { - lastExceptionTime = TNOW; - } - else if (TNOW >= lastExceptionTime + timeout - checkInterval) - { - // 判断该服务其他机器能否通,如果能通,那么不变,不能通,则自己降为备 - // TODO,tars_ping 其他机器先不做,直接降为备机,因为这里调所有主控都失败才会切换 - req.isMaster = false; - TLOG_ERROR("The service node has become the slave node because call getLocker exception." << endl); - TARS_NOTIFY_ERROR( - "Auto change to be slave, This service node has become the slave node because call getLocker exception!"); - onSlave(); - } - } +// if (req.isMaster) +// { +// if (exceptionTimes > 3) +// { +// //持续3次都无法访问主控, 则认为自己异常了!! +// req.isMaster = false; +// TLOG_ERROR("The service node has become the slave node because call getLocker exception." << endl); +// TARS_NOTIFY_ERROR( +// "Auto change to be slave, This service node has become the slave node because call getLocker exception!"); +// onSlave(); +// } +// } } TC_ThreadLock::Lock lock(_masterSlaveLock); - _masterSlaveLock.timedWait(checkInterval); + _masterSlaveLock.timedWait(timeout/3); } while(!_terminateCheckMasterSlave); } From 2c33073055c860c2b795700efaa6ad016fec1d37 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 12 Dec 2023 11:19:01 +0800 Subject: [PATCH 23/81] servant add doNoServant --- servant/libservant/ServantHandle.cpp | 27 +++++++++++++++++---------- servant/servant/Servant.h | 13 +++++++++++-- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/servant/libservant/ServantHandle.cpp b/servant/libservant/ServantHandle.cpp index 0eb740c0..567430d0 100644 --- a/servant/libservant/ServantHandle.cpp +++ b/servant/libservant/ServantHandle.cpp @@ -567,14 +567,14 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) } // processSample(current); - if (_servant->getName() != current->getServantName()) - { - current->sendResponse(TARSSERVERNOSERVANTERR); -// #ifdef TARS_OPENTRACKING -// finishTracking(TARSSERVERNOSERVANTERR, current); -// #endif - return; - } +// if (_servant->getName() != current->getServantName()) +// { +// current->sendResponse(TARSSERVERNOSERVANTERR); +//// #ifdef TARS_OPENTRACKING +//// finishTracking(TARSSERVERNOSERVANTERR, current); +//// #endif +// return; +// } int ret = TARSSERVERUNKNOWNERR; @@ -585,7 +585,14 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) try { //业务逻辑处理 - ret = _servant->dispatch(current, response.sBuffer); + if (_servant->getName() != current->getServantName()) + { + ret = _servant->doNoServant(current, response.sBuffer); + } + else + { + ret = _servant->dispatch(current, response.sBuffer); + } } catch (TarsDecodeException &ex) { @@ -622,7 +629,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) if (ret == TARSSERVERNOFUNCERR) { - ret = _servant->doNoFunc(current); + ret = _servant->doNoFunc(current, response.sBuffer); } //单向调用或者业务不需要同步返回 diff --git a/servant/servant/Servant.h b/servant/servant/Servant.h index 8cdf2d25..b72e1820 100644 --- a/servant/servant/Servant.h +++ b/servant/servant/Servant.h @@ -172,12 +172,21 @@ class Servant : public BaseNotify */ virtual int doClose(CurrentPtr current){ return -1; } + /** + * tars协议, 没有servant时候会调用 + * @param current + * @param buffer: 输出的buffer数据 + * @return 成功请返回0, 异常可以返回: [TARSSERVERSUCCESS~TARSSERVERUNKNOWNERR] + */ + virtual int doNoServant(CurrentPtr current, vector &buffer) {return tars::TARSSERVERNOSERVANTERR;} + /** * tars协议, 没有对应函数时会调用 * @param current - * @return + * @param buffer: 输出的buffer数据 + * @return 成功请返回0, 异常可以返回: [TARSSERVERSUCCESS~TARSSERVERUNKNOWNERR] */ - virtual int doNoFunc(CurrentPtr current) {return tars::TARSSERVERNOFUNCERR;} + virtual int doNoFunc(CurrentPtr current, vector &buffer) {return tars::TARSSERVERNOFUNCERR;} /** * 获得响应的数据队列 From 82d28148bdd336195d1aa50a6ce712e590b9e9f4 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 12 Dec 2023 17:12:48 +0800 Subject: [PATCH 24/81] fix __FILE__ bug --- servant/makefile/tars-tools.cmake.in | 2 +- util/include/util/tc_common.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/servant/makefile/tars-tools.cmake.in b/servant/makefile/tars-tools.cmake.in index 8f2d1d85..e2fb3365 100755 --- a/servant/makefile/tars-tools.cmake.in +++ b/servant/makefile/tars-tools.cmake.in @@ -57,7 +57,7 @@ set(PLATFORM) IF (UNIX) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -fsigned-char") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fsigned-char -std=c++11 -Wno-deprecated -fno-strict-aliasing -Wno-overloaded-virtual") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-builtin-macro-redefined -D__FILE__='\"$(notdir $(abspath $<))\"'") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-builtin-macro-redefined") set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -Wall -g") set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -Wall -fno-strict-aliasing") diff --git a/util/include/util/tc_common.h b/util/include/util/tc_common.h index edd1e64c..2de16469 100644 --- a/util/include/util/tc_common.h +++ b/util/include/util/tc_common.h @@ -1441,7 +1441,8 @@ bool TC_Common::equal(const unordered_map& mx , const unordered_map< #define __filename__(x) (strrchr(x, '\\') ? strrchr(x, '\\') + 1 : x) #define FILE_FUNC_LINE "[" << __filename__(__FILE__) << "::" << __FUNCTION__ << "::" << __LINE__ << "]" #else -#define FILE_FUNC_LINE "[" << __FILE__ << "::" << __FUNCTION__ << "::" << __LINE__ << "]" +#define __FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) +#define FILE_FUNC_LINE "[" << __FILENAME__ << "::" << __FUNCTION__ << "::" << __LINE__ << "]" #endif } From b296544d4008bdea83cd6de6932b20c973174792 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 21 Dec 2023 16:03:32 +0800 Subject: [PATCH 25/81] fix protocol --- servant/protocol | 2 +- unit-test/server/framework/QueryImp.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/servant/protocol b/servant/protocol index 6ef296fe..0af01a8b 160000 --- a/servant/protocol +++ b/servant/protocol @@ -1 +1 @@ -Subproject commit 6ef296fed81169355e81ebead9d181325b8c26e7 +Subproject commit 0af01a8b7e3a31b8050edf7b20478b1d0796c4f0 diff --git a/unit-test/server/framework/QueryImp.h b/unit-test/server/framework/QueryImp.h index 00289866..d597cd42 100755 --- a/unit-test/server/framework/QueryImp.h +++ b/unit-test/server/framework/QueryImp.h @@ -71,13 +71,13 @@ class QueryImp: public QueryF */ Int32 findObjectByIdInSameSet(const std::string & id,const std::string & setId,vector &activeEp,vector &inactiveEp, tars::CurrentPtr current); - /** 注册id变化的通知, 通知时会通知所有的变化内容(企业版功能) - * - * @param ids 对象名称 + /** 注册数据通知, 同时上报本地缓存数据的最后时间, 如果服务端发现变化则全量推送(企业版功能) + * 可以定时上报数据 + * @param timestamp <数据类型, 最后数据时间戳> * @param name 当前模块名称 * @return: 0-成功 others-失败 */ - Int32 registerChange(const vector &ids, const string &name, CurrentPtr current) { return -1; }; + Int32 registerChange(const map ×tamp, const string &name, CurrentPtr current) { return -1; }; /** 注册id变化的通知, 通知时后需要自己主动find(企业版功能) * From 8a6ebbee2236223f67b80c7ba5e1d920c2b9f1e6 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 21 Dec 2023 18:07:09 +0800 Subject: [PATCH 26/81] update protocol --- servant/protocol | 2 +- unit-test/server/framework/QueryImp.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/servant/protocol b/servant/protocol index 0af01a8b..45435317 160000 --- a/servant/protocol +++ b/servant/protocol @@ -1 +1 @@ -Subproject commit 0af01a8b7e3a31b8050edf7b20478b1d0796c4f0 +Subproject commit 4543531709ee10a00d2e91192cdae17726f54cd1 diff --git a/unit-test/server/framework/QueryImp.h b/unit-test/server/framework/QueryImp.h index d597cd42..f3289942 100755 --- a/unit-test/server/framework/QueryImp.h +++ b/unit-test/server/framework/QueryImp.h @@ -71,6 +71,13 @@ class QueryImp: public QueryF */ Int32 findObjectByIdInSameSet(const std::string & id,const std::string & setId,vector &activeEp,vector &inactiveEp, tars::CurrentPtr current); + /** 查找某个obj部署在哪些节点上 (企业版功能) + * + * @param id obj名称 + * @return: 0-成功 others-失败 + */ + int findObjectNodeName(const string &id, vector &nodeName, CurrentPtr current) { return -1; }; + /** 注册数据通知, 同时上报本地缓存数据的最后时间, 如果服务端发现变化则全量推送(企业版功能) * 可以定时上报数据 * @param timestamp <数据类型, 最后数据时间戳> From c1ac4c0b8e027141b6c06c7303aa030d4ea0212a Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 2 Jan 2024 10:49:33 +0800 Subject: [PATCH 27/81] add ApplicationCommunicator to support multi Appliations in one process --- servant/libservant/Application.cpp | 91 +++++++++++++++----------- servant/libservant/Communicator.cpp | 7 ++ servant/libservant/EndpointManager.cpp | 29 ++++---- servant/libservant/RemoteConfig.cpp | 3 +- servant/libservant/RemoteLogger.cpp | 1 - servant/libservant/ServantHandle.cpp | 5 +- servant/protocol | 2 +- servant/servant/Application.h | 16 ++++- servant/servant/Communicator.h | 14 +++- servant/servant/EndpointManager.h | 5 -- 10 files changed, 108 insertions(+), 65 deletions(-) diff --git a/servant/libservant/Application.cpp b/servant/libservant/Application.cpp index 340bfea8..f8c3759f 100644 --- a/servant/libservant/Application.cpp +++ b/servant/libservant/Application.cpp @@ -181,6 +181,11 @@ CommunicatorPtr& Application::getCommunicator() return _communicator; } +CommunicatorPtr& Application::getApplicationCommunicator() +{ + return _applicationCommunicator; +} + void reportRspQueue(TC_EpollServer *epollServer) { if (!g_pReportRspQueue) @@ -551,23 +556,23 @@ bool Application::cmdLoadProperty(const string& command, const string& params, s string sResult; //加载通讯器属性 - _communicator->setProperty(_conf); + _applicationCommunicator->setProperty(_conf); - _communicator->reloadProperty(sResult); + _applicationCommunicator->reloadProperty(sResult); //加载远程对象 _serverBaseInfo.Log = _conf.get("/tars/application/server"); // ServerConfig::Log = _serverBaseInfo.Log; - RemoteTimeLogger::getInstance()->setLogInfo(_communicator, _serverBaseInfo.Log, _serverBaseInfo.Application, _serverBaseInfo.ServerName, _serverBaseInfo.LogPath,setDivision()); + RemoteTimeLogger::getInstance()->setLogInfo(_applicationCommunicator, _serverBaseInfo.Log, _serverBaseInfo.Application, _serverBaseInfo.ServerName, _serverBaseInfo.LogPath,setDivision()); _serverBaseInfo.Config = _conf.get("/tars/application/server"); - _remoteConfig->setConfigInfo(_communicator, _serverBaseInfo.Config, _serverBaseInfo.Application, _serverBaseInfo.ServerName, _serverBaseInfo.BasePath, setDivision(), 5, _serverBaseInfo.Context); + _remoteConfig->setConfigInfo(_applicationCommunicator, _serverBaseInfo.Config, _serverBaseInfo.Application, _serverBaseInfo.ServerName, _serverBaseInfo.BasePath, setDivision(), 5, _serverBaseInfo.Context); _serverBaseInfo.Notify = _conf.get("/tars/application/server"); - RemoteNotify::getInstance()->setNotifyInfo(_communicator, _serverBaseInfo.Notify, _serverBaseInfo.Application, _serverBaseInfo.ServerName, setDivision(), _serverBaseInfo.NodeName); + RemoteNotify::getInstance()->setNotifyInfo(_applicationCommunicator, _serverBaseInfo.Notify, _serverBaseInfo.Application, _serverBaseInfo.ServerName, setDivision(), _serverBaseInfo.NodeName); result = "loaded config items:\r\n" + sResult + "log=" + _serverBaseInfo.Log + "\r\n" + @@ -659,8 +664,8 @@ bool Application::cmdReloadLocator(const string& command, const string& params, } else { - _communicator->setProperty("locator", sLocator); - _communicator->reloadLocator(); + _applicationCommunicator->setProperty("locator", sLocator); + _applicationCommunicator->reloadLocator(); result = sLocator + " set succ."; } @@ -680,7 +685,7 @@ bool Application::cmdViewResource(const string& command, const string& params, s ostringstream os; - os << _communicator->getResourcesInfo() << endl; + os << _applicationCommunicator->getResourcesInfo() << endl; os << OUT_LINE << endl; @@ -866,7 +871,7 @@ void Application::main(const string &config) } } - if (!_communicator->getProperty("locator").empty() && _serverBaseInfo.BakType > 0) + if (!_applicationCommunicator->getProperty("locator").empty() && _serverBaseInfo.BakType > 0) { int timeout = TC_Common::strto(_conf.get("/tars/application/server", "5000")); if (timeout < 5000) @@ -1023,7 +1028,16 @@ void Application::initializeClient() __out__.info() << "\n" << OUT_LINE_LONG << endl; //初始化通信器 - _communicator = CommunicatorFactory::getInstance()->getCommunicator(_conf); + if(!_communicator) + { + _communicator = CommunicatorFactory::getInstance()->getCommunicator(_conf); + _applicationCommunicator = _communicator; + } + else + { + //一个进程内嵌多个Application时发生, 正常业务服务不会发生 + _applicationCommunicator = CommunicatorFactory::getInstance()->getCommunicator(_conf, TC_Common::tostr(this)); + } __out__.info() << TC_Common::outfill("[proxy config]:") << endl; @@ -1038,19 +1052,19 @@ void Application::outClient(ostream &os) { os << OUT_LINE << "\n" << TC_Common::outfill("[load client]:") << endl; - os << TC_Common::outfill("locator") << _communicator->getProperty("locator") << endl; - os << TC_Common::outfill("sync-invoke-timeout") << _communicator->getProperty("sync-invoke-timeout") << endl; - os << TC_Common::outfill("async-invoke-timeout") << _communicator->getProperty("async-invoke-timeout") << endl; - os << TC_Common::outfill("refresh-endpoint-interval") << _communicator->getProperty("refresh-endpoint-interval") << endl; - os << TC_Common::outfill("stat") << _communicator->getProperty("stat") << endl; - os << TC_Common::outfill("property") << _communicator->getProperty("property") << endl; - os << TC_Common::outfill("report-interval") << _communicator->getProperty("report-interval") << endl; - os << TC_Common::outfill("keep-alive-interval") << _communicator->getProperty("keep-alive-interval") << endl; - os << TC_Common::outfill("netthread") << _communicator->getProperty("netthread") << endl; - os << TC_Common::outfill("asyncthread") << _communicator->getProperty("asyncthread") << endl; - os << TC_Common::outfill("modulename") << _communicator->getProperty("modulename") << endl; - os << TC_Common::outfill("enableset") << _communicator->getProperty("enableset") << endl; - os << TC_Common::outfill("setdivision") << _communicator->getProperty("setdivision") << endl; + os << TC_Common::outfill("locator") << _applicationCommunicator->getProperty("locator") << endl; + os << TC_Common::outfill("sync-invoke-timeout") << _applicationCommunicator->getProperty("sync-invoke-timeout") << endl; + os << TC_Common::outfill("async-invoke-timeout") << _applicationCommunicator->getProperty("async-invoke-timeout") << endl; + os << TC_Common::outfill("refresh-endpoint-interval") << _applicationCommunicator->getProperty("refresh-endpoint-interval") << endl; + os << TC_Common::outfill("stat") << _applicationCommunicator->getProperty("stat") << endl; + os << TC_Common::outfill("property") << _applicationCommunicator->getProperty("property") << endl; + os << TC_Common::outfill("report-interval") << _applicationCommunicator->getProperty("report-interval") << endl; + os << TC_Common::outfill("keep-alive-interval") << _applicationCommunicator->getProperty("keep-alive-interval") << endl; + os << TC_Common::outfill("netthread") << _applicationCommunicator->getProperty("netthread") << endl; + os << TC_Common::outfill("asyncthread") << _applicationCommunicator->getProperty("asyncthread") << endl; + os << TC_Common::outfill("modulename") << _applicationCommunicator->getProperty("modulename") << endl; + os << TC_Common::outfill("enableset") << _applicationCommunicator->getProperty("enableset") << endl; + os << TC_Common::outfill("setdivision") << _applicationCommunicator->getProperty("setdivision") << endl; } string Application::toDefault(const string &s, const string &sDefault) @@ -1256,7 +1270,10 @@ void Application::initializeServer() } } } + + //设置节点名称, 请求tarsregistry会在context中带过去, 方便知道从哪来的请求 ServerConfig::Context["node_name"] = ServerConfig::NodeName; + _applicationCommunicator->setProperty("node_name", ServerConfig::NodeName); onServerConfig(); @@ -1307,7 +1324,7 @@ void Application::initializeServer() /////////////////////////////////////////////////////////////////////////////////////////////////// //初始化本地Log __out__.info() << OUT_LINE << "\n" << TC_Common::outfill("[set roll logger] ") << "OK" << endl; - LocalRollLogger::getInstance()->setLogInfo(ServerConfig::Application, ServerConfig::ServerName, ServerConfig::LogPath, ServerConfig::LogSize, ServerConfig::LogNum, _communicator, ServerConfig::Log); + LocalRollLogger::getInstance()->setLogInfo(ServerConfig::Application, ServerConfig::ServerName, ServerConfig::LogPath, ServerConfig::LogSize, ServerConfig::LogNum, _applicationCommunicator, ServerConfig::Log); _epollServer->setLocalLogger(LocalRollLogger::getInstance()->logger()); //初始化是日志为同步 @@ -1328,24 +1345,24 @@ void Application::initializeServer() //初始化到LogServer代理 __out__.info() << OUT_LINE << "\n" << TC_Common::outfill("[set time logger] ") << "OK" << endl; bool bLogStatReport = (_conf.get("/tars/application/server", "0") == "1") ? true : false; - RemoteTimeLogger::getInstance()->setLogInfo(_communicator, ServerConfig::Log, ServerConfig::Application, ServerConfig::ServerName, ServerConfig::LogPath, setDivision(), bLogStatReport); + RemoteTimeLogger::getInstance()->setLogInfo(_applicationCommunicator, ServerConfig::Log, ServerConfig::Application, ServerConfig::ServerName, ServerConfig::LogPath, setDivision(), bLogStatReport); /////////////////////////////////////////////////////////////////////////////////////////////////// //初始化到配置中心代理 __out__.info() << OUT_LINE << "\n" << TC_Common::outfill("[set remote config] ") << "OK" << endl; _remoteConfig = std::make_shared(); - _remoteConfig->setConfigInfo(_communicator, ServerConfig::Config, ServerConfig::Application, ServerConfig::ServerName, ServerConfig::BasePath, setDivision(), 5, ServerConfig::Context); + _remoteConfig->setConfigInfo(_applicationCommunicator, ServerConfig::Config, ServerConfig::Application, ServerConfig::ServerName, ServerConfig::BasePath, setDivision(), 5, ServerConfig::Context); /////////////////////////////////////////////////////////////////////////////////////////////////// //初始化到信息中心代理 __out__.info() << OUT_LINE << "\n" << TC_Common::outfill("[set remote notify] ") << "OK" << endl; - RemoteNotify::getInstance()->setNotifyInfo(_communicator, ServerConfig::Notify, ServerConfig::Application, ServerConfig::ServerName, setDivision(), ServerConfig::LocalIp); + RemoteNotify::getInstance()->setNotifyInfo(_applicationCommunicator, ServerConfig::Notify, ServerConfig::Application, ServerConfig::ServerName, setDivision(), ServerConfig::LocalIp); /////////////////////////////////////////////////////////////////////////////////////////////////// //初始化到Node的代理 __out__.info() << OUT_LINE << "\n" << TC_Common::outfill("[set node proxy]") << "OK" << endl; _keepAliveNodeFHelper = std::make_shared(); - _keepAliveNodeFHelper->setNodeInfo(_communicator, ServerConfig::Node, ServerConfig::Application, ServerConfig::ServerName); + _keepAliveNodeFHelper->setNodeInfo(_applicationCommunicator, ServerConfig::Node, ServerConfig::Application, ServerConfig::ServerName); /////////////////////////////////////////////////////////////////////////////////////////////////// //初始化管理对象 @@ -1378,7 +1395,7 @@ void Application::initializeServer() } //队列取平均值 - if(!_communicator->getProperty("property").empty()) + if(!_applicationCommunicator->getProperty("property").empty()) { string sRspQueue; sRspQueue += ServerConfig::Application; @@ -1386,7 +1403,7 @@ void Application::initializeServer() sRspQueue += ServerConfig::ServerName; sRspQueue += ".sendrspqueue"; - g_pReportRspQueue = _communicator->getStatReport()->createPropertyReport(sRspQueue, PropertyReport::avg()); + g_pReportRspQueue = _applicationCommunicator->getStatReport()->createPropertyReport(sRspQueue, PropertyReport::avg()); } TarsTimeLogger::getInstance()->enableLocal(TRACE_LOG_FILENAME, false); @@ -1505,23 +1522,23 @@ void Application::bindAdapter(vector& adapters) adapters.push_back(bindAdapter); //队列取平均值 - if(!_communicator->getProperty("property").empty()) + if(!_applicationCommunicator->getProperty("property").empty()) { PropertyReportPtr p; - p = _communicator->getStatReport()->createPropertyReport(bindAdapter->getName() + ".queue", PropertyReport::avg()); + p = _applicationCommunicator->getStatReport()->createPropertyReport(bindAdapter->getName() + ".queue", PropertyReport::avg()); bindAdapter->_pReportQueue = p.get(); - p = _communicator->getStatReport()->createPropertyReport(bindAdapter->getName() + ".connectRate", PropertyReport::avg()); + p = _applicationCommunicator->getStatReport()->createPropertyReport(bindAdapter->getName() + ".connectRate", PropertyReport::avg()); bindAdapter->_pReportConRate = p.get(); - p = _communicator->getStatReport()->createPropertyReport(bindAdapter->getName() + ".timeoutNum", PropertyReport::sum()); + p = _applicationCommunicator->getStatReport()->createPropertyReport(bindAdapter->getName() + ".timeoutNum", PropertyReport::sum()); bindAdapter->_pReportTimeoutNum = p.get(); - p = _communicator->getStatReport()->createPropertyReport(bindAdapter->getName() + ".queueWaitTime", + p = _applicationCommunicator->getStatReport()->createPropertyReport(bindAdapter->getName() + ".queueWaitTime", PropertyReport::avg(), PropertyReport::min(), PropertyReport::max(), PropertyReport::count()); bindAdapter->_pReportQueueWaitTime = p.get(); - p = _communicator->getStatReport()->createPropertyReport(bindAdapter->getName() + ".servantHandleTime", + p = _applicationCommunicator->getStatReport()->createPropertyReport(bindAdapter->getName() + ".servantHandleTime", PropertyReport::avg(), PropertyReport::min(), PropertyReport::max(), PropertyReport::count()); bindAdapter->_pReportServantHandleTime = p.get(); } @@ -1576,7 +1593,7 @@ void Application::checkMasterSlave(int timeout) bool firstCheck = true; - QueryFPrx queryFPrx = Application::getCommunicator()->stringToProxy(Application::getCommunicator()->getProperty("locator")); + QueryFPrx queryFPrx = _applicationCommunicator->stringToProxy(_applicationCommunicator->getProperty("locator")); do { diff --git a/servant/libservant/Communicator.cpp b/servant/libservant/Communicator.cpp index 822c5079..6bf309a0 100644 --- a/servant/libservant/Communicator.cpp +++ b/servant/libservant/Communicator.cpp @@ -420,6 +420,13 @@ void Communicator::initialize() propertyPrx->tars_open_keepalive(false); } + string locator = getProperty("locator", ""); + if(!locator.empty()) + { + _queryFPrx = stringToProxy(locator); + _queryFPrx->tars_open_keepalive(false); + } + string sSetDivision = ClientConfig::SetOpen ? ClientConfig::SetDivision : ""; _statReport->setReportInfo(statPrx, propertyPrx, ClientConfig::ModuleName, ClientConfig::LocalIp, sSetDivision, iReportInterval, 0, 0, iMaxReportSize, iReportTimeout); diff --git a/servant/libservant/EndpointManager.cpp b/servant/libservant/EndpointManager.cpp index 9a8d8889..52b2f402 100644 --- a/servant/libservant/EndpointManager.cpp +++ b/servant/libservant/EndpointManager.cpp @@ -383,6 +383,9 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) try { + map context; + context["node_name"] = _communicator->getProperty("node_name"); + if(bSync) { vector activeEp; @@ -392,17 +395,17 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) { case E_ALL: { - iRet = _queryFPrx->findObjectById4Any(_objName,activeEp,inactiveEp); + iRet = _queryFPrx->findObjectById4Any(_objName,activeEp,inactiveEp, context); break; } case E_STATION: { - iRet = _queryFPrx->findObjectByIdInSameStation(_objName,sName,activeEp,inactiveEp); + iRet = _queryFPrx->findObjectByIdInSameStation(_objName,sName,activeEp,inactiveEp, context); break; } case E_SET: { - iRet = _queryFPrx->findObjectByIdInSameSet(_objName,sName,activeEp,inactiveEp); + iRet = _queryFPrx->findObjectByIdInSameSet(_objName,sName,activeEp,inactiveEp, context); break; } case E_DEFAULT: @@ -412,11 +415,11 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) { //指定set调用时,指定set的优先级最高 string setId = _invokeSetId.empty()?ClientConfig::SetDivision:_invokeSetId; - iRet = _queryFPrx->findObjectByIdInSameSet(_objName,setId,activeEp,inactiveEp); + iRet = _queryFPrx->findObjectByIdInSameSet(_objName,setId,activeEp,inactiveEp, context); } else { - iRet = _queryFPrx->findObjectByIdInSameGroup(_objName,activeEp,inactiveEp); + iRet = _queryFPrx->findObjectByIdInSameGroup(_objName,activeEp,inactiveEp, context); } break; } @@ -429,17 +432,17 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) { case E_ALL: { - _queryFPrx->async_findObjectById4Any(this,_objName); + _queryFPrx->async_findObjectById4Any(this,_objName, context); break; } case E_STATION: { - _queryFPrx->async_findObjectByIdInSameStation(this,_objName,sName); + _queryFPrx->async_findObjectByIdInSameStation(this,_objName,sName, context); break; } case E_SET: { - _queryFPrx->async_findObjectByIdInSameSet(this,_objName,sName); + _queryFPrx->async_findObjectByIdInSameSet(this,_objName,sName, context); break; } case E_DEFAULT: @@ -449,25 +452,25 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) { //指定set调用时,指定set的优先级最高 string setId = _invokeSetId.empty()?ClientConfig::SetDivision:_invokeSetId; - _queryFPrx->async_findObjectByIdInSameSet(this,_objName,setId); + _queryFPrx->async_findObjectByIdInSameSet(this,_objName,setId, context); } else { - _queryFPrx->async_findObjectByIdInSameGroup(this,_objName); + _queryFPrx->async_findObjectByIdInSameGroup(this,_objName, context); } break; } }//end switch } } - catch(TC_Exception & ex) + catch(exception & ex) { - TLOGERROR("[QueryEpBase::refreshReg obj:"<<_objName<<"exception:"<destroy(); + if(_servant) + { + _servant->destroy(); + } } catch (exception &ex) { diff --git a/servant/protocol b/servant/protocol index 45435317..b4890b16 160000 --- a/servant/protocol +++ b/servant/protocol @@ -1 +1 @@ -Subproject commit 4543531709ee10a00d2e91192cdae17726f54cd1 +Subproject commit b4890b162b3466b3a8854c88a0fb203d9123fecf diff --git a/servant/servant/Application.h b/servant/servant/Application.h index d8f12b53..a2c37037 100644 --- a/servant/servant/Application.h +++ b/servant/servant/Application.h @@ -258,6 +258,12 @@ class Application: public BaseNotify */ static CommunicatorPtr& getCommunicator(); + /** + * application自己的通信器, 当一个进程中内嵌多个Application时出现, 否则等于getCommunicator() + * @return + */ + CommunicatorPtr& getApplicationCommunicator(); + /** * 获取服务Server对象 * @@ -654,6 +660,12 @@ class Application: public BaseNotify */ static CommunicatorPtr _communicator; + /** + * communicator 每个application都自带一个, 如果_communicator已经存在, 则创建新的, 否则和_communicatory一样 + * 解决一个进程中内嵌多个Application时, 共享通信器的问题! + */ + CommunicatorPtr _applicationCommunicator; + /** * accept */ @@ -685,9 +697,7 @@ class Application: public BaseNotify bool _terminateCheckMasterSlave = false; std::thread *_masterSlaveCheckThread = nullptr; //主备模式检查线程(企业版框架功能) -// PropertyReport * _pReportQueue{}; -// PropertyReport * _pReportConRate{}; -// PropertyReport * _pReportTimeoutNum{}; + }; //////////////////////////////////////////////////////////////////// } diff --git a/servant/servant/Communicator.h b/servant/servant/Communicator.h index c8813ac5..b1e6b914 100644 --- a/servant/servant/Communicator.h +++ b/servant/servant/Communicator.h @@ -26,7 +26,7 @@ #include "servant/AsyncProcThread.h" #include "servant/StatReport.h" #include "servant/RemoteLogger.h" - +#include "servant/QueryF.h" #include "util/tc_openssl.h" // #ifdef TARS_OPENTRACKING @@ -340,6 +340,11 @@ class SVT_DLL_API Communicator : public TC_HandleBase, public TC_ThreadRecMutex */ bool isTerminating(); + /** + * 如果没有配置locator, 则返回null + * @return + */ + const QueryFPrx &getLocatorPrx() { return _queryFPrx; } protected: /** * 初始化 @@ -477,7 +482,12 @@ class SVT_DLL_API Communicator : public TC_HandleBase, public TC_ThreadRecMutex */ map> _objInfo; - /** + /* + * 主控的路由代理 + */ + QueryFPrx _queryFPrx; + + /** * ServantProxy代码的工厂类 */ ServantProxyFactory* _servantProxyFactory; diff --git a/servant/servant/EndpointManager.h b/servant/servant/EndpointManager.h index 14f86138..4cb2bed1 100644 --- a/servant/servant/EndpointManager.h +++ b/servant/servant/EndpointManager.h @@ -159,11 +159,6 @@ class QueryEpBase : public QueryFPrxCallback */ void setObjName(const string & sObjName); -// /* -// * 解析endpoint -// */ -// vector sepEndpoint(const string& sEndpoints); - /* * 从sEndpoints提取ip列表信息 */ From ba07e69ee8c256184d1dc9657caba78a9ca7e43e Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 4 Jan 2024 17:37:11 +0800 Subject: [PATCH 28/81] ClientConfig change to Communicator subclass, no global static object fix StatReport interface, remove parameters not used ClientConfig add context, when call tarsserver with this context --- servant/libservant/AdapterProxy.cpp | 9 ++- servant/libservant/AppCache.cpp | 2 +- servant/libservant/Application.cpp | 18 ++--- servant/libservant/Communicator.cpp | 50 ++++++-------- servant/libservant/Current.cpp | 15 ++-- servant/libservant/EndpointManager.cpp | 39 +++++------ servant/libservant/ObjectProxy.cpp | 5 +- servant/libservant/RemoteConfig.cpp | 7 +- servant/libservant/RemoteLogger.cpp | 22 +++--- servant/libservant/RemoteNotify.cpp | 15 ++-- servant/libservant/ServantHandle.cpp | 14 ++-- servant/libservant/StatReport.cpp | 50 ++++++-------- servant/protocol | 2 +- servant/servant/Communicator.h | 95 ++++++++++++++++---------- servant/servant/PropertyReport.h | 2 +- servant/servant/RemoteConfig.h | 12 +--- servant/servant/RemoteLogger.h | 3 +- servant/servant/RemoteNotify.h | 7 +- servant/servant/StatReport.h | 31 ++------- 19 files changed, 187 insertions(+), 211 deletions(-) diff --git a/servant/libservant/AdapterProxy.cpp b/servant/libservant/AdapterProxy.cpp index 9bff278f..9a331b98 100755 --- a/servant/libservant/AdapterProxy.cpp +++ b/servant/libservant/AdapterProxy.cpp @@ -287,15 +287,18 @@ TC_NetWorkBuffer::PACKET_TYPE AdapterProxy::onVerifyAuthCallback(TC_NetWorkBuffe void AdapterProxy::initStatHead() { vector vtSetInfo; - if(!ClientConfig::SetDivision.empty() && StatReport::divison2SetInfo(ClientConfig::SetDivision, vtSetInfo)) { + + if(!_communicator->getClientConfig().SetDivision.empty() && StatReport::divison2SetInfo(_communicator->getClientConfig().SetDivision, vtSetInfo)) { //主调(client)启用set - _statHead.masterName = StatReport::trimAndLimitStr(ClientConfig::ModuleName + "." + vtSetInfo[0] + vtSetInfo[1] + vtSetInfo[2] + "@" + ClientConfig::TarsVersion, StatReport::MAX_MASTER_NAME_LEN); + _statHead.masterName = StatReport::trimAndLimitStr(_communicator->getClientConfig().ModuleName + "." + vtSetInfo[0] + vtSetInfo[1] + vtSetInfo[2] + "@" + _communicator->getClientConfig().TarsVersion, StatReport::MAX_MASTER_NAME_LEN); } else { - _statHead.masterName = StatReport::trimAndLimitStr(ClientConfig::ModuleName + "@" + ClientConfig::TarsVersion, StatReport::MAX_MASTER_NAME_LEN); + _statHead.masterName = StatReport::trimAndLimitStr(_communicator->getClientConfig().ModuleName + "@" + _communicator->getClientConfig().TarsVersion, StatReport::MAX_MASTER_NAME_LEN); } + _statHead.masterIp = _communicator->getClientConfig().NodeName; + string sSlaveSet = _ep.setDivision(); const string sSlaveName = getSlaveName(_objectProxy->name()); diff --git a/servant/libservant/AppCache.cpp b/servant/libservant/AppCache.cpp index 8bd4ac04..eebe2f09 100644 --- a/servant/libservant/AppCache.cpp +++ b/servant/libservant/AppCache.cpp @@ -119,7 +119,7 @@ int AppCache::set(const string &sName,const string &sValue,const string sDomain) if(_lastSynTime == 0) //第一次写数据 打印tarsversion { m.clear(); - m["tarsversion"] = ClientConfig::TarsVersion; + m["tarsversion"] = TARS_VERSION; tConf.insertDomainParam(string(APPCACHE_ROOT_PATH),m,true); } diff --git a/servant/libservant/Application.cpp b/servant/libservant/Application.cpp index f8c3759f..b4d46b8d 100644 --- a/servant/libservant/Application.cpp +++ b/servant/libservant/Application.cpp @@ -568,11 +568,11 @@ bool Application::cmdLoadProperty(const string& command, const string& params, s _serverBaseInfo.Config = _conf.get("/tars/application/server"); - _remoteConfig->setConfigInfo(_applicationCommunicator, _serverBaseInfo.Config, _serverBaseInfo.Application, _serverBaseInfo.ServerName, _serverBaseInfo.BasePath, setDivision(), 5, _serverBaseInfo.Context); + _remoteConfig->setConfigInfo(_applicationCommunicator, _serverBaseInfo.Config, _serverBaseInfo.Application, _serverBaseInfo.ServerName, _serverBaseInfo.BasePath, setDivision(), 5); _serverBaseInfo.Notify = _conf.get("/tars/application/server"); - RemoteNotify::getInstance()->setNotifyInfo(_applicationCommunicator, _serverBaseInfo.Notify, _serverBaseInfo.Application, _serverBaseInfo.ServerName, setDivision(), _serverBaseInfo.NodeName); + RemoteNotify::getInstance()->setNotifyInfo(_applicationCommunicator, _serverBaseInfo.Notify, _serverBaseInfo.Application, _serverBaseInfo.ServerName, setDivision()); result = "loaded config items:\r\n" + sResult + "log=" + _serverBaseInfo.Log + "\r\n" + @@ -1272,8 +1272,8 @@ void Application::initializeServer() } //设置节点名称, 请求tarsregistry会在context中带过去, 方便知道从哪来的请求 - ServerConfig::Context["node_name"] = ServerConfig::NodeName; - _applicationCommunicator->setProperty("node_name", ServerConfig::NodeName); + _applicationCommunicator->_clientConfig.NodeName = ServerConfig::NodeName; + _applicationCommunicator->_clientConfig.Context["node_name"] = ServerConfig::NodeName; onServerConfig(); @@ -1351,12 +1351,12 @@ void Application::initializeServer() //初始化到配置中心代理 __out__.info() << OUT_LINE << "\n" << TC_Common::outfill("[set remote config] ") << "OK" << endl; _remoteConfig = std::make_shared(); - _remoteConfig->setConfigInfo(_applicationCommunicator, ServerConfig::Config, ServerConfig::Application, ServerConfig::ServerName, ServerConfig::BasePath, setDivision(), 5, ServerConfig::Context); + _remoteConfig->setConfigInfo(_applicationCommunicator, ServerConfig::Config, ServerConfig::Application, ServerConfig::ServerName, ServerConfig::BasePath, setDivision(), 5); /////////////////////////////////////////////////////////////////////////////////////////////////// //初始化到信息中心代理 __out__.info() << OUT_LINE << "\n" << TC_Common::outfill("[set remote notify] ") << "OK" << endl; - RemoteNotify::getInstance()->setNotifyInfo(_applicationCommunicator, ServerConfig::Notify, ServerConfig::Application, ServerConfig::ServerName, setDivision(), ServerConfig::LocalIp); + RemoteNotify::getInstance()->setNotifyInfo(_applicationCommunicator, ServerConfig::Notify, ServerConfig::Application, ServerConfig::ServerName, setDivision()); /////////////////////////////////////////////////////////////////////////////////////////////////// //初始化到Node的代理 @@ -1397,11 +1397,7 @@ void Application::initializeServer() //队列取平均值 if(!_applicationCommunicator->getProperty("property").empty()) { - string sRspQueue; - sRspQueue += ServerConfig::Application; - sRspQueue += "."; - sRspQueue += ServerConfig::ServerName; - sRspQueue += ".sendrspqueue"; + string sRspQueue= "sendrspqueue"; g_pReportRspQueue = _applicationCommunicator->getStatReport()->createPropertyReport(sRspQueue, PropertyReport::avg()); } diff --git a/servant/libservant/Communicator.cpp b/servant/libservant/Communicator.cpp index 6bf309a0..50cc45d0 100644 --- a/servant/libservant/Communicator.cpp +++ b/servant/libservant/Communicator.cpp @@ -27,17 +27,7 @@ namespace tars ////////////////////////////////////////////////////////////////////////////////////////////// -string ClientConfig::LocalIp = "127.0.0.1"; -string ClientConfig::ModuleName = "unknown"; - -set ClientConfig::SetLocalIp; - -bool ClientConfig::SetOpen = false; - -string ClientConfig::SetDivision = ""; - -string ClientConfig::TarsVersion = string(TARS_VERSION); ////////////////////////////////////////////////////////////////////////////////////////////// @@ -250,15 +240,15 @@ void Communicator::initialize() }); - ClientConfig::TarsVersion = TARS_VERSION; + _clientConfig.TarsVersion = TARS_VERSION; - ClientConfig::SetOpen = TC_Common::lower(getProperty("enableset", "n")) == "y" ? true : false; + _clientConfig.SetOpen = TC_Common::lower(getProperty("enableset", "n")) == "y" ? true : false; - if (ClientConfig::SetOpen) + if (_clientConfig.SetOpen) { - ClientConfig::SetDivision = getProperty("setdivision"); + _clientConfig.SetDivision = getProperty("setdivision"); - vector vtSetDivisions = TC_Common::sepstr(ClientConfig::SetDivision, "."); + vector vtSetDivisions = TC_Common::sepstr(_clientConfig.SetDivision, "."); string sWildCard = "*"; @@ -267,24 +257,24 @@ void Communicator::initialize() || vtSetDivisions[1] == sWildCard) { //set分组名不对时默认没有打开set分组 - ClientConfig::SetOpen = false; + _clientConfig.SetOpen = false; setProperty("enableset", "n"); - TLOGERROR("[set division name error:" << ClientConfig::SetDivision << ", client failed to open set]" << endl); + TLOGERROR("[set division name error:" << _clientConfig.SetDivision << ", client failed to open set]" << endl); } } - ClientConfig::LocalIp = getProperty("localip", ""); + _clientConfig.LocalIp = getProperty("localip", ""); - if (ClientConfig::SetLocalIp.empty()) + if (_clientConfig.SetLocalIp.empty()) { vector v = TC_Socket::getLocalHosts(); for (size_t i = 0; i < v.size(); i++) { - if (v[i] != "127.0.0.1" && ClientConfig::LocalIp.empty()) + if (v[i] != "127.0.0.1" && _clientConfig.LocalIp.empty()) { - ClientConfig::LocalIp = v[i]; + _clientConfig.LocalIp = v[i]; } - ClientConfig::SetLocalIp.insert(v[i]); + _clientConfig.SetLocalIp.insert(v[i]); } } @@ -295,13 +285,13 @@ void Communicator::initialize() { exe = TC_File::extractFileName(TC_File::getExePath()); } - catch (TC_File_Exception& ex) + catch (exception& ex) { //取失败则使用ip代替进程名 - exe = ClientConfig::LocalIp; + exe = _clientConfig.LocalIp; } - ClientConfig::ModuleName = getProperty("modulename", exe); + _clientConfig.ModuleName = getProperty("modulename", exe); #if TARS_SSL @@ -386,7 +376,7 @@ void Communicator::initialize() } //异步队列数目上报 - _reportAsyncQueue= getStatReport()->createPropertyReport(ClientConfig::ModuleName + ".asyncqueue", PropertyReport::avg()); + _reportAsyncQueue= getStatReport()->createPropertyReport("asyncqueue", PropertyReport::avg()); //初始化统计上报接口 string statObj = getProperty("stat", ""); @@ -427,8 +417,8 @@ void Communicator::initialize() _queryFPrx->tars_open_keepalive(false); } - string sSetDivision = ClientConfig::SetOpen ? ClientConfig::SetDivision : ""; - _statReport->setReportInfo(statPrx, propertyPrx, ClientConfig::ModuleName, ClientConfig::LocalIp, sSetDivision, iReportInterval, 0, 0, iMaxReportSize, iReportTimeout); + string sSetDivision = _clientConfig.SetOpen ? _clientConfig.SetDivision : ""; + _statReport->setReportInfo(statPrx, propertyPrx, _clientConfig.ModuleName, _clientConfig.LocalIp, sSetDivision, iReportInterval, iMaxReportSize, iReportTimeout); #if TARS_OPENTRACKING string collector_host = getProperty("collector_host", ""); @@ -583,8 +573,8 @@ int Communicator::reloadProperty(string & sResult) propertyPrx = stringToProxy(propertyObj); } - string sSetDivision = ClientConfig::SetOpen ? ClientConfig::SetDivision : ""; - _statReport->setReportInfo(statPrx, propertyPrx, ClientConfig::ModuleName, ClientConfig::LocalIp, sSetDivision, iReportInterval, 0, 0, iMaxReportSize, iReportTimeout); + string sSetDivision = _clientConfig.SetOpen ? _clientConfig.SetDivision : ""; + _statReport->setReportInfo(statPrx, propertyPrx, _clientConfig.ModuleName, _clientConfig.LocalIp, sSetDivision, iReportInterval, iMaxReportSize, iReportTimeout); sResult = "locator=" + getProperty("locator", "") + "\r\n" + "stat=" + statObj + "\r\n" + "property=" + propertyObj + "\r\n" + diff --git a/servant/libservant/Current.cpp b/servant/libservant/Current.cpp index 56434c32..8d814900 100644 --- a/servant/libservant/Current.cpp +++ b/servant/libservant/Current.cpp @@ -51,8 +51,9 @@ Current::~Current() { reportToStat("stat_from_server"); } - else if (!_isTars && ServerConfig::ReportFlow) + else if (!_isTars && _servantHandle && _servantHandle->getApplication()->getServerBaseInfo().ReportFlow) { + //非tars客户端 从服务端上报调用信息 reportToStat("not_tars_client"); } @@ -423,11 +424,15 @@ TC_EpollServer::BindAdapter* Current::getBindAdapter() void Current::reportToStat(const string& sObj) { - StatReport* stat = Application::getCommunicator()->getStatReport(); - - if(stat && stat->getStatPrx()) + if(_servantHandle) { - stat->report(sObj, "", _request.sFuncName, _data->ip(), 0, (StatReport::StatResult)_ret, TNOWMS - _data->recvTimeStamp(), 0, false); + StatReport *stat = _servantHandle->getApplication()->getApplicationCommunicator()->getStatReport(); + + if (stat && stat->getStatPrx()) + { + stat->report(sObj, "", _request.sFuncName, _data->ip(), 0, (StatReport::StatResult) _ret, + TNOWMS - _data->recvTimeStamp(), 0, false); + } } } diff --git a/servant/libservant/EndpointManager.cpp b/servant/libservant/EndpointManager.cpp index 52b2f402..fa4f8de3 100644 --- a/servant/libservant/EndpointManager.cpp +++ b/servant/libservant/EndpointManager.cpp @@ -163,9 +163,9 @@ void QueryEpBase::loadFromCache() string sLocatorKey = _locator; //如果启用set,则获取按set分组的缓存 - if (ClientConfig::SetOpen) + if (_communicator->getClientConfig().SetOpen) { - sLocatorKey += "_" + ClientConfig::SetDivision; + sLocatorKey += "_" + _communicator->getClientConfig().SetDivision; } string objName = _objName + string(_invokeSetId.empty() ? "" : ":") + _invokeSetId; @@ -383,9 +383,6 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) try { - map context; - context["node_name"] = _communicator->getProperty("node_name"); - if(bSync) { vector activeEp; @@ -395,31 +392,31 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) { case E_ALL: { - iRet = _queryFPrx->findObjectById4Any(_objName,activeEp,inactiveEp, context); + iRet = _queryFPrx->findObjectById4Any(_objName,activeEp,inactiveEp, _communicator->getClientConfig().Context); break; } case E_STATION: { - iRet = _queryFPrx->findObjectByIdInSameStation(_objName,sName,activeEp,inactiveEp, context); + iRet = _queryFPrx->findObjectByIdInSameStation(_objName,sName,activeEp,inactiveEp, _communicator->getClientConfig().Context); break; } case E_SET: { - iRet = _queryFPrx->findObjectByIdInSameSet(_objName,sName,activeEp,inactiveEp, context); + iRet = _queryFPrx->findObjectByIdInSameSet(_objName,sName,activeEp,inactiveEp, _communicator->getClientConfig().Context); break; } case E_DEFAULT: default: { - if(ClientConfig::SetOpen || !_invokeSetId.empty()) + if(_communicator->getClientConfig().SetOpen || !_invokeSetId.empty()) { //指定set调用时,指定set的优先级最高 - string setId = _invokeSetId.empty()?ClientConfig::SetDivision:_invokeSetId; - iRet = _queryFPrx->findObjectByIdInSameSet(_objName,setId,activeEp,inactiveEp, context); + string setId = _invokeSetId.empty()?_communicator->getClientConfig().SetDivision:_invokeSetId; + iRet = _queryFPrx->findObjectByIdInSameSet(_objName,setId,activeEp,inactiveEp, _communicator->getClientConfig().Context); } else { - iRet = _queryFPrx->findObjectByIdInSameGroup(_objName,activeEp,inactiveEp, context); + iRet = _queryFPrx->findObjectByIdInSameGroup(_objName,activeEp,inactiveEp, _communicator->getClientConfig().Context); } break; } @@ -432,31 +429,31 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) { case E_ALL: { - _queryFPrx->async_findObjectById4Any(this,_objName, context); + _queryFPrx->async_findObjectById4Any(this,_objName, _communicator->getClientConfig().Context); break; } case E_STATION: { - _queryFPrx->async_findObjectByIdInSameStation(this,_objName,sName, context); + _queryFPrx->async_findObjectByIdInSameStation(this,_objName,sName, _communicator->getClientConfig().Context); break; } case E_SET: { - _queryFPrx->async_findObjectByIdInSameSet(this,_objName,sName, context); + _queryFPrx->async_findObjectByIdInSameSet(this,_objName,sName, _communicator->getClientConfig().Context); break; } case E_DEFAULT: default: { - if(ClientConfig::SetOpen || !_invokeSetId.empty()) + if(_communicator->getClientConfig().SetOpen || !_invokeSetId.empty()) { //指定set调用时,指定set的优先级最高 - string setId = _invokeSetId.empty()?ClientConfig::SetDivision:_invokeSetId; - _queryFPrx->async_findObjectByIdInSameSet(this,_objName,setId, context); + string setId = _invokeSetId.empty()?_communicator->getClientConfig().SetDivision:_invokeSetId; + _queryFPrx->async_findObjectByIdInSameSet(this,_objName,setId, _communicator->getClientConfig().Context); } else { - _queryFPrx->async_findObjectByIdInSameGroup(this,_objName, context); + _queryFPrx->async_findObjectByIdInSameGroup(this,_objName, _communicator->getClientConfig().Context); } break; } @@ -663,9 +660,9 @@ void QueryEpBase::setEndPointToCache(bool bInactive) //如果启用set,则按set分组保存 string sLocatorKey = _locator; - if(ClientConfig::SetOpen) + if(_communicator->getClientConfig().SetOpen) { - sLocatorKey += "_" + ClientConfig::SetDivision; + sLocatorKey += "_" + _communicator->getClientConfig().SetDivision; } string objName = _objName + string(_invokeSetId.empty()?"":":") + _invokeSetId; if(bInactive) diff --git a/servant/libservant/ObjectProxy.cpp b/servant/libservant/ObjectProxy.cpp index a7735435..c0f56df2 100755 --- a/servant/libservant/ObjectProxy.cpp +++ b/servant/libservant/ObjectProxy.cpp @@ -26,7 +26,6 @@ namespace tars { -/////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// ObjectProxy::ObjectProxy(CommunicatorEpoll *pCommunicatorEpoll, ServantProxy *servantProxy, const string & sObjectProxyName,const string& setName) @@ -47,10 +46,10 @@ ObjectProxy::ObjectProxy(CommunicatorEpoll *pCommunicatorEpoll, ServantProxy *se { _name = sObjectProxyName; //启用set或者指定set调用 - if(ClientConfig::SetOpen || !_invokeSetId.empty()) + if(pCommunicatorEpoll->getCommunicator()->getClientConfig().SetOpen || !_invokeSetId.empty()) { //指定set调用时,指定set的优先级最高 - _invokeSetId = _invokeSetId.empty()?ClientConfig::SetDivision:_invokeSetId; + _invokeSetId = _invokeSetId.empty()?pCommunicatorEpoll->getCommunicator()->getClientConfig().SetDivision:_invokeSetId; _isInvokeBySet = true; } } diff --git a/servant/libservant/RemoteConfig.cpp b/servant/libservant/RemoteConfig.cpp index 8e0c0631..8fe3068a 100755 --- a/servant/libservant/RemoteConfig.cpp +++ b/servant/libservant/RemoteConfig.cpp @@ -27,7 +27,7 @@ namespace tars int RemoteConfig::setConfigInfo(const CommunicatorPtr &comm, const string &obj, const string &app, const string &serverName, - const string &basePath, const string &setdivision, int maxBakNum, const map &context) + const string &basePath, const string &setdivision, int maxBakNum) { TC_LockT lock(_mutex); @@ -41,7 +41,6 @@ RemoteConfig::setConfigInfo(const CommunicatorPtr &comm, const string &obj, cons _app = app; _serverName = serverName; _basePath = basePath; - _context = context; _maxBakNum = maxBakNum; _setdivision = setdivision; return 0; @@ -117,7 +116,7 @@ string RemoteConfig::getRemoteFile(const string &sFileName, bool bAppConfigOnly) { if (_setdivision.empty()) { - ret = _configPrx->loadConfig(_app, (bAppConfigOnly ? "" : _serverName), sFileName, stream, _context); + ret = _configPrx->loadConfig(_app, (bAppConfigOnly ? "" : _serverName), sFileName, stream, _comm->getClientConfig().Context); } else { struct ConfigInfo confInfo; @@ -126,7 +125,7 @@ string RemoteConfig::getRemoteFile(const string &sFileName, bool bAppConfigOnly) confInfo.filename = sFileName; confInfo.bAppOnly = bAppConfigOnly; confInfo.setdivision = _setdivision; - ret = _configPrx->loadConfigByInfo(confInfo, stream, _context); + ret = _configPrx->loadConfigByInfo(confInfo, stream, _comm->getClientConfig().Context); } break; diff --git a/servant/libservant/RemoteLogger.cpp b/servant/libservant/RemoteLogger.cpp index 2f753160..ef3b86ad 100644 --- a/servant/libservant/RemoteLogger.cpp +++ b/servant/libservant/RemoteLogger.cpp @@ -84,7 +84,8 @@ void RollWriteT::operator()(ostream &of, const deque > &ds) { try { - _logPrx->logger(DYEING_DIR, DYEING_FILE, "roll", "%Y%m%d", vRemoteDyeing, ServerConfig::Context); + + _logPrx->logger(DYEING_DIR, DYEING_FILE, "roll", "%Y%m%d", vRemoteDyeing, _context); } catch(exception &ex) { @@ -93,14 +94,19 @@ void RollWriteT::operator()(ostream &of, const deque > &ds) } } -void RollWriteT::setDyeingLogInfo(const string &sApp, const string &sServer, const string & sLogPath, int iMaxSize, int iMaxNum, const LogPrx &logPrx, const string &sLogObj) +void RollWriteT::setDyeingLogInfo(const string &sApp, const string &sServer, const string & sLogPath, int iMaxSize, int iMaxNum, const LogPrx &logPrx) { _app = sApp; _server = sServer; _logPath = sLogPath; _maxSize = iMaxSize; _maxNum = iMaxNum; + _logPrx = logPrx; + if(_logPrx) + { + _context["node_name"] = _logPrx->tars_communicator()->getClientConfig().NodeName; + } } @@ -157,7 +163,7 @@ void LocalRollLogger::setLogInfo(const string &sApp, const string &sServer, cons sync(false); //设置染色日志信息 - _logger.getWriteT().setDyeingLogInfo(sApp, sServer, sLogpath, iMaxSize, iMaxNum, _logPrx, sLogObj); + _logger.getWriteT().setDyeingLogInfo(sApp, sServer, sLogpath, iMaxSize, iMaxNum, _logPrx); } @@ -228,7 +234,7 @@ LocalRollLogger::RollLogger *LocalRollLogger::logger(const string &suffix) logger->modFlag(TC_DayLogger::HAS_TIME|TC_DayLogger::HAS_LEVEL|TC_DayLogger::HAS_PID, true); //设置染色日志信息 - logger->getWriteT().setDyeingLogInfo(_app, _server, _logpath, _logger.getMaxSize(), _logger.getMaxSize(), _logPrx, _logObj); + logger->getWriteT().setDyeingLogInfo(_app, _server, _logpath, _logger.getMaxSize(), _logger.getMaxSize(), _logPrx); _logger_ex[suffix] = logger; @@ -348,7 +354,7 @@ void RemoteTimeWriteT::sync2remote(const vector &v) stInfo.sSepar = _timeWrite->_separ; stInfo.sLogType = _timeWrite->_logType; - _timeWrite->_logPrx->loggerbyInfo(stInfo,v, ServerConfig::Context); + _timeWrite->_logPrx->loggerbyInfo(stInfo,v, _timeWrite->_logPrx->tars_communicator()->getClientConfig().Context); if (_timeWrite->_reportSuccPtr) { @@ -370,7 +376,7 @@ void RemoteTimeWriteT::sync2remoteDyeing(const vector &v) { try { - _timeWrite->_logPrx->logger(DYEING_DIR, DYEING_FILE, "", _timeWrite->_format, v, ServerConfig::Context); + _timeWrite->_logPrx->logger(DYEING_DIR, DYEING_FILE, "", _timeWrite->_format, v, _timeWrite->_logPrx->tars_communicator()->getClientConfig().Context); } catch(exception &ex) { @@ -650,7 +656,7 @@ void RemoteTimeLogger::initTimeLogger(TimeLogger *pTimeLogger, const string &sFi PropertyReportPtr reportFailPtr = NULL; if (_remote && _logStatReport && _comm) { - string sKey = _app + "." + _server + "." + sFile; + string sKey = sFile; reportSuccPtr = _comm->getStatReport()->createPropertyReport(sKey + "_log_send_succ", PropertyReport::sum()); reportFailPtr = _comm->getStatReport()->createPropertyReport(sKey + "_log_send_fail", PropertyReport::sum()); } @@ -720,7 +726,7 @@ void RemoteTimeLogger::initTimeLogger(TimeLogger *pTimeLogger,const string &sApp PropertyReportPtr reportFailPtr = NULL; if (_remote && _logStatReport && _comm) { - string sKey = _app + "." + _server + "." + sFile; + string sKey = sFile; reportSuccPtr = _comm->getStatReport()->createPropertyReport(sKey + "_log_send_succ", PropertyReport::sum()); reportFailPtr = _comm->getStatReport()->createPropertyReport(sKey + "_log_send_fail", PropertyReport::sum()); } diff --git a/servant/libservant/RemoteNotify.cpp b/servant/libservant/RemoteNotify.cpp index 62004775..52a9177d 100644 --- a/servant/libservant/RemoteNotify.cpp +++ b/servant/libservant/RemoteNotify.cpp @@ -21,7 +21,7 @@ namespace tars { -int RemoteNotify::setNotifyInfo(const CommunicatorPtr &comm, const string &obj, const string & app, const string &serverName, const string &sSetName, const string &nodeName) +int RemoteNotify::setNotifyInfo(const CommunicatorPtr &comm, const string &obj, const string & app, const string &serverName, const string &sSetName) { _comm = comm; if(!obj.empty()) @@ -34,7 +34,6 @@ int RemoteNotify::setNotifyInfo(const CommunicatorPtr &comm, const string &obj, _setName = sSetName; _app = app; _serverName = serverName; - _nodeName = nodeName; return 0; } @@ -51,14 +50,14 @@ void RemoteNotify::report(const string &sResult, bool bSync) info.sSet = _setName; info.sThreadId = TC_Common::tostr(std::this_thread::get_id()); info.sMessage = sResult; - info.sNodeName = _nodeName; + info.sNodeName = _comm->getClientConfig().NodeName; if(!bSync) { - _notifyPrx->async_reportNotifyInfo(NULL, info); + _notifyPrx->async_reportNotifyInfo(NULL, info, _comm->getClientConfig().Context); } else { - _notifyPrx->reportNotifyInfo(info); + _notifyPrx->reportNotifyInfo(info, _comm->getClientConfig().Context); } } } @@ -86,8 +85,8 @@ void RemoteNotify::notify(NOTIFYLEVEL level, const string &sMessage) info.sThreadId = TC_Common::tostr(std::this_thread::get_id()); info.sMessage = sMessage; info.eLevel = level; - info.sNodeName = _nodeName; - _notifyPrx->async_reportNotifyInfo(NULL, info); + info.sNodeName = _comm->getClientConfig().NodeName; + _notifyPrx->async_reportNotifyInfo(NULL, info, _comm->getClientConfig().Context); } } catch(exception &ex) @@ -113,7 +112,7 @@ void RemoteNotify::report(const string &sMessage, const string & app, const stri info.sSet = ""; info.sMessage = sMessage; info.sNodeName = sNodeName; - _notifyPrx->async_reportNotifyInfo(NULL, info); + _notifyPrx->async_reportNotifyInfo(NULL, info, _comm->getClientConfig().Context); } } catch(exception &ex) diff --git a/servant/libservant/ServantHandle.cpp b/servant/libservant/ServantHandle.cpp index ed078583..8df2564e 100644 --- a/servant/libservant/ServantHandle.cpp +++ b/servant/libservant/ServantHandle.cpp @@ -459,7 +459,7 @@ bool ServantHandle::processCookie(const CurrentPtr ¤t, map bool ServantHandle::checkValidSetInvoke(const CurrentPtr ¤t) { /*是否允许检查合法性*/ - if (ServerConfig::IsCheckSet == 0) + if (_application->getServerBaseInfo().IsCheckSet == 0) { //不检查 return true; @@ -467,7 +467,7 @@ bool ServantHandle::checkValidSetInvoke(const CurrentPtr ¤t) bool isSetInvoke = IS_MSG_TYPE(current->getMessageType(), tars::TARSMESSAGETYPESETNAME); //客户端按set规则调用且服务端启用set - if (isSetInvoke && ClientConfig::SetOpen) + if (isSetInvoke && _application->getApplicationCommunicator()->getClientConfig().SetOpen) { /** * 合法性规则: @@ -486,18 +486,18 @@ bool ServantHandle::checkValidSetInvoke(const CurrentPtr ¤t) sSetName = setIt->second; - if (ClientConfig::SetDivision == sSetName) + if (_application->getApplicationCommunicator()->getClientConfig().SetDivision == sSetName) { return true; } else { //属于同一地区是也属于合法调用 - string setArea1 = ClientConfig::SetDivision.substr(0, ClientConfig::SetDivision.find_last_of(".")); + string setArea1 = _application->getApplicationCommunicator()->getClientConfig().SetDivision.substr(0, _application->getApplicationCommunicator()->getClientConfig().SetDivision.find_last_of(".")); string setArea2 = sSetName.substr(0, sSetName.find_last_of(".")); if (setArea1 == setArea2) { return true; - } else if (ClientConfig::SetDivision.substr(0, ClientConfig::SetDivision.find_first_of(".")) != + } else if (_application->getApplicationCommunicator()->getClientConfig().SetDivision.substr(0, _application->getApplicationCommunicator()->getClientConfig().SetDivision.find_first_of(".")) != sSetName.substr(0, sSetName.find_first_of("."))) { //属于不同的set之间调用也属于合法 @@ -509,7 +509,7 @@ bool ServantHandle::checkValidSetInvoke(const CurrentPtr ¤t) << current->getMessageType() << "|" << current->getServantName() << "|" << current->getFuncName() << "|client:" - << ClientConfig::SetDivision << "|server:" + << _application->getApplicationCommunicator()->getClientConfig().SetDivision << "|server:" << sSetName << "]" << endl); current->sendResponse(TARSINVOKEBYINVALIDESET); return false; @@ -522,7 +522,7 @@ bool ServantHandle::checkValidSetInvoke(const CurrentPtr ¤t) << current->getMessageType() << "|" << current->getServantName() << "|" << current->getFuncName() << "|client:" - << ClientConfig::SetDivision << "|server:" + << _application->getApplicationCommunicator()->getClientConfig().SetDivision << "|server:" << sSetName << "]" << endl); current->sendResponse(TARSINVOKEBYINVALIDESET); return false; diff --git a/servant/libservant/StatReport.cpp b/servant/libservant/StatReport.cpp index 4655182a..ce9cb295 100755 --- a/servant/libservant/StatReport.cpp +++ b/servant/libservant/StatReport.cpp @@ -37,9 +37,6 @@ StatReport::StatReport(Communicator* communicator) , _reportTimeout(5000) , _maxReportSize(MAX_REPORT_SIZE) , _terminate(false) -, _sampleRate(1) -, _maxSampleCount(500) -, _retValueNumLimit(10) { srand(time(NULL)); } @@ -69,8 +66,6 @@ void StatReport::setReportInfo(const StatFPrx& statPrx, const string& strModuleIp, const string& strSetDivision, int iReportInterval, - int iSampleRate, - unsigned int iMaxSampleCount, int iMaxReportSize, int iReportTimeout) { @@ -91,10 +86,6 @@ void StatReport::setReportInfo(const StatFPrx& statPrx, _reportTimeout = iReportTimeout < 5000 ? 5000 : iReportTimeout; - _sampleRate = (iSampleRate < 1)?1: iSampleRate; - - _maxSampleCount = iMaxSampleCount>500?500:iMaxSampleCount; - if ( iMaxReportSize < MIN_REPORT_SIZE || iMaxReportSize > MAX_REPORT_SIZE ) { _maxReportSize = MAX_REPORT_SIZE; @@ -209,19 +200,19 @@ bool StatReport::divison2SetInfo(const string& str, vector& vtSetInfo) return true; } -/* -tars.tarsstat to tarsstat -*/ -string StatReport::getServerName(string sModuleName) -{ - string::size_type pos = sModuleName.find("."); - if (pos != string::npos) - { - return sModuleName.substr(pos + 1); //+1:过滤. - } - return sModuleName; -} - +///* +//tars.tarsstat to tarsstat +//*/ +//string StatReport::getServerName(string sModuleName) +//{ +// string::size_type pos = sModuleName.find("."); +// if (pos != string::npos) +// { +// return sModuleName.substr(pos + 1); //+1:过滤. +// } +// return sModuleName; +//} +// void StatReport::report(const string& strModuleName, const string& setdivision, @@ -246,11 +237,11 @@ void StatReport::report(const string& strModuleName, { if (!_setName.empty()) { - head.masterName = _moduleName + "." + _setName + _setArea + _setID + "@" + ClientConfig::TarsVersion; + head.masterName = _moduleName + "." + _setName + _setArea + _setID + "@" + _communicator->getClientConfig().TarsVersion; } else { - head.masterName = _moduleName + "@" + ClientConfig::TarsVersion; + head.masterName = _moduleName + "@" + _communicator->getClientConfig().TarsVersion; } if (!setdivision.empty()) //被调没有启用set分组,slavename保持原样 @@ -338,7 +329,7 @@ void StatReport::report(const string& strMasterName, StatMicMsgHead head; StatMicMsgBody body; - head.masterName = trimAndLimitStr(strMasterName + "@" + ClientConfig::TarsVersion, MAX_MASTER_NAME_LEN); + head.masterName = trimAndLimitStr(strMasterName + "@" + _communicator->getClientConfig().TarsVersion, MAX_MASTER_NAME_LEN); head.masterIp = trimAndLimitStr(strMasterIp, MAX_MASTER_IP_LEN); head.slaveName = trimAndLimitStr(strSlaveName, MAX_MASTER_NAME_LEN); head.slaveIp = trimAndLimitStr(strSlaveIp, MAX_MASTER_IP_LEN); @@ -413,6 +404,7 @@ int StatReport::reportMicMsg(MapStatMicMsg& msg, bool bFromClient) msg.swap(mStatMsg); } + TLOGTARS("[StatReport::reportMicMsg get size:" << mStatMsg.size()<<"]"<< endl); for(MapStatMicMsg::iterator it = mStatMsg.begin(); it != mStatMsg.end(); it++) { @@ -425,7 +417,7 @@ int StatReport::reportMicMsg(MapStatMicMsg& msg, bool bFromClient) if(_statPrx) { TLOGTARS("[StatReport::reportMicMsg send size:" << mTemp.size()<<"]"<< endl); - _statPrx->tars_set_timeout(_reportTimeout)->async_reportMicMsg(NULL,mTemp,bFromClient, ServerConfig::Context); + _statPrx->tars_set_timeout(_reportTimeout)->async_reportMicMsg(NULL,mTemp,bFromClient, _communicator->getClientConfig().Context); } iLen = iTemLen; mTemp.clear(); @@ -447,7 +439,7 @@ int StatReport::reportMicMsg(MapStatMicMsg& msg, bool bFromClient) if(_statPrx) { TLOGTARS("[StatReport::reportMicMsg send size:" << mTemp.size()<<"]"<< endl); - _statPrx->tars_set_timeout(_reportTimeout)->async_reportMicMsg(NULL,mTemp,bFromClient, ServerConfig::Context); + _statPrx->tars_set_timeout(_reportTimeout)->async_reportMicMsg(NULL,mTemp,bFromClient, _communicator->getClientConfig().Context); } } return 0; @@ -592,7 +584,7 @@ int StatReport::reportPropMsg() if (_propertyPrx) { TLOGTARS("[StatReport::reportPropMsg send size:" << mTemp.size() << "]" << endl); - _propertyPrx->tars_set_timeout(_reportTimeout)->async_reportPropMsg(NULL, mTemp, ServerConfig::Context); + _propertyPrx->tars_set_timeout(_reportTimeout)->async_reportPropMsg(NULL, mTemp, _communicator->getClientConfig().Context); } iLen = iTemLen; mTemp.clear(); @@ -604,7 +596,7 @@ int StatReport::reportPropMsg() if (_propertyPrx) { TLOGTARS("[StatReport::reportPropMsg send size:" << mTemp.size() << "]" << endl); - _propertyPrx->tars_set_timeout(_reportTimeout)->async_reportPropMsg(NULL, mTemp, ServerConfig::Context); + _propertyPrx->tars_set_timeout(_reportTimeout)->async_reportPropMsg(NULL, mTemp, _communicator->getClientConfig().Context); } } return 0; diff --git a/servant/protocol b/servant/protocol index b4890b16..bbae12db 160000 --- a/servant/protocol +++ b/servant/protocol @@ -1 +1 @@ -Subproject commit b4890b162b3466b3a8854c88a0fb203d9123fecf +Subproject commit bbae12db66dc96b651fe1545a6b7387e1ec02091 diff --git a/servant/servant/Communicator.h b/servant/servant/Communicator.h index b1e6b914..adbe98c4 100644 --- a/servant/servant/Communicator.h +++ b/servant/servant/Communicator.h @@ -115,38 +115,6 @@ class CommunicatorEpoll; class TC_OpenSSL; //////////////////////////////////////////////////////////////////////// -/** - * 客户端配置 - */ -struct ClientConfig -{ - /** - * 客户端IP地址 - */ - static string LocalIp; - /** - * 客户端模块名称 - */ - static string ModuleName; - /** - * 客户端所有的IP地址 - */ - static set SetLocalIp; - /** - *客户端是否打开set分组 - */ - static bool SetOpen; - /** - *客户端set分组 - */ - static string SetDivision; - - /** - * 客户端的版本号 - */ - static string TarsVersion; -}; - //////////////////////////////////////////////////////////////////////// /** * 通信器,用于创建和维护客户端proxy @@ -154,8 +122,52 @@ struct ClientConfig class SVT_DLL_API Communicator : public TC_HandleBase, public TC_ThreadRecMutex { public: - - typedef std::function custom_callback; + /** + * 客户端配置 + */ + struct ClientConfig + { + /** + * 客户端IP地址 + */ + string LocalIp = "127.0.0.1"; + + /** + * 部署的节点名称, 如果独立客户端则为LocalIp; + */ + string NodeName; + + /** + * 访问框架服务时, 传入的context, 目前: ["node_name"] = NodeName + */ + map Context; + + /** + * 客户端模块名称 + */ + string ModuleName; + + /** + * 客户端所有的IP地址 + */ + set SetLocalIp; + + /** + *客户端是否打开set分组 + */ + bool SetOpen = false; + /** + *客户端set分组 + */ + string SetDivision; + + /** + * 客户端的版本号 + */ + string TarsVersion; + }; + + typedef std::function custom_callback; /** * 构造函数 @@ -345,6 +357,13 @@ class SVT_DLL_API Communicator : public TC_HandleBase, public TC_ThreadRecMutex * @return */ const QueryFPrx &getLocatorPrx() { return _queryFPrx; } + + /** + * 获取set等信息 + * @return + */ + const ClientConfig &getClientConfig() const { return _clientConfig; } + protected: /** * 初始化 @@ -445,6 +464,8 @@ class SVT_DLL_API Communicator : public TC_HandleBase, public TC_ThreadRecMutex /** * 框架内部需要直接访问通信器的类 */ + friend class Application; + friend class AdapterProxy; friend class ServantProxy; @@ -576,7 +597,11 @@ class SVT_DLL_API Communicator : public TC_HandleBase, public TC_ThreadRecMutex * 注册事件 */ size_t _sigId = -1; - + + /** + * 客户端配置 + */ + ClientConfig _clientConfig; // #ifdef TARS_OPENTRACKING // public: // struct TraceManager:public TC_HandleBase{ diff --git a/servant/servant/PropertyReport.h b/servant/servant/PropertyReport.h index fbcd3004..e10b2942 100755 --- a/servant/servant/PropertyReport.h +++ b/servant/servant/PropertyReport.h @@ -87,7 +87,7 @@ class PropertyReport : public TC_HandleBase }; /** - * 分布 + * 分布(不建议再使用了) */ class distr { diff --git a/servant/servant/RemoteConfig.h b/servant/servant/RemoteConfig.h index 8eae8ed4..a72f8efd 100644 --- a/servant/servant/RemoteConfig.h +++ b/servant/servant/RemoteConfig.h @@ -60,7 +60,7 @@ class SVT_DLL_API RemoteConfig //: public TC_Singleton * * @return int */ - int setConfigInfo(const CommunicatorPtr &comm, const string &obj, const string & app, const string &serverName, const string& basePath, const string& setdivision="",int maxBakNum = 5, const map &context = {}); + int setConfigInfo(const CommunicatorPtr &comm, const string &obj, const string & app, const string &serverName, const string& basePath, const string& setdivision="",int maxBakNum = 5); /** * 读取ConfigServer上配置文件到本地,并备份原文件 @@ -108,11 +108,6 @@ class SVT_DLL_API RemoteConfig //: public TC_Singleton */ inline void localRename(const string& oldFile, const string& newFile); -// /** -// * 获取hostname, 给k8s版本使用 -// */ -// string getHostName(); - protected: /** @@ -140,11 +135,6 @@ class SVT_DLL_API RemoteConfig //: public TC_Singleton */ string _basePath; - /** - * - */ - map _context; - /** * set信息 */ diff --git a/servant/servant/RemoteLogger.h b/servant/servant/RemoteLogger.h index ecb8b53d..98ad441b 100755 --- a/servant/servant/RemoteLogger.h +++ b/servant/servant/RemoteLogger.h @@ -69,7 +69,7 @@ class RollWriteT void operator()(ostream &of, const deque > &ds); - void setDyeingLogInfo(const string &sApp, const string &sServer, const string & sLogPath, int iMaxSize, int iMaxNum, const LogPrx &logPrx, const string & sLogObj); + void setDyeingLogInfo(const string &sApp, const string &sServer, const string & sLogPath, int iMaxSize, int iMaxNum, const LogPrx &logPrx); protected: @@ -86,6 +86,7 @@ class RollWriteT */ LogPrx _logPrx; + map _context; }; diff --git a/servant/servant/RemoteNotify.h b/servant/servant/RemoteNotify.h index 4b86187c..809bc9d6 100644 --- a/servant/servant/RemoteNotify.h +++ b/servant/servant/RemoteNotify.h @@ -43,7 +43,7 @@ class SVT_DLL_API RemoteNotify : public TC_Singleton * * @return int */ - int setNotifyInfo(const CommunicatorPtr &comm, const string &obj, const string & app, const string &serverName, const string &sSetName, const string &nodeName); + int setNotifyInfo(const CommunicatorPtr &comm, const string &obj, const string & app, const string &serverName, const string &sSetName); /** * 通知, 一定是异步上报的 @@ -89,11 +89,6 @@ class SVT_DLL_API RemoteNotify : public TC_Singleton *set 名字 */ string _setName; - - /* - *节点 - */ - string _nodeName; }; } diff --git a/servant/servant/StatReport.h b/servant/servant/StatReport.h index 2561222d..fb2defc8 100644 --- a/servant/servant/StatReport.h +++ b/servant/servant/StatReport.h @@ -26,16 +26,7 @@ ///////////////////////////////////////////////////////////////////////// /* 属性上报使用方式: - StatReport report; - report->setReportInfo( pPtr,strMasterName,strMasterIp, 5 ); - vector v; - v.push_back(1000); - v.push_back(1001); - v.push_back(1002); - v.push_back(1003); - v.push_back(1004); - - PropertyReportPtr srPtr = report->createPropertyReport("test", PropertyReport::sum(), PropertyReport::dist(v)); + PropertyReportPtr srPtr = report->createPropertyReport("test", PropertyReport::sum()); srPtr->report(i); */ @@ -87,8 +78,6 @@ class StatReport : public TC_HandleBase, public TC_Thread, public TC_ThreadLock * @param strModuleIp, 模块ip * @param iReportInterval, 上报间隔单位秒 * @param iMaxReporSize一次最大上报包长度。 跟udp最大允许包8k、MTU长度1472有关,暂定取值范围[500-1400] - * @param iSampleRate, 采样比率1/1000 - * @param iMaxSampleCount, 最大采样数 * @param iReportTimeout, 上报接口调用的超时时间 * @param sContainer, 设置上报的容器名 */ @@ -98,8 +87,6 @@ class StatReport : public TC_HandleBase, public TC_Thread, public TC_ThreadLock const string& strModuleIp, const string& strSetDivision, int iReportInterval = 60, - int iSampleRate = 1000, - unsigned int iMaxSampleCount = 100, int iMaxReportSize = 1400, int iReportTimeout = 5000); @@ -244,10 +231,10 @@ class StatReport : public TC_HandleBase, public TC_Thread, public TC_ThreadLock */ static bool divison2SetInfo(const string& str, vector& vtSetInfo); - /* - * func: tars.xxxServer =>> xxxServer - */ - static string getServerName(string sModuleName); +// /* +// * func: tars.xxxServer =>> xxxServer +// */ +// static string getServerName(string sModuleName); private: @@ -301,10 +288,6 @@ class StatReport : public TC_HandleBase, public TC_Thread, public TC_ThreadLock string _ip; - int _sampleRate; //生成模块间调用时序图的采样比率 - - unsigned int _maxSampleCount; //1分钟内最大采样条数 - StatFPrx _statPrx; MapStatMicMsg _statMicMsgClient; @@ -317,10 +300,6 @@ class StatReport : public TC_HandleBase, public TC_Thread, public TC_ThreadLock map _statPropMsg; -private: - - size_t _retValueNumLimit; - }; /////////////////////////////////////////////////////////// } From 9df9a8895feb007ca267a1fc45568f745e974df5 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Sat, 6 Jan 2024 11:55:09 +0800 Subject: [PATCH 29/81] fix current report stat --- servant/libservant/Application.cpp | 5 ++ servant/libservant/Current.cpp | 125 +++++++++++++++------------ servant/libservant/ServantHandle.cpp | 10 +-- servant/servant/Application.h | 6 ++ servant/servant/Current.h | 47 +++++----- servant/servant/ServantHandle.h | 2 +- servant/servant/StatReport.h | 3 + tools/tars2cpp/tars2cpp.cpp | 2 +- 8 files changed, 116 insertions(+), 84 deletions(-) diff --git a/servant/libservant/Application.cpp b/servant/libservant/Application.cpp index b4d46b8d..ed3d0346 100644 --- a/servant/libservant/Application.cpp +++ b/servant/libservant/Application.cpp @@ -1115,6 +1115,11 @@ TC_EpollServer::BindAdapterPtr Application::getBindAdapter(const string &obj) return _epollServer->getBindAdapter(adapter); } +bool Application::isTerminate() +{ + return !_epollServer || _epollServer->isTerminate(); +} + //void Application::addServantOnClose(const string& servant, const TC_EpollServer::close_functor& cf) //{ // string adapterName = _servantHelper->getServantAdapter(servant); diff --git a/servant/libservant/Current.cpp b/servant/libservant/Current.cpp index 8d814900..ca1eeb88 100644 --- a/servant/libservant/Current.cpp +++ b/servant/libservant/Current.cpp @@ -24,11 +24,11 @@ namespace tars { ////////////////////////////////////////////////////////////////// -Current::Current(ServantHandle *pServantHandle) +Current::Current(const shared_ptr & pServantHandle) : _servantHandle(pServantHandle) , _response(true) , _ret(0) - , _reportStat(true) +// , _reportStat(true) , _traceCall(false) { @@ -36,28 +36,34 @@ Current::Current(ServantHandle *pServantHandle) Current::~Current() { - //TUP调用或单向调用,从服务端上报调用信息 - if(_reportStat) - { - if(_request.iVersion == TUPVERSION ) - { - reportToStat("tup_client"); - } - else if(_request.cPacketType == TARSONEWAY) - { - reportToStat("one_way_client"); - } - else if(_request.cPacketType == TARSNORMAL) - { - reportToStat("stat_from_server"); - } - else if (!_isTars && _servantHandle && _servantHandle->getApplication()->getServerBaseInfo().ReportFlow) - { - - //非tars客户端 从服务端上报调用信息 - reportToStat("not_tars_client"); - } - } +// //TUP调用或单向调用,从服务端上报调用信息 +// if(_reportStat && _servantHandle->getApplication()->getServerBaseInfo().ReportFlow && _servantHandle && _servantHandle->getApplication() && !_servantHandle->getApplication()->isTerminate() && !_servantHandle->getApplication()->getApplicationCommunicator()->isTerminating()) +// { +// StatReport *stat = _servantHandle->getApplication()->getApplicationCommunicator()->getStatReport(); +// +// if (stat && stat->getStatPrx()) +// { +// auto func = [&](const char *obj) +// { +// stat->report(obj, "", _request.sFuncName, _data->ip(), 0, (StatReport::StatResult) _ret, +// TNOWMS - _data->recvTimeStamp(), 0, false); +// }; +// +// if (_request.iVersion == TUPVERSION) +// { +// func("tup_client"); +// } else if (_request.cPacketType == TARSONEWAY) +// { +// func("one_way_client"); +// } else if (_request.cPacketType == TARSNORMAL) +// { +// func("stat_from_server"); +// } else if (!_isTars) +// { +// func("not_tars_client"); +// } +// } +// } } const string &Current::getHostName() const @@ -135,11 +141,16 @@ struct timeval Current::getRecvTime() const return tm; } -void Current::setReportStat(bool bReport) +int64_t Current::recvTimeStampUs() const { - _reportStat = bReport; + return _data->recvTimeStampUs(); } +//void Current::setReportStat(bool bReport) +//{ +// _reportStat = bReport; +//} +// const vector& Current::getRequestBuffer() const { if (_isTars) @@ -173,10 +184,6 @@ void Current::initialize(const shared_ptr &data) _data = data; -// Application *application = (Application*)this->_servantHandle->getApplication(); - -// _request.sServantName = application->getServantHelper()->getAdapterServant(_data->adapter()->getName()); - _isTars = _data->adapter()->isTarsProtocol(); if (_isTars) @@ -193,11 +200,7 @@ void Current::initializeClose(const shared_ptr &dat { _data = data; -// Application *application = (Application*)this->_servantHandle->getApplication(); - _request.sServantName = this->_servantHandle->getServant()->getName(); - -// _request.sServantName = application->getServantHelper()->getAdapterServant(_data->adapter()->getName()); } void Current::initialize(const vector& sRecvBuffer) @@ -212,7 +215,6 @@ void Current::initialize(const vector& sRecvBuffer) void Current::sendResponse(const char *buff, uint32_t len) { shared_ptr send = _data->createSendContext(); - // send->buffer()->assign(buff, len); send->buffer()->addBuffer(buff, len); _servantHandle->sendResponse(send); } @@ -227,7 +229,7 @@ void Current::sendResponse(int iRet, const vector &buff) ResponsePacket response; response.sBuffer = buff; - sendResponse(iRet, response, TARS_STATUS(), ""); + sendResponse(iRet, response, {}, ""); } void Current::sendResponse(int iRet, const string &buff) @@ -240,27 +242,27 @@ void Current::sendResponse(int iRet, const string &buff) ResponsePacket response; response.sBuffer.assign(buff.begin(), buff.end()); - sendResponse(iRet, response, TARS_STATUS(), ""); + sendResponse(iRet, response, {}, ""); } void Current::sendResponse(int iRet) { ResponsePacket response; - sendResponse(iRet, response, TARS_STATUS(), ""); + sendResponse(iRet, response, {}, ""); } void Current::sendResponse(int iRet, tars::TarsOutputStream& os) { ResponsePacket response; os.swap(response.sBuffer); - sendResponse(iRet, response, TARS_STATUS(), ""); + sendResponse(iRet, response, {}, ""); } void Current::sendResponse(int iRet, tup::UniAttribute& attr) { ResponsePacket response; attr.encode(response.sBuffer); - sendResponse(iRet, response, TARS_STATUS(), ""); + sendResponse(iRet, response, {}, ""); } void Current::sendResponse(int iRet, ResponsePacket &response, const map& status, const string & sResultDesc) @@ -288,7 +290,7 @@ void Current::sendResponse(int iRet, ResponsePacket &response, const mapsetBuffer(ProxyProtocol::toBuffer(os)); + { + StatReport *stat = _servantHandle->getApplication()->getApplicationCommunicator()->getStatReport(); + + if (stat && stat->getStatPrx()) + { + stat->report("stat_from_server", "", getFuncName(), getIp(), 0, (StatReport::StatResult) _ret, + TNOWMS - recvTimeStampUs() / 1000, 0, false); + } + } + _servantHandle->sendResponse(send); } @@ -401,7 +413,7 @@ void Current::sendPushResponse(int iRet, const string &funcName, TarsOutputStrea void Current::close() { - if (_servantHandle) + if (_servantHandle && !_servantHandle->getApplication()->isTerminate()) { _servantHandle->close(_data); } @@ -409,7 +421,7 @@ void Current::close() ServantHandle* Current::getServantHandle() { - return _servantHandle; + return _servantHandle.get(); } string Current::getModuleName() @@ -421,20 +433,19 @@ TC_EpollServer::BindAdapter* Current::getBindAdapter() { return _data->adapter().get(); } - -void Current::reportToStat(const string& sObj) -{ - if(_servantHandle) - { - StatReport *stat = _servantHandle->getApplication()->getApplicationCommunicator()->getStatReport(); - - if (stat && stat->getStatPrx()) - { - stat->report(sObj, "", _request.sFuncName, _data->ip(), 0, (StatReport::StatResult) _ret, - TNOWMS - _data->recvTimeStamp(), 0, false); - } - } -} +// +//void Current::reportToStat(const string& sObj) +//{ +// if(_data->adapter() ) +// { +// StatReport *stat = comm->getStatReport(); +// +// if (stat && stat->getStatPrx()) +// { +// stat->report(sObj, "", _request.sFuncName, _data->ip(), 0, (StatReport::StatResult) _ret, TNOWMS - _data->recvTimeStamp(), 0, false); +// } +// } +//} void Current::setTrace(bool traceCall, const string& traceKey) { diff --git a/servant/libservant/ServantHandle.cpp b/servant/libservant/ServantHandle.cpp index 8df2564e..48103a43 100644 --- a/servant/libservant/ServantHandle.cpp +++ b/servant/libservant/ServantHandle.cpp @@ -217,7 +217,7 @@ void ServantHandle::heartbeat() CurrentPtr ServantHandle::createCurrent(const shared_ptr &data) { - CurrentPtr current = new Current(this); + CurrentPtr current = new Current(shared_from_this()); try { @@ -262,10 +262,10 @@ CurrentPtr ServantHandle::createCurrent(const shared_ptr &data) { - CurrentPtr current = new Current(this); + CurrentPtr current = new Current(shared_from_this()); current->initializeClose(data); - current->setReportStat(false); +// current->setReportStat(false); current->setCloseType(data->closeType()); return current; } @@ -551,7 +551,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) } //处理染色消息 - string dyeingKey = ""; + string dyeingKey; TarsDyeingSwitch dyeSwitch; if (processDye(current, dyeingKey)) { @@ -638,7 +638,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) //单向调用或者业务不需要同步返回 if (current->isResponse()) { - current->sendResponse(ret, response, Current::TARS_STATUS(), sResultDesc); + current->sendResponse(ret, response, {}, sResultDesc); } #ifdef TARS_OPENTRACKING finishTracking(ret, current); diff --git a/servant/servant/Application.h b/servant/servant/Application.h index a2c37037..3d7f358d 100644 --- a/servant/servant/Application.h +++ b/servant/servant/Application.h @@ -366,6 +366,12 @@ class Application: public BaseNotify */ const ServerBaseInfo &getServerBaseInfo() const { return _serverBaseInfo; } + /** + * 是否已经结束了 + * @return + */ + bool isTerminate(); + protected: /** * 初始化, 只会进程调用一次 diff --git a/servant/servant/Current.h b/servant/servant/Current.h index 79c3a95d..8af0160b 100644 --- a/servant/servant/Current.h +++ b/servant/servant/Current.h @@ -37,13 +37,13 @@ class Current : public TC_HandleBase public: typedef std::map TARS_STATUS; - typedef std::vector TARS_BUFFER; +// typedef std::vector TARS_BUFFER; /** * 构造函数 * @param pServantHandle */ - Current(ServantHandle *pServantHandle); + Current(const shared_ptr &pServantHandle); /** * 析构 @@ -193,10 +193,16 @@ class Current : public TC_HandleBase */ struct timeval getRecvTime() const; - /** - * 设置是否上报状态报告 - */ - void setReportStat(bool bReport); + /** + * 数据接收到时间(微秒) + * @return + */ + int64_t recvTimeStampUs() const; + +// /** +// * 设置是否上报状态报告 +// */ +// void setReportStat(bool bReport); /** * 获取RequestPacket @@ -229,28 +235,28 @@ class Current : public TC_HandleBase void sendResponse(int iRet, tup::UniAttribute& attr); /** - * tars协议的发送响应数据(仅TARS协议有效) + * tars协议的发送响应数据(仅TARS协议有效), 给底层包iRet和sBuffer复制, 序列化后发送, 生成的代码中调用 * @param iRet * @param buff */ void sendResponse(int iRet, const vector &buff); /** - * tars协议的发送响应数据(仅TARS协议有效) + * tars协议的发送响应数据(仅TARS协议有效), 给底层包iRet和sBuffer复制, 序列化后发送, 生成的代码中调用 * @param iRet * @param buff */ void sendResponse(int iRet, const string &buff); /** - * 普通协议的发送响应数据(非TARS协议有效) + * 普通协议的发送响应数据(非TARS协议有效), 直接发送buff裸数据 * @param buff * @param len */ void sendResponse(const char* buff, uint32_t len); /** - * + * tars协议使用 * @param iRet * @param response * @param status @@ -260,11 +266,12 @@ class Current : public TC_HandleBase void sendResponse(int iRet, ResponsePacket &response, const map& status, const string& sResultDesc); /** - * 针对Push消息的应答数据 + * push callback机制中, 针对Push消息的应答数据(自动生成的代码中使用, 一般业务不主动使用该函数) * @param buff * @param len */ void sendPushResponse(int iRet, const string &funcName, TarsOutputStream& oss, const map &context = tars::Current::TARS_STATUS()); + /** * 设置调用链追踪信息,服务端主动回包时用 * @param traceCall @@ -311,10 +318,10 @@ class Current : public TC_HandleBase */ void initialize(const vector &sRecvBuffer); - /** - * 服务端上报状态,针对单向调用及WUP调用(仅对TARS协议有效) - */ - void reportToStat(const string & sObj); +// /** +// * 服务端上报状态,针对单向调用及TUP调用 +// */ +// void reportToStat(const string & sObj); /** * 设置cookie @@ -341,7 +348,7 @@ class Current : public TC_HandleBase /** * 操作类指针 */ - ServantHandle* _servantHandle; + shared_ptr _servantHandle; /** * 接收到的数据 @@ -363,10 +370,10 @@ class Current : public TC_HandleBase */ int _ret; - /** - * 是否上报stat - */ - bool _reportStat; +// /** +// * 是否上报stat +// */ +// bool _reportStat; /** * 设置额外返回的内容 diff --git a/servant/servant/ServantHandle.h b/servant/servant/ServantHandle.h index e8277790..18b48aa3 100644 --- a/servant/servant/ServantHandle.h +++ b/servant/servant/ServantHandle.h @@ -39,7 +39,7 @@ class Application; /** * 处理网络请求线程 */ -class ServantHandle : public TC_EpollServer::Handle +class ServantHandle : public TC_EpollServer::Handle, public enable_shared_from_this { public: /** diff --git a/servant/servant/StatReport.h b/servant/servant/StatReport.h index fb2defc8..1d81e751 100644 --- a/servant/servant/StatReport.h +++ b/servant/servant/StatReport.h @@ -301,6 +301,9 @@ class StatReport : public TC_HandleBase, public TC_Thread, public TC_ThreadLock map _statPropMsg; }; + +//typedef TC_AutoPtr StatReportPtr; + /////////////////////////////////////////////////////////// } diff --git a/tools/tars2cpp/tars2cpp.cpp b/tools/tars2cpp/tars2cpp.cpp index a7075874..6cba3e55 100755 --- a/tools/tars2cpp/tars2cpp.cpp +++ b/tools/tars2cpp/tars2cpp.cpp @@ -2567,7 +2567,7 @@ string Tars2Cpp::generateH(const OperationPtr& pPtr, bool bVirtual, const string s << endl; s << TAB << "vector sTupResponseBuffer;" << endl; s << TAB << "_tarsAttr_.encode(sTupResponseBuffer);"<< endl; - s << TAB << "_current_->sendResponse(tars::TARSSERVERSUCCESS, sTupResponseBuffer);" << endl; + s << TAB << "_current_->sendResponse(tars::TARSSERVERSUCCESS, _tarsAttr_);" << endl; if (_bTrace) { s << TAB << "_rsp_len_ = sTupResponseBuffer.size();" << endl; From 0cfb16372f197fb30607f7e52881950dccce4b42 Mon Sep 17 00:00:00 2001 From: yangjl Date: Mon, 8 Jan 2024 11:21:11 +0800 Subject: [PATCH 30/81] =?UTF-8?q?style:=E4=BF=AE=E6=94=B9xxx=5Ffcontext?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=EF=BC=8C=E9=81=BF=E5=85=8D=E4=B8=8E=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E4=BD=BF=E7=94=A8boost=20fcontext=E7=9A=84=E5=BA=93?= =?UTF-8?q?=E4=BA=A7=E7=94=9F=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/include/util/tc_fcontext.h | 4 +-- util/src/asm/jump_arm64_aapcs_elf_gas.S | 8 ++--- util/src/asm/jump_arm64_aapcs_macho_gas.S | 4 +-- util/src/asm/jump_arm_aapcs_elf_gas.S | 8 ++--- util/src/asm/jump_arm_aapcs_macho_gas.S | 4 +-- util/src/asm/jump_arm_aapcs_pe_armasm.asm | 4 +-- util/src/asm/jump_i386_ms_pe_gas.asm | 10 +++--- util/src/asm/jump_i386_ms_pe_masm.asm | 6 ++-- util/src/asm/jump_i386_sysv_elf_gas.S | 12 +++---- util/src/asm/jump_i386_sysv_macho_gas.S | 8 ++--- util/src/asm/jump_mips32_o32_elf_gas.S | 12 +++---- util/src/asm/jump_ppc32_sysv_elf_gas.S | 12 +++---- util/src/asm/jump_ppc32_sysv_macho_gas.S | 4 +-- util/src/asm/jump_ppc32_sysv_xcoff_gas.S | 12 +++---- util/src/asm/jump_ppc64_sysv_elf_gas.S | 36 +++++++++---------- util/src/asm/jump_ppc64_sysv_macho_gas.S | 4 +-- util/src/asm/jump_ppc64_sysv_xcoff_gas.S | 4 +-- util/src/asm/jump_x86_64_ms_pe_gas.asm | 10 +++--- util/src/asm/jump_x86_64_ms_pe_masm.asm | 4 +-- util/src/asm/jump_x86_64_sysv_elf_gas.S | 8 ++--- util/src/asm/jump_x86_64_sysv_macho_gas.S | 4 +-- util/src/asm/make_arm64_aapcs_elf_gas.S | 10 +++--- util/src/asm/make_arm64_aapcs_macho_gas.S | 6 ++-- util/src/asm/make_arm_aapcs_elf_gas.S | 10 +++--- util/src/asm/make_arm_aapcs_macho_gas.S | 6 ++-- util/src/asm/make_arm_aapcs_pe_armasm.asm | 10 +++--- util/src/asm/make_i386_ms_pe_gas.asm | 18 +++++----- util/src/asm/make_i386_ms_pe_masm.asm | 14 ++++---- util/src/asm/make_i386_sysv_elf_gas.S | 14 ++++---- util/src/asm/make_i386_sysv_macho_gas.S | 10 +++--- util/src/asm/make_mips32_o32_elf_gas.S | 14 ++++---- util/src/asm/make_ppc32_sysv_elf_gas.S | 14 ++++---- util/src/asm/make_ppc32_sysv_macho_gas.S | 8 ++--- util/src/asm/make_ppc32_sysv_xcoff_gas.S | 18 +++++----- util/src/asm/make_ppc64_sysv_elf_gas.S | 40 +++++++++++----------- util/src/asm/make_ppc64_sysv_macho_gas.S | 8 ++--- util/src/asm/make_ppc64_sysv_xcoff_gas.S | 14 ++++---- util/src/asm/make_x86_64_ms_pe_gas.asm | 22 ++++++------ util/src/asm/make_x86_64_ms_pe_masm.asm | 14 ++++---- util/src/asm/make_x86_64_sysv_elf_gas.S | 14 ++++---- util/src/asm/make_x86_64_sysv_macho_gas.S | 10 +++--- util/src/asm/ontop_arm64_aapcs_elf_gas.S | 8 ++--- util/src/asm/ontop_arm64_aapcs_macho_gas.S | 4 +-- util/src/asm/ontop_arm_aapcs_elf_gas.S | 8 ++--- util/src/asm/ontop_arm_aapcs_macho_gas.S | 4 +-- util/src/asm/ontop_arm_aapcs_pe_armasm.asm | 4 +-- util/src/asm/ontop_i386_ms_pe_gas.asm | 14 ++++---- util/src/asm/ontop_i386_ms_pe_masm.asm | 10 +++--- util/src/asm/ontop_i386_sysv_elf_gas.S | 14 ++++---- util/src/asm/ontop_i386_sysv_macho_gas.S | 10 +++--- util/src/asm/ontop_mips32_o32_elf_gas.S | 12 +++---- util/src/asm/ontop_ppc32_sysv_elf_gas.S | 14 ++++---- util/src/asm/ontop_ppc32_sysv_macho_gas.S | 4 +-- util/src/asm/ontop_ppc32_sysv_xcoff_gas.S | 12 +++---- util/src/asm/ontop_ppc64_sysv_elf_gas.S | 36 +++++++++---------- util/src/asm/ontop_ppc64_sysv_macho_gas.S | 4 +-- util/src/asm/ontop_ppc64_sysv_xcoff_gas.S | 4 +-- util/src/asm/ontop_x86_64_ms_pe_gas.asm | 10 +++--- util/src/asm/ontop_x86_64_ms_pe_masm.asm | 4 +-- util/src/asm/ontop_x86_64_sysv_elf_gas.S | 8 ++--- util/src/asm/ontop_x86_64_sysv_macho_gas.S | 4 +-- util/src/tc_coroutine.cpp | 8 ++--- 62 files changed, 324 insertions(+), 324 deletions(-) diff --git a/util/include/util/tc_fcontext.h b/util/include/util/tc_fcontext.h index 3d4a5c8d..13eb8d0b 100644 --- a/util/include/util/tc_fcontext.h +++ b/util/include/util/tc_fcontext.h @@ -12,8 +12,8 @@ struct transfer_t { void * data; }; -extern "C" transfer_t jump_fcontext( fcontext_t const to, void * vp); -extern "C" fcontext_t make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) ); +extern "C" transfer_t tars_jump_fcontext( fcontext_t const to, void * vp); +extern "C" fcontext_t tars_make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) ); } diff --git a/util/src/asm/jump_arm64_aapcs_elf_gas.S b/util/src/asm/jump_arm64_aapcs_elf_gas.S index cefd1830..ece57b8f 100644 --- a/util/src/asm/jump_arm64_aapcs_elf_gas.S +++ b/util/src/asm/jump_arm64_aapcs_elf_gas.S @@ -54,9 +54,9 @@ .file "jump_arm64_aapcs_elf_gas.S" .text .align 2 -.global jump_fcontext -.type jump_fcontext, %function -jump_fcontext: +.global tars_jump_fcontext +.type tars_jump_fcontext, %function +tars_jump_fcontext: # prepare stack for GP + FPU sub sp, sp, #0xb0 @@ -109,6 +109,6 @@ jump_fcontext: add sp, sp, #0xb0 ret x4 -.size jump_fcontext,.-jump_fcontext +.size tars_jump_fcontext,.-tars_jump_fcontext # Mark that we don't need executable stack. .section .note.GNU-stack,"",%progbits diff --git a/util/src/asm/jump_arm64_aapcs_macho_gas.S b/util/src/asm/jump_arm64_aapcs_macho_gas.S index 31738f74..a5a3a1e5 100644 --- a/util/src/asm/jump_arm64_aapcs_macho_gas.S +++ b/util/src/asm/jump_arm64_aapcs_macho_gas.S @@ -52,9 +52,9 @@ *******************************************************/ .text -.globl _jump_fcontext +.globl _tars_jump_fcontext .balign 16 -_jump_fcontext: +_tars_jump_fcontext: ; prepare stack for GP + FPU sub sp, sp, #0xb0 diff --git a/util/src/asm/jump_arm_aapcs_elf_gas.S b/util/src/asm/jump_arm_aapcs_elf_gas.S index 86efe9d8..ac72d33a 100644 --- a/util/src/asm/jump_arm_aapcs_elf_gas.S +++ b/util/src/asm/jump_arm_aapcs_elf_gas.S @@ -40,11 +40,11 @@ .file "jump_arm_aapcs_elf_gas.S" .text -.globl jump_fcontext +.globl tars_jump_fcontext .align 2 -.type jump_fcontext,%function +.type tars_jump_fcontext,%function .syntax unified -jump_fcontext: +tars_jump_fcontext: @ save LR as PC push {lr} @ save hidden,V1-V8,LR @@ -82,7 +82,7 @@ jump_fcontext: @ restore PC pop {pc} -.size jump_fcontext,.-jump_fcontext +.size tars_jump_fcontext,.-tars_jump_fcontext @ Mark that we don't need executable stack. .section .note.GNU-stack,"",%progbits diff --git a/util/src/asm/jump_arm_aapcs_macho_gas.S b/util/src/asm/jump_arm_aapcs_macho_gas.S index 8edd0d7d..09a6cc0e 100644 --- a/util/src/asm/jump_arm_aapcs_macho_gas.S +++ b/util/src/asm/jump_arm_aapcs_macho_gas.S @@ -39,9 +39,9 @@ *******************************************************/ .text -.globl _jump_fcontext +.globl _tars_jump_fcontext .align 2 -_jump_fcontext: +_tars_jump_fcontext: @ save LR as PC push {lr} @ save hidden,V1-V8,LR diff --git a/util/src/asm/jump_arm_aapcs_pe_armasm.asm b/util/src/asm/jump_arm_aapcs_pe_armasm.asm index bca923c6..4ec4492b 100644 --- a/util/src/asm/jump_arm_aapcs_pe_armasm.asm +++ b/util/src/asm/jump_arm_aapcs_pe_armasm.asm @@ -26,9 +26,9 @@ AREA |.text|, CODE ALIGN 4 - EXPORT jump_fcontext + EXPORT tars_jump_fcontext -jump_fcontext PROC +tars_jump_fcontext PROC ; save LR as PC push {lr} ; save hidden,V1-V8,LR diff --git a/util/src/asm/jump_i386_ms_pe_gas.asm b/util/src/asm/jump_i386_ms_pe_gas.asm index 6eb45326..900a78b8 100644 --- a/util/src/asm/jump_i386_ms_pe_gas.asm +++ b/util/src/asm/jump_i386_ms_pe_gas.asm @@ -32,9 +32,9 @@ .def @feat.00; .scl 3; .type 0; .endef .set @feat.00, 1 -.globl _jump_fcontext -.def _jump_fcontext; .scl 2; .type 32; .endef -_jump_fcontext: +.globl _tars_jump_fcontext +.def _tars_jump_fcontext; .scl 2; .type 32; .endef +_tars_jump_fcontext: /* prepare stack */ leal -0x2c(%esp), %esp @@ -71,7 +71,7 @@ _jump_fcontext: /* store ESP (pointing to context-data) in EAX */ movl %esp, %eax - /* firstarg of jump_fcontext() == fcontext to jump to */ + /* firstarg of tars_jump_fcontext() == fcontext to jump to */ movl 0x30(%esp), %ecx /* restore ESP (pointing to context-data) from ECX */ @@ -120,4 +120,4 @@ _jump_fcontext: jmp *%ecx .section .drectve -.ascii " -export:\"jump_fcontext\"" +.ascii " -export:\"tars_jump_fcontext\"" diff --git a/util/src/asm/jump_i386_ms_pe_masm.asm b/util/src/asm/jump_i386_ms_pe_masm.asm index 451d4835..681f98fb 100644 --- a/util/src/asm/jump_i386_ms_pe_masm.asm +++ b/util/src/asm/jump_i386_ms_pe_masm.asm @@ -24,7 +24,7 @@ .model flat, c .code -jump_fcontext PROC EXPORT +tars_jump_fcontext PROC EXPORT ; prepare stack lea esp, [esp-02ch] @@ -63,7 +63,7 @@ ENDIF ; store ESP (pointing to context-data) in EAX mov eax, esp - ; firstarg of jump_fcontext() == fcontext to jump to + ; firstarg of tars_jump_fcontext() == fcontext to jump to mov ecx, [esp+030h] ; restore ESP (pointing to context-data) from ECX @@ -112,5 +112,5 @@ ENDIF ; jump to context jmp ecx -jump_fcontext ENDP +tars_jump_fcontext ENDP END diff --git a/util/src/asm/jump_i386_sysv_elf_gas.S b/util/src/asm/jump_i386_sysv_elf_gas.S index b96d4b5c..c78b26cd 100644 --- a/util/src/asm/jump_i386_sysv_elf_gas.S +++ b/util/src/asm/jump_i386_sysv_elf_gas.S @@ -26,10 +26,10 @@ .file "jump_i386_sysv_elf_gas.S" .text -.globl jump_fcontext +.globl tars_jump_fcontext .align 2 -.type jump_fcontext,@function -jump_fcontext: +.type tars_jump_fcontext,@function +tars_jump_fcontext: leal -0x18(%esp), %esp /* prepare stack */ #if !defined(BOOST_USE_TSX) @@ -45,10 +45,10 @@ jump_fcontext: /* store ESP (pointing to context-data) in ECX */ movl %esp, %ecx - /* first arg of jump_fcontext() == fcontext to jump to */ + /* first arg of tars_jump_fcontext() == fcontext to jump to */ movl 0x20(%esp), %eax - /* second arg of jump_fcontext() == data to be transferred */ + /* second arg of tars_jump_fcontext() == data to be transferred */ movl 0x24(%esp), %edx /* restore ESP (pointing to context-data) from EAX */ @@ -77,7 +77,7 @@ jump_fcontext: /* jump to context */ jmp *%ecx -.size jump_fcontext,.-jump_fcontext +.size tars_jump_fcontext,.-tars_jump_fcontext /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits diff --git a/util/src/asm/jump_i386_sysv_macho_gas.S b/util/src/asm/jump_i386_sysv_macho_gas.S index 8ab7c6f2..d93f169a 100644 --- a/util/src/asm/jump_i386_sysv_macho_gas.S +++ b/util/src/asm/jump_i386_sysv_macho_gas.S @@ -25,9 +25,9 @@ ****************************************************************************************/ .text -.globl _jump_fcontext +.globl _tars_jump_fcontext .align 2 -_jump_fcontext: +_tars_jump_fcontext: leal -0x18(%esp), %esp /* prepare stack */ #if !defined(BOOST_USE_TSX) @@ -43,10 +43,10 @@ _jump_fcontext: /* store ESP (pointing to context-data) in ECX */ movl %esp, %ecx - /* first arg of jump_fcontext() == fcontext to jump to */ + /* first arg of tars_jump_fcontext() == fcontext to jump to */ movl 0x1c(%esp), %eax - /* second arg of jump_fcontext() == data to be transferred */ + /* second arg of tars_jump_fcontext() == data to be transferred */ movl 0x20(%esp), %edx /* restore ESP (pointing to context-data) from EAX */ diff --git a/util/src/asm/jump_mips32_o32_elf_gas.S b/util/src/asm/jump_mips32_o32_elf_gas.S index f2b8034d..ffb523df 100644 --- a/util/src/asm/jump_mips32_o32_elf_gas.S +++ b/util/src/asm/jump_mips32_o32_elf_gas.S @@ -40,11 +40,11 @@ .file "jump_mips32_o32_elf_gas.S" .text -.globl jump_fcontext +.globl tars_jump_fcontext .align 2 -.type jump_fcontext,@function -.ent jump_fcontext -jump_fcontext: +.type tars_jump_fcontext,@function +.ent tars_jump_fcontext +tars_jump_fcontext: # reserve space on stack addiu $sp, $sp, -96 @@ -112,8 +112,8 @@ jump_fcontext: # jump to context jr $t9 -.end jump_fcontext -.size jump_fcontext, .-jump_fcontext +.end tars_jump_fcontext +.size tars_jump_fcontext, .-tars_jump_fcontext /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits diff --git a/util/src/asm/jump_ppc32_sysv_elf_gas.S b/util/src/asm/jump_ppc32_sysv_elf_gas.S index 48e09c93..89b886cb 100644 --- a/util/src/asm/jump_ppc32_sysv_elf_gas.S +++ b/util/src/asm/jump_ppc32_sysv_elf_gas.S @@ -52,12 +52,12 @@ .file "jump_ppc32_sysv_elf_gas.S" .text -.globl jump_fcontext +.globl tars_jump_fcontext .align 2 -.type jump_fcontext,@function -jump_fcontext: - # Linux: jump_fcontext( hidden transfer_t * R3, R4, R5) - # Other: transfer_t R3:R4 = jump_fcontext( R3, R4) +.type tars_jump_fcontext,@function +tars_jump_fcontext: + # Linux: tars_jump_fcontext( hidden transfer_t * R3, R4, R5) + # Other: transfer_t R3:R4 = tars_jump_fcontext( R3, R4) mflr %r0 # return address from LR mffs %f0 # FPSCR @@ -195,7 +195,7 @@ jump_fcontext: # jump to context bctr -.size jump_fcontext, .-jump_fcontext +.size tars_jump_fcontext, .-tars_jump_fcontext /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits diff --git a/util/src/asm/jump_ppc32_sysv_macho_gas.S b/util/src/asm/jump_ppc32_sysv_macho_gas.S index c555237a..7e74737f 100644 --- a/util/src/asm/jump_ppc32_sysv_macho_gas.S +++ b/util/src/asm/jump_ppc32_sysv_macho_gas.S @@ -74,9 +74,9 @@ *******************************************************/ .text -.globl _jump_fcontext +.globl _tars_jump_fcontext .align 2 -_jump_fcontext: +_tars_jump_fcontext: ; reserve space on stack subi r1, r1, 244 diff --git a/util/src/asm/jump_ppc32_sysv_xcoff_gas.S b/util/src/asm/jump_ppc32_sysv_xcoff_gas.S index 5a967726..92e73ba7 100644 --- a/util/src/asm/jump_ppc32_sysv_xcoff_gas.S +++ b/util/src/asm/jump_ppc32_sysv_xcoff_gas.S @@ -72,13 +72,13 @@ * ------------------------------------------------- * * * *******************************************************/ -.globl .jump_fcontext -.globl jump_fcontext[DS] +.globl .tars_jump_fcontext +.globl tars_jump_fcontext[DS] .align 2 -.csect jump_fcontext[DS] -jump_fcontext: - .long .jump_fcontext -.jump_fcontext: +.csect tars_jump_fcontext[DS] +tars_jump_fcontext: + .long .tars_jump_fcontext +.tars_jump_fcontext: # reserve space on stack subi r1, r1, 244 diff --git a/util/src/asm/jump_ppc64_sysv_elf_gas.S b/util/src/asm/jump_ppc64_sysv_elf_gas.S index 28907db3..43e21d3b 100644 --- a/util/src/asm/jump_ppc64_sysv_elf_gas.S +++ b/util/src/asm/jump_ppc64_sysv_elf_gas.S @@ -67,33 +67,33 @@ *******************************************************/ .file "jump_ppc64_sysv_elf_gas.S" -.globl jump_fcontext +.globl tars_jump_fcontext #if _CALL_ELF == 2 .text .align 2 -jump_fcontext: - addis %r2, %r12, .TOC.-jump_fcontext@ha - addi %r2, %r2, .TOC.-jump_fcontext@l - .localentry jump_fcontext, . - jump_fcontext +tars_jump_fcontext: + addis %r2, %r12, .TOC.-tars_jump_fcontext@ha + addi %r2, %r2, .TOC.-tars_jump_fcontext@l + .localentry tars_jump_fcontext, . - tars_jump_fcontext #else .section ".opd","aw" .align 3 -jump_fcontext: +tars_jump_fcontext: # ifdef _CALL_LINUX - .quad .L.jump_fcontext,.TOC.@tocbase,0 - .type jump_fcontext,@function + .quad .L.tars_jump_fcontext,.TOC.@tocbase,0 + .type tars_jump_fcontext,@function .text .align 2 -.L.jump_fcontext: +.L.tars_jump_fcontext: # else - .hidden .jump_fcontext - .globl .jump_fcontext - .quad .jump_fcontext,.TOC.@tocbase,0 - .size jump_fcontext,24 - .type .jump_fcontext,@function + .hidden .tars_jump_fcontext + .globl .tars_jump_fcontext + .quad .tars_jump_fcontext,.TOC.@tocbase,0 + .size tars_jump_fcontext,24 + .type .tars_jump_fcontext,@function .text .align 2 -.jump_fcontext: +.tars_jump_fcontext: # endif #endif # reserve space on stack @@ -189,7 +189,7 @@ jump_fcontext: # jump to context bctr - .size jump_fcontext, .-jump_fcontext + .size tars_jump_fcontext, .-tars_jump_fcontext #else # zero in r3 indicates first jump to context-function cmpdi %r3, 0 @@ -210,9 +210,9 @@ use_entry_arg: # jump to context bctr # ifdef _CALL_LINUX - .size .jump_fcontext, .-.L.jump_fcontext + .size .tars_jump_fcontext, .-.L.tars_jump_fcontext # else - .size .jump_fcontext, .-.jump_fcontext + .size .tars_jump_fcontext, .-.tars_jump_fcontext # endif #endif diff --git a/util/src/asm/jump_ppc64_sysv_macho_gas.S b/util/src/asm/jump_ppc64_sysv_macho_gas.S index 74fcb2ab..4f647d74 100644 --- a/util/src/asm/jump_ppc64_sysv_macho_gas.S +++ b/util/src/asm/jump_ppc64_sysv_macho_gas.S @@ -68,9 +68,9 @@ .text .align 2 -.globl _jump_fcontext +.globl _tars_jump_fcontext -_jump_fcontext: +_tars_jump_fcontext: ; reserve space on stack subi r1, r1, 184 diff --git a/util/src/asm/jump_ppc64_sysv_xcoff_gas.S b/util/src/asm/jump_ppc64_sysv_xcoff_gas.S index ff0e6eaa..3a6e895a 100644 --- a/util/src/asm/jump_ppc64_sysv_xcoff_gas.S +++ b/util/src/asm/jump_ppc64_sysv_xcoff_gas.S @@ -7,8 +7,8 @@ */ .align 2 -.globl .jump_fcontext -.jump_fcontext: +.globl .tars_jump_fcontext +.tars_jump_fcontext: # reserve space on stack subi 1, 1, 184 diff --git a/util/src/asm/jump_x86_64_ms_pe_gas.asm b/util/src/asm/jump_x86_64_ms_pe_gas.asm index ec4ecfe9..e01af1fa 100644 --- a/util/src/asm/jump_x86_64_ms_pe_gas.asm +++ b/util/src/asm/jump_x86_64_ms_pe_gas.asm @@ -89,10 +89,10 @@ .file "jump_x86_64_ms_pe_gas.asm" .text .p2align 4,,15 -.globl jump_fcontext -.def jump_fcontext; .scl 2; .type 32; .endef -.seh_proc jump_fcontext -jump_fcontext: +.globl tars_jump_fcontext +.def tars_jump_fcontext; .scl 2; .type 32; .endef +.seh_proc tars_jump_fcontext +tars_jump_fcontext: .seh_endprologue leaq -0x118(%rsp), %rsp /* prepare stack */ @@ -206,4 +206,4 @@ jump_fcontext: .seh_endproc .section .drectve -.ascii " -export:\"jump_fcontext\"" +.ascii " -export:\"tars_jump_fcontext\"" diff --git a/util/src/asm/jump_x86_64_ms_pe_masm.asm b/util/src/asm/jump_x86_64_ms_pe_masm.asm index 4d5a4b33..63df0046 100644 --- a/util/src/asm/jump_x86_64_ms_pe_masm.asm +++ b/util/src/asm/jump_x86_64_ms_pe_masm.asm @@ -84,7 +84,7 @@ .code -jump_fcontext PROC EXPORT FRAME +tars_jump_fcontext PROC EXPORT FRAME .endprolog ; prepare stack @@ -201,5 +201,5 @@ ENDIF ; indirect jump to context jmp r10 -jump_fcontext ENDP +tars_jump_fcontext ENDP END diff --git a/util/src/asm/jump_x86_64_sysv_elf_gas.S b/util/src/asm/jump_x86_64_sysv_elf_gas.S index 0c4a1a39..84cf2e55 100644 --- a/util/src/asm/jump_x86_64_sysv_elf_gas.S +++ b/util/src/asm/jump_x86_64_sysv_elf_gas.S @@ -26,10 +26,10 @@ .file "jump_x86_64_sysv_elf_gas.S" .text -.globl jump_fcontext -.type jump_fcontext,@function +.globl tars_jump_fcontext +.type tars_jump_fcontext,@function .align 16 -jump_fcontext: +tars_jump_fcontext: leaq -0x38(%rsp), %rsp /* prepare stack */ #if !defined(BOOST_USE_TSX) @@ -85,7 +85,7 @@ jump_fcontext: /* indirect jump to context */ jmp *%r8 -.size jump_fcontext,.-jump_fcontext +.size tars_jump_fcontext,.-tars_jump_fcontext /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits diff --git a/util/src/asm/jump_x86_64_sysv_macho_gas.S b/util/src/asm/jump_x86_64_sysv_macho_gas.S index afc3e5c1..b798ba10 100644 --- a/util/src/asm/jump_x86_64_sysv_macho_gas.S +++ b/util/src/asm/jump_x86_64_sysv_macho_gas.S @@ -25,9 +25,9 @@ ****************************************************************************************/ .text -.globl _jump_fcontext +.globl _tars_jump_fcontext .align 8 -_jump_fcontext: +_tars_jump_fcontext: leaq -0x38(%rsp), %rsp /* prepare stack */ #if !defined(BOOST_USE_TSX) diff --git a/util/src/asm/make_arm64_aapcs_elf_gas.S b/util/src/asm/make_arm64_aapcs_elf_gas.S index 66cfb2da..5de794ed 100644 --- a/util/src/asm/make_arm64_aapcs_elf_gas.S +++ b/util/src/asm/make_arm64_aapcs_elf_gas.S @@ -54,16 +54,16 @@ .file "make_arm64_aapcs_elf_gas.S" .text .align 2 -.global make_fcontext -.type make_fcontext, %function -make_fcontext: +.global tars_make_fcontext +.type tars_make_fcontext, %function +tars_make_fcontext: # shift address in x0 (allocated stack) to lower 16 byte boundary and x0, x0, ~0xF # reserve space for context-data on context-stack sub x0, x0, #0xb0 - # third arg of make_fcontext() == address of context-function + # third arg of tars_make_fcontext() == address of context-function # store address as a PC to jump in str x2, [x0, #0xa0] @@ -80,6 +80,6 @@ finish: # exit application bl _exit -.size make_fcontext,.-make_fcontext +.size tars_make_fcontext,.-tars_make_fcontext # Mark that we don't need executable stack. .section .note.GNU-stack,"",%progbits diff --git a/util/src/asm/make_arm64_aapcs_macho_gas.S b/util/src/asm/make_arm64_aapcs_macho_gas.S index b30b1e3e..20e77788 100644 --- a/util/src/asm/make_arm64_aapcs_macho_gas.S +++ b/util/src/asm/make_arm64_aapcs_macho_gas.S @@ -52,17 +52,17 @@ *******************************************************/ .text -.globl _make_fcontext +.globl _tars_make_fcontext .balign 16 -_make_fcontext: +_tars_make_fcontext: ; shift address in x0 (allocated stack) to lower 16 byte boundary and x0, x0, ~0xF ; reserve space for context-data on context-stack sub x0, x0, #0xb0 - ; third arg of make_fcontext() == address of context-function + ; third arg of tars_make_fcontext() == address of context-function ; store address as a PC to jump in str x2, [x0, #0xa0] diff --git a/util/src/asm/make_arm_aapcs_elf_gas.S b/util/src/asm/make_arm_aapcs_elf_gas.S index 98ae64b4..0804e828 100644 --- a/util/src/asm/make_arm_aapcs_elf_gas.S +++ b/util/src/asm/make_arm_aapcs_elf_gas.S @@ -40,18 +40,18 @@ .file "make_arm_aapcs_elf_gas.S" .text -.globl make_fcontext +.globl tars_make_fcontext .align 2 -.type make_fcontext,%function +.type tars_make_fcontext,%function .syntax unified -make_fcontext: +tars_make_fcontext: @ shift address in A1 to lower 16 byte boundary bic a1, a1, #15 @ reserve space for context-data on context-stack sub a1, a1, #124 - @ third arg of make_fcontext() == address of context-function + @ third arg of tars_make_fcontext() == address of context-function str a3, [a1, #104] @ compute address of returned transfer_t @@ -75,7 +75,7 @@ finish: mov a1, #0 @ exit application bl _exit@PLT -.size make_fcontext,.-make_fcontext +.size tars_make_fcontext,.-tars_make_fcontext @ Mark that we don't need executable stack. .section .note.GNU-stack,"",%progbits diff --git a/util/src/asm/make_arm_aapcs_macho_gas.S b/util/src/asm/make_arm_aapcs_macho_gas.S index c909ae9d..3e831eeb 100644 --- a/util/src/asm/make_arm_aapcs_macho_gas.S +++ b/util/src/asm/make_arm_aapcs_macho_gas.S @@ -39,16 +39,16 @@ *******************************************************/ .text -.globl _make_fcontext +.globl _tars_make_fcontext .align 2 -_make_fcontext: +_tars_make_fcontext: @ shift address in A1 to lower 16 byte boundary bic a1, a1, #15 @ reserve space for context-data on context-stack sub a1, a1, #124 - @ third arg of make_fcontext() == address of context-function + @ third arg of tars_make_fcontext() == address of context-function str a3, [a1, #108] @ compute address of returned transfer_t diff --git a/util/src/asm/make_arm_aapcs_pe_armasm.asm b/util/src/asm/make_arm_aapcs_pe_armasm.asm index 27cbfb08..07c27eda 100644 --- a/util/src/asm/make_arm_aapcs_pe_armasm.asm +++ b/util/src/asm/make_arm_aapcs_pe_armasm.asm @@ -27,11 +27,11 @@ AREA |.text|, CODE ALIGN 4 - EXPORT make_fcontext + EXPORT tars_make_fcontext IMPORT _exit -make_fcontext PROC - ; first arg of make_fcontext() == top of context-stack +tars_make_fcontext PROC + ; first arg of tars_make_fcontext() == top of context-stack ; save top of context-stack (base) A4 mov a4, a1 @@ -43,7 +43,7 @@ make_fcontext PROC ; save top address of context_stack as 'base' str a4, [a1, #0x8] - ; second arg of make_fcontext() == size of context-stack + ; second arg of tars_make_fcontext() == size of context-stack ; compute bottom address of context-stack (limit) sub a4, a4, a2 ; save bottom address of context-stack as 'limit' @@ -51,7 +51,7 @@ make_fcontext PROC ; save bottom address of context-stack as 'dealloction stack' str a4, [a1, #0x0] - ; third arg of make_fcontext() == address of context-function + ; third arg of tars_make_fcontext() == address of context-function str a3, [a1, #0x34] ; compute address of returned transfer_t diff --git a/util/src/asm/make_i386_ms_pe_gas.asm b/util/src/asm/make_i386_ms_pe_gas.asm index 608ddf3a..86b0ea11 100644 --- a/util/src/asm/make_i386_ms_pe_gas.asm +++ b/util/src/asm/make_i386_ms_pe_gas.asm @@ -32,10 +32,10 @@ .def @feat.00; .scl 3; .type 0; .endef .set @feat.00, 1 -.globl _make_fcontext -.def _make_fcontext; .scl 2; .type 32; .endef -_make_fcontext: - /* first arg of make_fcontext() == top of context-stack */ +.globl _tars_make_fcontext +.def _tars_make_fcontext; .scl 2; .type 32; .endef +_tars_make_fcontext: + /* first arg of tars_make_fcontext() == top of context-stack */ movl 0x04(%esp), %eax /* reserve space for first argument of context-function */ @@ -56,11 +56,11 @@ _make_fcontext: /* save x87 control-word */ fnstcw 0x4(%eax) - /* first arg of make_fcontext() == top of context-stack */ + /* first arg of tars_make_fcontext() == top of context-stack */ movl 0x4(%esp), %ecx /* save top address of context stack as 'base' */ movl %ecx, 0x14(%eax) - /* second arg of make_fcontext() == size of context-stack */ + /* second arg of tars_make_fcontext() == size of context-stack */ movl 0x8(%esp), %edx /* negate stack size for LEA instruction (== substraction) */ negl %edx @@ -74,7 +74,7 @@ _make_fcontext: xorl %ecx, %ecx movl %ecx, 0x8(%eax) - /* third arg of make_fcontext() == address of context-function */ + /* third arg of tars_make_fcontext() == address of context-function */ /* stored in EBX */ movl 0xc(%esp), %ecx movl %ecx, 0x24(%eax) @@ -82,7 +82,7 @@ _make_fcontext: /* compute abs address of label trampoline */ movl $trampoline, %ecx /* save address of trampoline as return-address for context-function */ - /* will be entered after calling jump_fcontext() first time */ + /* will be entered after calling tars_jump_fcontext() first time */ movl %ecx, 0x2c(%eax) /* compute abs address of label finish */ @@ -150,4 +150,4 @@ finish: .def __exit; .scl 2; .type 32; .endef /* standard C library function */ .section .drectve -.ascii " -export:\"make_fcontext\"" +.ascii " -export:\"tars_make_fcontext\"" diff --git a/util/src/asm/make_i386_ms_pe_masm.asm b/util/src/asm/make_i386_ms_pe_masm.asm index 738fe0d9..9119d36d 100644 --- a/util/src/asm/make_i386_ms_pe_masm.asm +++ b/util/src/asm/make_i386_ms_pe_masm.asm @@ -26,8 +26,8 @@ _exit PROTO, value:SDWORD .code -make_fcontext PROC EXPORT - ; first arg of make_fcontext() == top of context-stack +tars_make_fcontext PROC EXPORT + ; first arg of tars_make_fcontext() == top of context-stack mov eax, [esp+04h] ; reserve space for first argument of context-function @@ -47,11 +47,11 @@ make_fcontext PROC EXPORT ; save x87 control-word fnstcw [eax+04h] - ; first arg of make_fcontext() == top of context-stack + ; first arg of tars_make_fcontext() == top of context-stack mov ecx, [esp+04h] ; save top address of context stack as 'base' mov [eax+014h], ecx - ; second arg of make_fcontext() == size of context-stack + ; second arg of tars_make_fcontext() == size of context-stack mov edx, [esp+08h] ; negate stack size for LEA instruction (== substraction) neg edx @@ -65,7 +65,7 @@ make_fcontext PROC EXPORT xor ecx, ecx mov [eax+08h], ecx - ; third arg of make_fcontext() == address of context-function + ; third arg of tars_make_fcontext() == address of context-function ; stored in EBX mov ecx, [esp+0ch] mov [eax+024h], ecx @@ -73,7 +73,7 @@ make_fcontext PROC EXPORT ; compute abs address of label trampoline mov ecx, trampoline ; save address of trampoline as return-address for context-function - ; will be entered after calling jump_fcontext() first time + ; will be entered after calling tars_jump_fcontext() first time mov [eax+02ch], ecx ; compute abs address of label finish @@ -136,5 +136,5 @@ finish: ; exit application call _exit hlt -make_fcontext ENDP +tars_make_fcontext ENDP END diff --git a/util/src/asm/make_i386_sysv_elf_gas.S b/util/src/asm/make_i386_sysv_elf_gas.S index b76de260..60502d66 100644 --- a/util/src/asm/make_i386_sysv_elf_gas.S +++ b/util/src/asm/make_i386_sysv_elf_gas.S @@ -26,11 +26,11 @@ .file "make_i386_sysv_elf_gas.S" .text -.globl make_fcontext +.globl tars_make_fcontext .align 2 -.type make_fcontext,@function -make_fcontext: - /* first arg of make_fcontext() == top of context-stack */ +.type tars_make_fcontext,@function +tars_make_fcontext: + /* first arg of tars_make_fcontext() == top of context-stack */ movl 0x4(%esp), %eax /* reserve space for first argument of context-function @@ -43,7 +43,7 @@ make_fcontext: /* reserve space for context-data on context-stack */ leal -0x28(%eax), %eax - /* third arg of make_fcontext() == address of context-function */ + /* third arg of tars_make_fcontext() == address of context-function */ /* stored in EBX */ movl 0xc(%esp), %ecx movl %ecx, 0x10(%eax) @@ -65,7 +65,7 @@ make_fcontext: /* compute abs address of label trampoline */ addl $trampoline-1b, %ecx /* save address of trampoline as return address */ - /* will be entered after calling jump_fcontext() first time */ + /* will be entered after calling tars_jump_fcontext() first time */ movl %ecx, 0x18(%eax) /* compute abs address of label finish */ @@ -101,7 +101,7 @@ finish: /* exit application */ call _exit@PLT hlt -.size make_fcontext,.-make_fcontext +.size tars_make_fcontext,.-tars_make_fcontext /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits diff --git a/util/src/asm/make_i386_sysv_macho_gas.S b/util/src/asm/make_i386_sysv_macho_gas.S index fdcdb7c8..f0d18220 100644 --- a/util/src/asm/make_i386_sysv_macho_gas.S +++ b/util/src/asm/make_i386_sysv_macho_gas.S @@ -25,10 +25,10 @@ ****************************************************************************************/ .text -.globl _make_fcontext +.globl _tars_make_fcontext .align 2 -_make_fcontext: - /* first arg of make_fcontext() == top of context-stack */ +_tars_make_fcontext: + /* first arg of tars_make_fcontext() == top of context-stack */ movl 0x4(%esp), %eax /* reserve space for first argument of context-function @@ -41,7 +41,7 @@ _make_fcontext: /* reserve space for context-data on context-stack */ leal -0x2c(%eax), %eax - /* third arg of make_fcontext() == address of context-function */ + /* third arg of tars_make_fcontext() == address of context-function */ /* stored in EBX */ movl 0xc(%esp), %ecx movl %ecx, 0x10(%eax) @@ -58,7 +58,7 @@ _make_fcontext: /* compute abs address of label trampoline */ addl $trampoline-1b, %ecx /* save address of trampoline as return address */ - /* will be entered after calling jump_fcontext() first time */ + /* will be entered after calling tars_jump_fcontext() first time */ movl %ecx, 0x18(%eax) /* compute abs address of label finish */ diff --git a/util/src/asm/make_mips32_o32_elf_gas.S b/util/src/asm/make_mips32_o32_elf_gas.S index 4e11e3d0..9c4eaf92 100644 --- a/util/src/asm/make_mips32_o32_elf_gas.S +++ b/util/src/asm/make_mips32_o32_elf_gas.S @@ -40,11 +40,11 @@ .file "make_mips32_o32_elf_gas.S" .text -.globl make_fcontext +.globl tars_make_fcontext .align 2 -.type make_fcontext,@function -.ent make_fcontext -make_fcontext: +.type tars_make_fcontext,@function +.ent tars_make_fcontext +tars_make_fcontext: #ifdef __PIC__ .set noreorder .cpload $t9 @@ -63,7 +63,7 @@ make_fcontext: # - 4 bytes for alignment addiu $v0, $v0, -128 - # third arg of make_fcontext() == address of context-function + # third arg of tars_make_fcontext() == address of context-function sw $a2, 92($v0) # save global pointer in context-data sw $gp, 112($v0) @@ -90,8 +90,8 @@ finish: la $t9, _exit move $a0, $zero jr $t9 -.end make_fcontext -.size make_fcontext, .-make_fcontext +.end tars_make_fcontext +.size tars_make_fcontext, .-tars_make_fcontext /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits diff --git a/util/src/asm/make_ppc32_sysv_elf_gas.S b/util/src/asm/make_ppc32_sysv_elf_gas.S index 9616c4ca..e6a39a57 100644 --- a/util/src/asm/make_ppc32_sysv_elf_gas.S +++ b/util/src/asm/make_ppc32_sysv_elf_gas.S @@ -52,14 +52,14 @@ .file "make_ppc32_sysv_elf_gas.S" .text -.globl make_fcontext +.globl tars_make_fcontext .align 2 -.type make_fcontext,@function -make_fcontext: +.type tars_make_fcontext,@function +tars_make_fcontext: # save return address into R6 mflr %r6 - # first arg of make_fcontext() == top address of context-function + # first arg of tars_make_fcontext() == top address of context-function # shift address in R3 to lower 16 byte boundary clrrwi %r3, %r3, 4 @@ -67,7 +67,7 @@ make_fcontext: # and parameter area + 240 bytes of context-data (R1 % 16 == 0) subi %r3, %r3, 16 + 240 - # third arg of make_fcontext() == address of context-function + # third arg of tars_make_fcontext() == address of context-function #ifdef __linux__ # save context-function as PC stw %r5, 16(%r3) @@ -111,7 +111,7 @@ make_fcontext: #ifndef __linux__ trampoline: - # On systems other than Linux, jump_fcontext is returning the + # On systems other than Linux, tars_jump_fcontext is returning the # transfer_t in R3:R4, but we need to pass transfer_t * R3 to # our context-function. lwz %r0, 8(%r1) # address of context-function @@ -136,7 +136,7 @@ finish: # call _exit(0) with special addend 0x8000 for large model li %r3, 0 bl _exit + 0x8000@plt -.size make_fcontext, .-make_fcontext +.size tars_make_fcontext, .-tars_make_fcontext /* Provide the GOT pointer for secure PLT, large model. */ .section .got2,"aw" diff --git a/util/src/asm/make_ppc32_sysv_macho_gas.S b/util/src/asm/make_ppc32_sysv_macho_gas.S index 8f35eff9..b8401ecc 100644 --- a/util/src/asm/make_ppc32_sysv_macho_gas.S +++ b/util/src/asm/make_ppc32_sysv_macho_gas.S @@ -74,13 +74,13 @@ *******************************************************/ .text -.globl _make_fcontext +.globl _tars_make_fcontext .align 2 -_make_fcontext: +_tars_make_fcontext: # save return address into R6 mflr r6 - # first arg of make_fcontext() == top address of context-function + # first arg of tars_make_fcontext() == top address of context-function # shift address in R3 to lower 16 byte boundary clrrwi r3, r3, 4 @@ -88,7 +88,7 @@ _make_fcontext: # including 64 byte of linkage + parameter area (R1 16 == 0) subi r3, r3, 336 - # third arg of make_fcontext() == address of context-function + # third arg of tars_make_fcontext() == address of context-function stw r5, 240(r3) # set back-chain to zero diff --git a/util/src/asm/make_ppc32_sysv_xcoff_gas.S b/util/src/asm/make_ppc32_sysv_xcoff_gas.S index f2572580..4712ae29 100644 --- a/util/src/asm/make_ppc32_sysv_xcoff_gas.S +++ b/util/src/asm/make_ppc32_sysv_xcoff_gas.S @@ -72,18 +72,18 @@ * ------------------------------------------------- * * * *******************************************************/ - .globl make_fcontext[DS] - .globl .make_fcontext[PR] + .globl tars_make_fcontext[DS] + .globl .tars_make_fcontext[PR] .align 2 - .csect make_fcontext[DS] -make_fcontext: - .long .make_fcontext[PR] - .csect .make_fcontext[PR], 3 -#.make_fcontext: + .csect tars_make_fcontext[DS] +tars_make_fcontext: + .long .tars_make_fcontext[PR] + .csect .tars_make_fcontext[PR], 3 +#.tars_make_fcontext: # save return address into R6 mflr 6 - # first arg of make_fcontext() == top address of context-function + # first arg of tars_make_fcontext() == top address of context-function # shift address in R3 to lower 16 byte boundary clrrwi 3, 3, 4 @@ -91,7 +91,7 @@ make_fcontext: # including 64 byte of linkage + parameter area (R1 % 16 == 0) subi 3, 3, 336 - # third arg of make_fcontext() == address of context-function + # third arg of tars_make_fcontext() == address of context-function stw 5, 240(3) # set back-chain to zero diff --git a/util/src/asm/make_ppc64_sysv_elf_gas.S b/util/src/asm/make_ppc64_sysv_elf_gas.S index c4d7ee59..0ec35e84 100644 --- a/util/src/asm/make_ppc64_sysv_elf_gas.S +++ b/util/src/asm/make_ppc64_sysv_elf_gas.S @@ -67,39 +67,39 @@ *******************************************************/ .file "make_ppc64_sysv_elf_gas.S" -.globl make_fcontext +.globl tars_make_fcontext #if _CALL_ELF == 2 .text .align 2 -make_fcontext: - addis %r2, %r12, .TOC.-make_fcontext@ha - addi %r2, %r2, .TOC.-make_fcontext@l - .localentry make_fcontext, . - make_fcontext +tars_make_fcontext: + addis %r2, %r12, .TOC.-tars_make_fcontext@ha + addi %r2, %r2, .TOC.-tars_make_fcontext@l + .localentry tars_make_fcontext, . - tars_make_fcontext #else .section ".opd","aw" .align 3 -make_fcontext: +tars_make_fcontext: # ifdef _CALL_LINUX - .quad .L.make_fcontext,.TOC.@tocbase,0 - .type make_fcontext,@function + .quad .L.tars_make_fcontext,.TOC.@tocbase,0 + .type tars_make_fcontext,@function .text .align 2 -.L.make_fcontext: +.L.tars_make_fcontext: # else - .hidden .make_fcontext - .globl .make_fcontext - .quad .make_fcontext,.TOC.@tocbase,0 - .size make_fcontext,24 - .type .make_fcontext,@function + .hidden .tars_make_fcontext + .globl .tars_make_fcontext + .quad .tars_make_fcontext,.TOC.@tocbase,0 + .size tars_make_fcontext,24 + .type .tars_make_fcontext,@function .text .align 2 -.make_fcontext: +.tars_make_fcontext: # endif #endif # save return address into R6 mflr %r6 - # first arg of make_fcontext() == top address of context-stack + # first arg of tars_make_fcontext() == top address of context-stack # shift address in R3 to lower 16 byte boundary clrrdi %r3, %r3, 4 @@ -107,7 +107,7 @@ make_fcontext: # including 64 byte of linkage + parameter area (R1 % 16 == 0) subi %r3, %r3, 248 - # third arg of make_fcontext() == address of context-function + # third arg of tars_make_fcontext() == address of context-function # entry point (ELFv2) or descriptor (ELFv1) #if _CALL_ELF == 2 # save address of context-function entry point @@ -164,12 +164,12 @@ finish: bl _exit nop #if _CALL_ELF == 2 - .size make_fcontext, .-make_fcontext + .size tars_make_fcontext, .-tars_make_fcontext #else # ifdef _CALL_LINUX - .size .make_fcontext, .-.L.make_fcontext + .size .tars_make_fcontext, .-.L.tars_make_fcontext # else - .size .make_fcontext, .-.make_fcontext + .size .tars_make_fcontext, .-.tars_make_fcontext # endif #endif diff --git a/util/src/asm/make_ppc64_sysv_macho_gas.S b/util/src/asm/make_ppc64_sysv_macho_gas.S index 7b947bb6..cdcb48f9 100644 --- a/util/src/asm/make_ppc64_sysv_macho_gas.S +++ b/util/src/asm/make_ppc64_sysv_macho_gas.S @@ -66,12 +66,12 @@ * * .text -.globl _make_fcontext -_make_fcontext: +.globl _tars_make_fcontext +_tars_make_fcontext: ; save return address into R6 mflr r6 - ; first arg of make_fcontext() == top address of context-function + ; first arg of tars_make_fcontext() == top address of context-function ; shift address in R3 to lower 16 byte boundary clrrwi r3, r3, 4 @@ -79,7 +79,7 @@ _make_fcontext: ; including 64 byte of linkage + parameter area (R1 16 == 0) subi r3, r3, 248 - ; third arg of make_fcontext() == address of context-function + ; third arg of tars_make_fcontext() == address of context-function stw r5, 176(r3) ; set back-chain to zero diff --git a/util/src/asm/make_ppc64_sysv_xcoff_gas.S b/util/src/asm/make_ppc64_sysv_xcoff_gas.S index 60ad6b6b..164172fc 100644 --- a/util/src/asm/make_ppc64_sysv_xcoff_gas.S +++ b/util/src/asm/make_ppc64_sysv_xcoff_gas.S @@ -4,16 +4,16 @@ (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ - .globl make_fcontext[DS] - .globl .make_fcontext[PR] + .globl tars_make_fcontext[DS] + .globl .tars_make_fcontext[PR] .align 2 - .csect .make_fcontext[PR], 3 - .globl _make_fcontext -#._make_fcontext: + .csect .tars_make_fcontext[PR], 3 + .globl _tars_make_fcontext +#._tars_make_fcontext: # save return address into R6 mflr 6 - # first arg of make_fcontext() == top address of context-function + # first arg of tars_make_fcontext() == top address of context-function # shift address in R3 to lower 16 byte boundary clrrwi 3, 3, 4 @@ -21,7 +21,7 @@ # including 64 byte of linkage + parameter area (R1 % 16 == 0) subi 3, 3, 248 - # third arg of make_fcontext() == address of context-function + # third arg of tars_make_fcontext() == address of context-function stw 5, 176(3) # set back-chain to zero diff --git a/util/src/asm/make_x86_64_ms_pe_gas.asm b/util/src/asm/make_x86_64_ms_pe_gas.asm index 958a2a7b..4e8eef06 100644 --- a/util/src/asm/make_x86_64_ms_pe_gas.asm +++ b/util/src/asm/make_x86_64_ms_pe_gas.asm @@ -89,13 +89,13 @@ .file "make_x86_64_ms_pe_gas.asm" .text .p2align 4,,15 -.globl make_fcontext -.def make_fcontext; .scl 2; .type 32; .endef -.seh_proc make_fcontext -make_fcontext: +.globl tars_make_fcontext +.def tars_make_fcontext; .scl 2; .type 32; .endef +.seh_proc tars_make_fcontext +tars_make_fcontext: .seh_endprologue - /* first arg of make_fcontext() == top of context-stack */ + /* first arg of tars_make_fcontext() == top of context-stack */ movq %rcx, %rax /* shift address in RAX to lower 16 byte boundary */ @@ -106,13 +106,13 @@ make_fcontext: /* on context-function entry: (RSP -0x8) % 16 == 0 */ leaq -0x150(%rax), %rax - /* third arg of make_fcontext() == address of context-function */ + /* third arg of tars_make_fcontext() == address of context-function */ movq %r8, 0x100(%rax) - /* first arg of make_fcontext() == top of context-stack */ + /* first arg of tars_make_fcontext() == top of context-stack */ /* save top address of context stack as 'base' */ movq %rcx, 0xc8(%rax) - /* second arg of make_fcontext() == size of context-stack */ + /* second arg of tars_make_fcontext() == size of context-stack */ /* negate stack size for LEA instruction (== substraction) */ negq %rdx /* compute bottom address of context stack (limit) */ @@ -138,7 +138,7 @@ make_fcontext: /* compute abs address of label trampoline */ leaq trampoline(%rip), %rcx /* save address of finish as return-address for context-function */ - /* will be entered after jump_fcontext() first time */ + /* will be entered after tars_jump_fcontext() first time */ movq %rcx, 0x118(%rax) /* compute abs address of label finish */ @@ -160,7 +160,7 @@ finish: /* 32byte shadow-space for _exit() */ andq $-32, %rsp /* 32byte shadow-space for _exit() are */ - /* already reserved by make_fcontext() */ + /* already reserved by tars_make_fcontext() */ /* exit code is zero */ xorq %rcx, %rcx /* exit application */ @@ -171,4 +171,4 @@ finish: .def _exit; .scl 2; .type 32; .endef /* standard C library function */ .section .drectve -.ascii " -export:\"make_fcontext\"" +.ascii " -export:\"tars_make_fcontext\"" diff --git a/util/src/asm/make_x86_64_ms_pe_masm.asm b/util/src/asm/make_x86_64_ms_pe_masm.asm index cccba893..ed4ebf0c 100644 --- a/util/src/asm/make_x86_64_ms_pe_masm.asm +++ b/util/src/asm/make_x86_64_ms_pe_masm.asm @@ -87,11 +87,11 @@ EXTERN _exit:PROC .code ; generate function table entry in .pdata and unwind information in -make_fcontext PROC EXPORT FRAME +tars_make_fcontext PROC EXPORT FRAME ; .xdata for a function's structured exception handling unwind behavior .endprolog - ; first arg of make_fcontext() == top of context-stack + ; first arg of tars_make_fcontext() == top of context-stack mov rax, rcx ; shift address in RAX to lower 16 byte boundary @@ -102,14 +102,14 @@ make_fcontext PROC EXPORT FRAME ; on context-function entry: (RSP -0x8) % 16 == 0 sub rax, 0150h - ; third arg of make_fcontext() == address of context-function + ; third arg of tars_make_fcontext() == address of context-function ; stored in RBX mov [rax+0100h], r8 - ; first arg of make_fcontext() == top of context-stack + ; first arg of tars_make_fcontext() == top of context-stack ; save top address of context stack as 'base' mov [rax+0c8h], rcx - ; second arg of make_fcontext() == size of context-stack + ; second arg of tars_make_fcontext() == size of context-stack ; negate stack size for LEA instruction (== substraction) neg rdx ; compute bottom address of context stack (limit) @@ -135,7 +135,7 @@ make_fcontext PROC EXPORT FRAME ; compute abs address of label trampoline lea rcx, trampoline ; save address of trampoline as return-address for context-function - ; will be entered after calling jump_fcontext() first time + ; will be entered after calling tars_jump_fcontext() first time mov [rax+0118h], rcx ; compute abs address of label finish @@ -159,5 +159,5 @@ finish: ; exit application call _exit hlt -make_fcontext ENDP +tars_make_fcontext ENDP END diff --git a/util/src/asm/make_x86_64_sysv_elf_gas.S b/util/src/asm/make_x86_64_sysv_elf_gas.S index 0ef37569..dfa0f7c7 100644 --- a/util/src/asm/make_x86_64_sysv_elf_gas.S +++ b/util/src/asm/make_x86_64_sysv_elf_gas.S @@ -26,11 +26,11 @@ .file "make_x86_64_sysv_elf_gas.S" .text -.globl make_fcontext -.type make_fcontext,@function +.globl tars_make_fcontext +.type tars_make_fcontext,@function .align 16 -make_fcontext: - /* first arg of make_fcontext() == top of context-stack */ +tars_make_fcontext: + /* first arg of tars_make_fcontext() == top of context-stack */ movq %rdi, %rax /* shift address in RAX to lower 16 byte boundary */ @@ -40,7 +40,7 @@ make_fcontext: /* on context-function entry: (RSP -0x8) % 16 == 0 */ leaq -0x40(%rax), %rax - /* third arg of make_fcontext() == address of context-function */ + /* third arg of tars_make_fcontext() == address of context-function */ /* stored in RBX */ movq %rdx, 0x28(%rax) @@ -52,7 +52,7 @@ make_fcontext: /* compute abs address of label trampoline */ leaq trampoline(%rip), %rcx /* save address of trampoline as return-address for context-function */ - /* will be entered after calling jump_fcontext() first time */ + /* will be entered after calling tars_jump_fcontext() first time */ movq %rcx, 0x38(%rax) /* compute abs address of label finish */ @@ -76,7 +76,7 @@ finish: /* exit application */ call _exit@PLT hlt -.size make_fcontext,.-make_fcontext +.size tars_make_fcontext,.-tars_make_fcontext /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits diff --git a/util/src/asm/make_x86_64_sysv_macho_gas.S b/util/src/asm/make_x86_64_sysv_macho_gas.S index 5d6c5431..df946141 100644 --- a/util/src/asm/make_x86_64_sysv_macho_gas.S +++ b/util/src/asm/make_x86_64_sysv_macho_gas.S @@ -25,10 +25,10 @@ ****************************************************************************************/ .text -.globl _make_fcontext +.globl _tars_make_fcontext .align 8 -_make_fcontext: - /* first arg of make_fcontext() == top of context-stack */ +_tars_make_fcontext: + /* first arg of tars_make_fcontext() == top of context-stack */ movq %rdi, %rax /* shift address in RAX to lower 16 byte boundary */ @@ -38,7 +38,7 @@ _make_fcontext: /* on context-function entry: (RSP -0x8) % 16 == 0 */ leaq -0x40(%rax), %rax - /* third arg of make_fcontext() == address of context-function */ + /* third arg of tars_make_fcontext() == address of context-function */ /* stored in RBX */ movq %rdx, 0x28(%rax) @@ -50,7 +50,7 @@ _make_fcontext: /* compute abs address of label trampoline */ leaq trampoline(%rip), %rcx /* save address of trampoline as return-address for context-function */ - /* will be entered after calling jump_fcontext() first time */ + /* will be entered after calling tars_jump_fcontext() first time */ movq %rcx, 0x38(%rax) /* compute abs address of label finish */ diff --git a/util/src/asm/ontop_arm64_aapcs_elf_gas.S b/util/src/asm/ontop_arm64_aapcs_elf_gas.S index 665ca5a2..5f9e2666 100644 --- a/util/src/asm/ontop_arm64_aapcs_elf_gas.S +++ b/util/src/asm/ontop_arm64_aapcs_elf_gas.S @@ -54,9 +54,9 @@ .file "ontop_arm64_aapcs_elf_gas.S" .text .align 2 -.global ontop_fcontext -.type ontop_fcontext, %function -ontop_fcontext: +.global tars_ontop_fcontext +.type tars_ontop_fcontext, %function +tars_ontop_fcontext: # prepare stack for GP + FPU sub sp, sp, #0xb0 @@ -108,6 +108,6 @@ ontop_fcontext: # jump to ontop-function ret x2 -.size ontop_fcontext,.-ontop_fcontext +.size tars_ontop_fcontext,.-tars_ontop_fcontext # Mark that we don't need executable stack. .section .note.GNU-stack,"",%progbits diff --git a/util/src/asm/ontop_arm64_aapcs_macho_gas.S b/util/src/asm/ontop_arm64_aapcs_macho_gas.S index a387d06d..43cc0afe 100644 --- a/util/src/asm/ontop_arm64_aapcs_macho_gas.S +++ b/util/src/asm/ontop_arm64_aapcs_macho_gas.S @@ -52,9 +52,9 @@ *******************************************************/ .text -.global _ontop_fcontext +.global _tars_ontop_fcontext .balign 16 -_ontop_fcontext: +_tars_ontop_fcontext: ; prepare stack for GP + FPU sub sp, sp, #0xb0 diff --git a/util/src/asm/ontop_arm_aapcs_elf_gas.S b/util/src/asm/ontop_arm_aapcs_elf_gas.S index 59ad5ca9..4a3e7633 100644 --- a/util/src/asm/ontop_arm_aapcs_elf_gas.S +++ b/util/src/asm/ontop_arm_aapcs_elf_gas.S @@ -40,11 +40,11 @@ .file "ontop_arm_aapcs_elf_gas.S" .text -.globl ontop_fcontext +.globl tars_ontop_fcontext .align 2 -.type ontop_fcontext,%function +.type tars_ontop_fcontext,%function .syntax unified -ontop_fcontext: +tars_ontop_fcontext: @ save LR as PC push {lr} @ save hidden,V1-V8,LR @@ -87,7 +87,7 @@ ontop_fcontext: @ jump to ontop-function bx a4 -.size ontop_fcontext,.-ontop_fcontext +.size tars_ontop_fcontext,.-tars_ontop_fcontext @ Mark that we don't need executable stack. .section .note.GNU-stack,"",%progbits diff --git a/util/src/asm/ontop_arm_aapcs_macho_gas.S b/util/src/asm/ontop_arm_aapcs_macho_gas.S index 421fcb45..62187e8b 100644 --- a/util/src/asm/ontop_arm_aapcs_macho_gas.S +++ b/util/src/asm/ontop_arm_aapcs_macho_gas.S @@ -39,9 +39,9 @@ *******************************************************/ .text -.globl _ontop_fcontext +.globl _tars_ontop_fcontext .align 2 -_ontop_fcontext: +_tars_ontop_fcontext: @ save LR as PC push {lr} @ save hidden,V1-V8,LR diff --git a/util/src/asm/ontop_arm_aapcs_pe_armasm.asm b/util/src/asm/ontop_arm_aapcs_pe_armasm.asm index f360a8ff..069204b1 100644 --- a/util/src/asm/ontop_arm_aapcs_pe_armasm.asm +++ b/util/src/asm/ontop_arm_aapcs_pe_armasm.asm @@ -26,9 +26,9 @@ AREA |.text|, CODE ALIGN 4 - EXPORT ontop_fcontext + EXPORT tars_ontop_fcontext -ontop_fcontext PROC +tars_ontop_fcontext PROC ; save LR as PC push {lr} ; save hidden,V1-V8,LR diff --git a/util/src/asm/ontop_i386_ms_pe_gas.asm b/util/src/asm/ontop_i386_ms_pe_gas.asm index abe9002a..ae49d64a 100644 --- a/util/src/asm/ontop_i386_ms_pe_gas.asm +++ b/util/src/asm/ontop_i386_ms_pe_gas.asm @@ -32,9 +32,9 @@ .def @feat.00; .scl 3; .type 0; .endef .set @feat.00, 1 -.globl _ontop_fcontext -.def _ontop_fcontext; .scl 2; .type 32; .endef -_ontop_fcontext: +.globl _tars_ontop_fcontext +.def _tars_ontop_fcontext; .scl 2; .type 32; .endef +_tars_ontop_fcontext: /* prepare stack */ leal -0x2c(%esp), %esp @@ -71,19 +71,19 @@ _ontop_fcontext: /* store ESP (pointing to context-data) in ECX */ movl %esp, %ecx - /* first arg of ontop_fcontext() == fcontext to jump to */ + /* first arg of tars_ontop_fcontext() == fcontext to jump to */ movl 0x30(%esp), %eax /* pass parent fcontext_t */ movl %ecx, 0x30(%eax) - /* second arg of ontop_fcontext() == data to be transferred */ + /* second arg of tars_ontop_fcontext() == data to be transferred */ movl 0x34(%esp), %ecx /* pass data */ movl %ecx, 0x34(%eax) - /* third arg of ontop_fcontext() == ontop-function */ + /* third arg of tars_ontop_fcontext() == ontop-function */ movl 0x38(%esp), %ecx /* restore ESP (pointing to context-data) from EDX */ @@ -128,4 +128,4 @@ _ontop_fcontext: jmp *%ecx .section .drectve -.ascii " -export:\"ontop_fcontext\"" +.ascii " -export:\"tars_ontop_fcontext\"" diff --git a/util/src/asm/ontop_i386_ms_pe_masm.asm b/util/src/asm/ontop_i386_ms_pe_masm.asm index 895578f3..4283a232 100644 --- a/util/src/asm/ontop_i386_ms_pe_masm.asm +++ b/util/src/asm/ontop_i386_ms_pe_masm.asm @@ -24,7 +24,7 @@ .model flat, c .code -ontop_fcontext PROC EXPORT +tars_ontop_fcontext PROC EXPORT ; prepare stack lea esp, [esp-02ch] @@ -63,19 +63,19 @@ ENDIF ; store ESP (pointing to context-data) in ECX mov ecx, esp - ; first arg of ontop_fcontext() == fcontext to jump to + ; first arg of tars_ontop_fcontext() == fcontext to jump to mov eax, [esp+030h] ; pass parent fcontext_t mov [eax+030h], ecx - ; second arg of ontop_fcontext() == data to be transferred + ; second arg of tars_ontop_fcontext() == data to be transferred mov ecx, [esp+034h] ; pass data mov [eax+034h], ecx - ; third arg of ontop_fcontext() == ontop-function + ; third arg of tars_ontop_fcontext() == ontop-function mov ecx, [esp+038h] ; restore ESP (pointing to context-data) from EAX @@ -120,5 +120,5 @@ ENDIF ; jump to context jmp ecx -ontop_fcontext ENDP +tars_ontop_fcontext ENDP END diff --git a/util/src/asm/ontop_i386_sysv_elf_gas.S b/util/src/asm/ontop_i386_sysv_elf_gas.S index 40fe6c2a..80dd0218 100644 --- a/util/src/asm/ontop_i386_sysv_elf_gas.S +++ b/util/src/asm/ontop_i386_sysv_elf_gas.S @@ -26,10 +26,10 @@ .file "ontop_i386_sysv_elf_gas.S" .text -.globl ontop_fcontext +.globl tars_ontop_fcontext .align 2 -.type ontop_fcontext,@function -ontop_fcontext: +.type tars_ontop_fcontext,@function +tars_ontop_fcontext: leal -0x18(%esp), %esp /* prepare stack */ #if !defined(BOOST_USE_TSX) @@ -45,19 +45,19 @@ ontop_fcontext: /* store ESP (pointing to context-data) in ECX */ movl %esp, %ecx - /* first arg of ontop_fcontext() == fcontext to jump to */ + /* first arg of tars_ontop_fcontext() == fcontext to jump to */ movl 0x20(%esp), %eax /* pass parent fcontext_t */ movl %ecx, 0x20(%eax) - /* second arg of ontop_fcontext() == data to be transferred */ + /* second arg of tars_ontop_fcontext() == data to be transferred */ movl 0x24(%esp), %ecx /* pass data */ movl %ecx, 0x24(%eax) - /* third arg of ontop_fcontext() == ontop-function */ + /* third arg of tars_ontop_fcontext() == ontop-function */ movl 0x28(%esp), %ecx /* restore ESP (pointing to context-data) from EAX */ @@ -84,7 +84,7 @@ ontop_fcontext: /* jump to context */ jmp *%ecx -.size ontop_fcontext,.-ontop_fcontext +.size tars_ontop_fcontext,.-tars_ontop_fcontext /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits diff --git a/util/src/asm/ontop_i386_sysv_macho_gas.S b/util/src/asm/ontop_i386_sysv_macho_gas.S index 3a88372b..81c87894 100644 --- a/util/src/asm/ontop_i386_sysv_macho_gas.S +++ b/util/src/asm/ontop_i386_sysv_macho_gas.S @@ -25,9 +25,9 @@ ****************************************************************************************/ .text -.globl _ontop_fcontext +.globl _tars_ontop_fcontext .align 2 -_ontop_fcontext: +_tars_ontop_fcontext: leal -0x18(%esp), %esp /* prepare stack */ #if !defined(BOOST_USE_TSX) @@ -43,19 +43,19 @@ _ontop_fcontext: /* store ESP (pointing to context-data) in ECX */ movl %esp, %ecx - /* first arg of ontop_fcontext() == fcontext to jump to */ + /* first arg of tars_ontop_fcontext() == fcontext to jump to */ movl 0x1c(%esp), %eax /* pass parent fcontext_t */ movl %ecx, 0x1c(%eax) - /* second arg of ontop_fcontext() == data to be transferred */ + /* second arg of tars_ontop_fcontext() == data to be transferred */ movl 0x20(%esp), %ecx /* pass data */ movl %ecx, 0x20(%eax) - /* third arg of ontop_fcontext() == ontop-function */ + /* third arg of tars_ontop_fcontext() == ontop-function */ movl 0x24(%esp), %ecx /* restore ESP (pointing to context-data) from EAX */ diff --git a/util/src/asm/ontop_mips32_o32_elf_gas.S b/util/src/asm/ontop_mips32_o32_elf_gas.S index c69203c6..6bb124d4 100644 --- a/util/src/asm/ontop_mips32_o32_elf_gas.S +++ b/util/src/asm/ontop_mips32_o32_elf_gas.S @@ -40,11 +40,11 @@ .file "ontop_mips32_o32_elf_gas.S" .text -.globl ontop_fcontext +.globl tars_ontop_fcontext .align 2 -.type ontop_fcontext,@function -.ent ontop_fcontext -ontop_fcontext: +.type tars_ontop_fcontext,@function +.ent tars_ontop_fcontext +tars_ontop_fcontext: # reserve space on stack addiu $sp, $sp, -96 @@ -113,8 +113,8 @@ ontop_fcontext: # jump to context jr $t9 -.end ontop_fcontext -.size ontop_fcontext, .-ontop_fcontext +.end tars_ontop_fcontext +.size tars_ontop_fcontext, .-tars_ontop_fcontext /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits diff --git a/util/src/asm/ontop_ppc32_sysv_elf_gas.S b/util/src/asm/ontop_ppc32_sysv_elf_gas.S index 464d99d5..96939e1c 100644 --- a/util/src/asm/ontop_ppc32_sysv_elf_gas.S +++ b/util/src/asm/ontop_ppc32_sysv_elf_gas.S @@ -52,12 +52,12 @@ .file "ontop_ppc32_sysv_elf_gas.S" .text -.globl ontop_fcontext +.globl tars_ontop_fcontext .align 2 -.type ontop_fcontext,@function -ontop_fcontext: - # Linux: ontop_fcontext( hidden transfer_t * R3, R4, R5, R6) - # Other: transfer_t R3:R4 = jump_fcontext( R3, R4, R5) +.type tars_ontop_fcontext,@function +tars_ontop_fcontext: + # Linux: tars_ontop_fcontext( hidden transfer_t * R3, R4, R5, R6) + # Other: transfer_t R3:R4 = tars_jump_fcontext( R3, R4, R5) mflr %r0 # return address from LR mffs %f0 # FPSCR @@ -186,8 +186,8 @@ ontop_fcontext: # see tail_ppc32_sysv_elf_gas.cpp # Linux: fcontext_ontop_tail( hidden transfer_t * R3, R4, R5, R6, R7) # Other: transfer_t R3:R4 = fcontext_ontop_tail( R3, R4, R5, R6) - b ontop_fcontext_tail -.size ontop_fcontext, .-ontop_fcontext + b tars_ontop_fcontext_tail +.size tars_ontop_fcontext, .-tars_ontop_fcontext /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits diff --git a/util/src/asm/ontop_ppc32_sysv_macho_gas.S b/util/src/asm/ontop_ppc32_sysv_macho_gas.S index 1eb5f934..30aa8372 100644 --- a/util/src/asm/ontop_ppc32_sysv_macho_gas.S +++ b/util/src/asm/ontop_ppc32_sysv_macho_gas.S @@ -74,9 +74,9 @@ *******************************************************/ .text -.globl _ontop_fcontext +.globl _tars_ontop_fcontext .align 2 -_ontop_fcontext: +_tars_ontop_fcontext: # reserve space on stack subi r1, r1, 244 diff --git a/util/src/asm/ontop_ppc32_sysv_xcoff_gas.S b/util/src/asm/ontop_ppc32_sysv_xcoff_gas.S index a3c9fa23..a8ed5b4d 100644 --- a/util/src/asm/ontop_ppc32_sysv_xcoff_gas.S +++ b/util/src/asm/ontop_ppc32_sysv_xcoff_gas.S @@ -72,13 +72,13 @@ * ------------------------------------------------- * * * *******************************************************/ -.globl .ontop_fcontext -.globl ontop_fcontext[DS] +.globl .tars_ontop_fcontext +.globl tars_ontop_fcontext[DS] .align 2 -.csect ontop_fcontext[DS] -ontop_fcontext: - .long .ontop_fcontext -.ontop_fcontext: +.csect tars_ontop_fcontext[DS] +tars_ontop_fcontext: + .long .tars_ontop_fcontext +.tars_ontop_fcontext: # reserve space on stack subi r1, r1, 244 diff --git a/util/src/asm/ontop_ppc64_sysv_elf_gas.S b/util/src/asm/ontop_ppc64_sysv_elf_gas.S index cd97f456..9bbac289 100644 --- a/util/src/asm/ontop_ppc64_sysv_elf_gas.S +++ b/util/src/asm/ontop_ppc64_sysv_elf_gas.S @@ -67,33 +67,33 @@ *******************************************************/ .file "ontop_ppc64_sysv_elf_gas.S" -.globl ontop_fcontext +.globl tars_ontop_fcontext #if _CALL_ELF == 2 .text .align 2 -ontop_fcontext: - addis %r2, %r12, .TOC.-ontop_fcontext@ha - addi %r2, %r2, .TOC.-ontop_fcontext@l - .localentry ontop_fcontext, . - ontop_fcontext +tars_ontop_fcontext: + addis %r2, %r12, .TOC.-tars_ontop_fcontext@ha + addi %r2, %r2, .TOC.-tars_ontop_fcontext@l + .localentry tars_ontop_fcontext, . - tars_ontop_fcontext #else .section ".opd","aw" .align 3 -ontop_fcontext: +tars_ontop_fcontext: # ifdef _CALL_LINUX - .quad .L.ontop_fcontext,.TOC.@tocbase,0 - .type ontop_fcontext,@function + .quad .L.tars_ontop_fcontext,.TOC.@tocbase,0 + .type tars_ontop_fcontext,@function .text .align 2 -.L.ontop_fcontext: +.L.tars_ontop_fcontext: # else - .hidden .ontop_fcontext - .globl .ontop_fcontext - .quad .ontop_fcontext,.TOC.@tocbase,0 - .size ontop_fcontext,24 - .type .ontop_fcontext,@function + .hidden .tars_ontop_fcontext + .globl .tars_ontop_fcontext + .quad .tars_ontop_fcontext,.TOC.@tocbase,0 + .size tars_ontop_fcontext,24 + .type .tars_ontop_fcontext,@function .text .align 2 -.ontop_fcontext: +.tars_ontop_fcontext: # endif #endif # reserve space on stack @@ -209,7 +209,7 @@ return_to_ctx: bctr #if _CALL_ELF == 2 - .size ontop_fcontext, .-ontop_fcontext + .size tars_ontop_fcontext, .-tars_ontop_fcontext #else use_entry_arg: # compute return-value struct address @@ -233,9 +233,9 @@ use_entry_arg: b return_to_ctx # ifdef _CALL_LINUX - .size .ontop_fcontext, .-.L.ontop_fcontext + .size .tars_ontop_fcontext, .-.L.tars_ontop_fcontext # else - .size .ontop_fcontext, .-.ontop_fcontext + .size .tars_ontop_fcontext, .-.tars_ontop_fcontext # endif #endif diff --git a/util/src/asm/ontop_ppc64_sysv_macho_gas.S b/util/src/asm/ontop_ppc64_sysv_macho_gas.S index 5de8acd1..37e031c0 100644 --- a/util/src/asm/ontop_ppc64_sysv_macho_gas.S +++ b/util/src/asm/ontop_ppc64_sysv_macho_gas.S @@ -68,9 +68,9 @@ .text .align 2 -.globl _ontop_fcontext +.globl _tars_ontop_fcontext -_ontop_fcontext: +_tars_ontop_fcontext: ; reserve space on stack subi r1, r1, 184 diff --git a/util/src/asm/ontop_ppc64_sysv_xcoff_gas.S b/util/src/asm/ontop_ppc64_sysv_xcoff_gas.S index 93f8c234..d953dfcd 100644 --- a/util/src/asm/ontop_ppc64_sysv_xcoff_gas.S +++ b/util/src/asm/ontop_ppc64_sysv_xcoff_gas.S @@ -1,6 +1,6 @@ .align 2 -.globl .ontop_fcontext -.ontop_fcontext: +.globl .tars_ontop_fcontext +.tars_ontop_fcontext: # reserve space on stack subi 1, 1, 184 diff --git a/util/src/asm/ontop_x86_64_ms_pe_gas.asm b/util/src/asm/ontop_x86_64_ms_pe_gas.asm index 02e040c9..7de98117 100644 --- a/util/src/asm/ontop_x86_64_ms_pe_gas.asm +++ b/util/src/asm/ontop_x86_64_ms_pe_gas.asm @@ -89,10 +89,10 @@ .file "ontop_x86_64_ms_pe_gas.asm" .text .p2align 4,,15 -.globl ontop_fcontext -.def ontop_fcontext; .scl 2; .type 32; .endef -.seh_proc ontop_fcontext -ontop_fcontext: +.globl tars_ontop_fcontext +.def tars_ontop_fcontext; .scl 2; .type 32; .endef +.seh_proc tars_ontop_fcontext +tars_ontop_fcontext: .seh_endprologue leaq -0x118(%rsp), %rsp /* prepare stack */ @@ -208,4 +208,4 @@ ontop_fcontext: .seh_endproc .section .drectve -.ascii " -export:\"ontop_fcontext\"" +.ascii " -export:\"tars_ontop_fcontext\"" diff --git a/util/src/asm/ontop_x86_64_ms_pe_masm.asm b/util/src/asm/ontop_x86_64_ms_pe_masm.asm index 99dfedb9..c07f371c 100644 --- a/util/src/asm/ontop_x86_64_ms_pe_masm.asm +++ b/util/src/asm/ontop_x86_64_ms_pe_masm.asm @@ -84,7 +84,7 @@ .code -ontop_fcontext PROC EXPORT FRAME +tars_ontop_fcontext PROC EXPORT FRAME .endprolog ; prepare stack @@ -203,5 +203,5 @@ ENDIF ; indirect jump to context jmp r9 -ontop_fcontext ENDP +tars_ontop_fcontext ENDP END diff --git a/util/src/asm/ontop_x86_64_sysv_elf_gas.S b/util/src/asm/ontop_x86_64_sysv_elf_gas.S index 4cdba400..6209c45e 100644 --- a/util/src/asm/ontop_x86_64_sysv_elf_gas.S +++ b/util/src/asm/ontop_x86_64_sysv_elf_gas.S @@ -26,10 +26,10 @@ .file "ontop_x86_64_sysv_elf_gas.S" .text -.globl ontop_fcontext -.type ontop_fcontext,@function +.globl tars_ontop_fcontext +.type tars_ontop_fcontext,@function .align 16 -ontop_fcontext: +tars_ontop_fcontext: /* preserve ontop-function in R8 */ movq %rdx, %r8 @@ -88,7 +88,7 @@ ontop_fcontext: /* indirect jump to context */ jmp *%r8 -.size ontop_fcontext,.-ontop_fcontext +.size tars_ontop_fcontext,.-tars_ontop_fcontext /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits diff --git a/util/src/asm/ontop_x86_64_sysv_macho_gas.S b/util/src/asm/ontop_x86_64_sysv_macho_gas.S index 49755c69..e9e90728 100644 --- a/util/src/asm/ontop_x86_64_sysv_macho_gas.S +++ b/util/src/asm/ontop_x86_64_sysv_macho_gas.S @@ -25,9 +25,9 @@ ****************************************************************************************/ .text -.globl _ontop_fcontext +.globl _tars_ontop_fcontext .align 8 -_ontop_fcontext: +_tars_ontop_fcontext: /* preserve ontop-function in R8 */ movq %rdx, %r8 diff --git a/util/src/tc_coroutine.cpp b/util/src/tc_coroutine.cpp index 3da86e16..46a68832 100755 --- a/util/src/tc_coroutine.cpp +++ b/util/src/tc_coroutine.cpp @@ -245,9 +245,9 @@ void TC_CoroutineInfo::registerFunc(const std::function& callback) _init_func.args = this; - fcontext_t ctx = make_fcontext(_stack_ctx.sp, _stack_ctx.size, TC_CoroutineInfo::corotineEntry); + fcontext_t ctx = tars_make_fcontext(_stack_ctx.sp, _stack_ctx.size, TC_CoroutineInfo::corotineEntry); - transfer_t tf = jump_fcontext(ctx, this); + transfer_t tf = tars_jump_fcontext(ctx, this); //实际的ctx this->setCtx(tf.fctx); @@ -260,7 +260,7 @@ void TC_CoroutineInfo::corotineEntry(transfer_t tf) auto func = coro->_init_func.coroFunc; void* args = coro->_init_func.args; - transfer_t t = jump_fcontext(tf.fctx, NULL); + transfer_t t = tars_jump_fcontext(tf.fctx, NULL); //拿到自己的协程堆栈, 当前协程结束以后, 好跳转到main coro->_scheduler->setMainCtx(t.fctx); @@ -688,7 +688,7 @@ void TC_CoroutineScheduler::switchCoro(TC_CoroutineInfo *to) //跳转到to协程 _currentCoro = to; - transfer_t t = jump_fcontext(to->getCtx(), NULL); + transfer_t t = tars_jump_fcontext(to->getCtx(), NULL); //并保存协程堆栈 to->setCtx(t.fctx); From 4fdea5f8b1fb3b2cebad041c033f1a1eca906058 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Mon, 8 Jan 2024 15:10:46 +0800 Subject: [PATCH 31/81] ServantHandle in servant use shared ptr --- servant/libservant/Servant.cpp | 8 ++++---- servant/libservant/ServantHandle.cpp | 2 +- servant/servant/Servant.h | 7 ++++--- unit-test/server/HelloImp.cpp | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/servant/libservant/Servant.cpp b/servant/libservant/Servant.cpp index 0be18daa..5ac263cc 100644 --- a/servant/libservant/Servant.cpp +++ b/servant/libservant/Servant.cpp @@ -27,7 +27,7 @@ namespace tars thread_local shared_ptr CallbackThreadData::g_sp; -Servant::Servant():_handle(NULL) +Servant::Servant() //:_handle(NULL) { } @@ -62,14 +62,14 @@ string Servant::getModuleName() return _application->getServerBaseInfo().Application + "." + _application->getServerBaseInfo().ServerName; } -void Servant::setHandle(TC_EpollServer::Handle* handle) +void Servant::setHandle(const shared_ptr &handle) { _handle = handle; } -TC_EpollServer::Handle* Servant::getHandle() +shared_ptr Servant::getHandle() { - return _handle; + return _handle.lock(); } int Servant::dispatch(CurrentPtr current, vector &buffer) diff --git a/servant/libservant/ServantHandle.cpp b/servant/libservant/ServantHandle.cpp index 48103a43..6c52224d 100644 --- a/servant/libservant/ServantHandle.cpp +++ b/servant/libservant/ServantHandle.cpp @@ -162,7 +162,7 @@ void ServantHandle::initialize() try { - _servant->setHandle(this); + _servant->setHandle(shared_from_this()); _servant->initialize(); diff --git a/servant/servant/Servant.h b/servant/servant/Servant.h index b72e1820..89a2c2c6 100644 --- a/servant/servant/Servant.h +++ b/servant/servant/Servant.h @@ -29,6 +29,7 @@ namespace tars { class Application; +class ServantHandle; //////////////////////////////////////////////////////////////////// /** @@ -63,7 +64,7 @@ class Servant : public BaseNotify * 设置所属的Handle * @param handle */ - void setHandle(TC_EpollServer::Handle* handle); + void setHandle(const shared_ptr &handle); /** * 设置全局的应用 @@ -87,7 +88,7 @@ class Servant : public BaseNotify * 获取所属的Handle * @return HandlePtr& */ - TC_EpollServer::Handle* getHandle(); + shared_ptr getHandle(); /** * 初始化 @@ -208,7 +209,7 @@ class Servant : public BaseNotify /** * 所属的Handle */ - TC_EpollServer::Handle* _handle; + std::weak_ptr _handle; /** * 异步响应队列, 每个Servant一个队列, 这个用于在ServantImp中, 再异步发请求给其他服务 diff --git a/unit-test/server/HelloImp.cpp b/unit-test/server/HelloImp.cpp index 3f599d7b..cbd82829 100755 --- a/unit-test/server/HelloImp.cpp +++ b/unit-test/server/HelloImp.cpp @@ -150,7 +150,7 @@ bool HelloImp::testCoro(const std::string& sIn, std::string &sOut, CurrentPtr cu int HelloImp::testConHash(std::string &sOut, CurrentPtr current) { - sOut = _handle->getBindAdapter()->getEndpoint().toString(); + sOut = getHandle()->getBindAdapter()->getEndpoint().toString(); return 0; } From e4c873f59aef09eec1f92017c0539e5ea48a7fb4 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Fri, 12 Jan 2024 20:21:14 +0800 Subject: [PATCH 32/81] fix remote logger remove ServerConfig::Context --- servant/libservant/RemoteLogger.cpp | 6 ++++-- servant/libservant/ServantHandle.cpp | 2 +- servant/libservant/ServantProxy.cpp | 2 ++ servant/protocol | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/servant/libservant/RemoteLogger.cpp b/servant/libservant/RemoteLogger.cpp index ef3b86ad..37afdcc6 100644 --- a/servant/libservant/RemoteLogger.cpp +++ b/servant/libservant/RemoteLogger.cpp @@ -114,7 +114,9 @@ void RollWriteT::setDyeingLogInfo(const string &sApp, const string &sServer, con LocalRollLogger::~LocalRollLogger() { - for(auto e : _logger_ex) + terminate(); + + for(const auto& e : _logger_ex) { delete e.second; } @@ -518,7 +520,7 @@ void TimeWriteT::operator()(ostream &of, const deque > &buf { try { - _logPrx->logger(DYEING_DIR, DYEING_FILE, "day", "%Y%m%d", vDyeingLog, ServerConfig::Context); + _logPrx->logger(DYEING_DIR, DYEING_FILE, "day", "%Y%m%d", vDyeingLog, _logPrx->tars_communicator()->getClientConfig().Context); } catch(exception &ex) { diff --git a/servant/libservant/ServantHandle.cpp b/servant/libservant/ServantHandle.cpp index 6c52224d..3748d1bc 100644 --- a/servant/libservant/ServantHandle.cpp +++ b/servant/libservant/ServantHandle.cpp @@ -581,7 +581,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) int ret = TARSSERVERUNKNOWNERR; - string sResultDesc = ""; + string sResultDesc; ResponsePacket response; diff --git a/servant/libservant/ServantProxy.cpp b/servant/libservant/ServantProxy.cpp index 4e08be66..58c0c12c 100644 --- a/servant/libservant/ServantProxy.cpp +++ b/servant/libservant/ServantProxy.cpp @@ -814,12 +814,14 @@ uint32_t ServantProxy::tars_gen_requestid() void ServantProxy::tars_set_push_callback(const ServantProxyCallbackPtr & cb) { + std::lock_guard lock(_mutex); _pushCallback = cb; cb->setServantPrx(this); } ServantProxyCallbackPtr ServantProxy::tars_get_push_callback() { + std::lock_guard lock(_mutex); return _pushCallback; } diff --git a/servant/protocol b/servant/protocol index bbae12db..0dbd080c 160000 --- a/servant/protocol +++ b/servant/protocol @@ -1 +1 @@ -Subproject commit bbae12db66dc96b651fe1545a6b7387e1ec02091 +Subproject commit 0dbd080c8f1b927a7a3f7e5a36e134855dfa58c8 From 90db0b4d46a19bd8655bec84fd0e6f6ca3b26a56 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Mon, 15 Jan 2024 20:54:45 +0800 Subject: [PATCH 33/81] tc_port add closeAllFileDescriptors, and fix forkExec bug --- util/include/util/tc_port.h | 17 ++++-- util/include/util/tc_socket.h | 12 ++-- util/src/tc_port.cpp | 104 +++++++++++++++++++++++----------- 3 files changed, 89 insertions(+), 44 deletions(-) diff --git a/util/include/util/tc_port.h b/util/include/util/tc_port.h index eda7ff1c..455b40ec 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -124,14 +124,21 @@ class TC_Port /** * fork子进程并运行程序 * @param sExe: 可执行程序路径 - * @param sPwdPath: 程序运行的当前路径 - * @param sRollLogPath: 滚动日志路径(stdout会重定向到滚动日志), 为空则不重定向 - * @param vOptions: 参数 + * @param sPwdPath: 设置程序运行的当前路径(chdir) + * @param sRollLogPath: 重定向输出路径(stdout/stderr会重定向到该日志文件), 为空则不重定向 + * @param vArgs: 参数 * @return 子进程id: ==0: 子进程中, >0: 父进程中(子进程pid), 其他抛出异常 TC_Port_Exception */ - static int64_t forkExec(const string& sExe, const string& sPwdPath, const string& sRollLogPath, const vector& vOptions); + static int64_t forkExec(const string& sExe, const string& sPwdPath, const string& sRollLogPath, const vector& vArgs); - /** +#if TARGET_PLATFORM_IOS || TARGET_PLATFORM_LINUX + /** + * 关闭所有当前进程的文件句柄(除了stdin/stdout/stderr) + */ + static void closeAllFileDescriptors(); +#endif + + /** * 注册ctrl+c回调事件(SIGINT/CTRL_C_EVENT) * @param callback * @return size_t, 注册事件的id, 取消注册时需要 diff --git a/util/include/util/tc_socket.h b/util/include/util/tc_socket.h index 13ec6adf..d09eabaa 100644 --- a/util/include/util/tc_socket.h +++ b/util/include/util/tc_socket.h @@ -586,12 +586,12 @@ class TC_Socket */ static bool isInProgress(); - /** - * @brief 关闭句柄 - * - * @return - */ - static void closeSocketNoThrow(int); +// /** +// * @brief 关闭句柄 +// * +// * @return +// */ +// static void closeSocketNoThrow(int); #if 0 /** diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index 43c899b7..bb467e03 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -41,6 +41,10 @@ #include "util/tc_strptime.h" #endif +#if TARGET_PLATFORM_IOS +#include +#endif + namespace tars { @@ -280,6 +284,51 @@ std::string TC_Port::exec(const char* cmd, std::string &err) return fileData; } +#if TARGET_PLATFORM_LINUX +void TC_Port::closeAllFileDescriptors() { + DIR *dir; + struct dirent *entry; + int fd; + + dir = opendir("/proc/self/fd"); + if (dir == NULL) { + perror("Cannot open /proc/self/fd"); + exit(EXIT_FAILURE); + } + + while ((entry = readdir(dir)) != NULL) { + fd = atoi(entry->d_name); + if (fd > STDERR_FILENO) { // Skip stdin, stdout, and stderr + close(fd); + } + } + + closedir(dir); +} + +#elif TARGET_PLATFORM_IOS + +void TC_Port::closeAllFileDescriptors() +{ + int max_fd; + int fd; + size_t len = sizeof(max_fd); + + // Get the maximum file descriptor number for the current process + if (sysctlbyname("kern.maxfilesperproc", &max_fd, &len, NULL, 0) < 0) + { + return; + } + + for (fd = STDERR_FILENO + 1; fd < max_fd; fd++) + { + close(fd); + } +} + +#endif + + int64_t TC_Port::forkExec(const string& sExePath, const string& sPwdPath, const string& sRollLogPath, const vector& vOptions) { vector vEnvs; @@ -348,8 +397,18 @@ int64_t TC_Port::forkExec(const string& sExePath, const string& sPwdPath, const return pi.dwProcessId; #else + + string bin = sExePath; + if(!TC_File::isAbsolute(bin)) + { + char current_directory[FILENAME_MAX] = {0x00}; + getcwd(current_directory, sizeof(current_directory)); + + bin = TC_File::simplifyDirectory(string(current_directory) + FILE_SEP + bin); + } + vector vArgs; - vArgs.push_back(sExePath); + vArgs.push_back(bin); vArgs.insert(vArgs.end(), vOptions.begin(), vOptions.end()); int argc = static_cast(vArgs.size()); @@ -371,49 +430,28 @@ int64_t TC_Port::forkExec(const string& sExePath, const string& sPwdPath, const if (pid == 0) { - int maxFd = static_cast(sysconf(_SC_OPEN_MAX)); - for (int fd = 3; fd < maxFd; ++fd) - { - close(fd); - } + closeAllFileDescriptors(); - //server stdcout 日志在滚动日志显示 + //stdout/stderr 重定向到日志文件里面 if (!sRollLogPath.empty()) { TC_File::makeDirRecursive(TC_File::extractFilePath(sRollLogPath)); #if TARGET_PLATFORM_IOS - if ((freopen(sRollLogPath.c_str(), "ab", stdout)) != NULL && (freopen(sRollLogPath.c_str(), "ab", stderr)) != NULL) -#else - if ((freopen64(sRollLogPath.c_str(), "ab", stdout)) != NULL && (freopen64(sRollLogPath.c_str(), "ab", stderr)) != NULL) -#endif - { - cout << argv[0] << " redirect stdout and stderr to " << sRollLogPath << endl; - } - else - { - //重定向失败 直接退出 - exit(0); - } - } - else - { - cout << argv[0] << " cannot redirect stdout and stderr to log file sRollLogPath is empty" << endl; + freopen(sRollLogPath.c_str(), "ab", stdout); + freopen(sRollLogPath.c_str(), "ab", stderr); +#else + freopen64(sRollLogPath.c_str(), "ab", stdout); + freopen64(sRollLogPath.c_str(), "ab", stderr); +#endif } -// for_each(vEnvs.begin(), vEnvs.end(), EnvVal()); - if (strlen(pwdCStr) != 0) { - if (chdir(pwdCStr) == -1) - { - cerr << argv[0] << " cannot change working directory to " << pwdCStr << "|errno=" << errno << endl; - } + chdir(pwdCStr); } - if (execvp(argv[0], argv) == -1) - { - cerr << "cannot execute " << argv[0] << "|errno=" << strerror(errno) << endl; - } + execvp(argv[0], argv); + exit(0); } else From 64a457dd3eed1d3a7d6eb068f85f98da391a1cd0 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 18 Jan 2024 14:16:33 +0800 Subject: [PATCH 34/81] tc_port add kill AdminF.tars add getPid bind after initialize when Applicaion start --- servant/libservant/AdminServant.cpp | 5 + servant/libservant/Application.cpp | 141 +++++++++++++----------- servant/protocol | 2 +- servant/servant/AdminServant.h | 4 + servant/servant/Application.h | 13 ++- unit-test/rpc/test_admin.cpp | 10 +- unit-test/server/framework/QueryImp.cpp | 12 +- util/include/util/tc_epoll_server.h | 20 ++-- util/include/util/tc_port.h | 6 + util/src/tc_epoll_server.cpp | 11 +- util/src/tc_port.cpp | 17 +++ 11 files changed, 154 insertions(+), 87 deletions(-) diff --git a/servant/libservant/AdminServant.cpp b/servant/libservant/AdminServant.cpp index 4ebf0535..6b481eb0 100644 --- a/servant/libservant/AdminServant.cpp +++ b/servant/libservant/AdminServant.cpp @@ -65,5 +65,10 @@ string AdminServant::notify(const string &command, CurrentPtr current) return this->getApplication()->getNotifyObserver()->notify(command, current); } +long AdminServant::getPid(CurrentPtr current) +{ + return getpid(); +} + /////////////////////////////////////////////////////////////////////// } diff --git a/servant/libservant/Application.cpp b/servant/libservant/Application.cpp index ed3d0346..246324f3 100644 --- a/servant/libservant/Application.cpp +++ b/servant/libservant/Application.cpp @@ -778,9 +778,6 @@ void Application::main(const TC_Option &option) string config = TC_File::load2str(ServerConfig::ConfigFile); - __out__.debug() << "config:" << ServerConfig::ConfigFile << endl; - __out__.debug() << "config:" << config << endl; - main(config); } @@ -800,6 +797,9 @@ void Application::main(const string &config) //解析配置文件 parseConfig(config); + __out__.debug() << "config:" << ServerConfig::ConfigFile << endl; + __out__.debug() << "config:" << config << endl; + //初始化Proxy部分 initializeClient(); @@ -808,21 +808,7 @@ void Application::main(const string &config) _serverBaseInfo = ServerConfig::toServerBaseInfo(); - vector adapters; - - //绑定对象和端口 - bindAdapter(adapters); - - stringstream os; - - //输出所有adapter - outAllAdapter(os); - - __out__.info() << os.str(); - - __out__.info() << "\n" << TC_Common::outfill("[initialize server] ", '.') << " [Done]" << endl; - - __out__.info() << OUT_LINE_LONG << endl; + initializeAdapter(); { bool initing = true; @@ -835,7 +821,6 @@ void Application::main(const string &config) { //发送心跳给node, 表示正在启动 _keepAliveNodeFHelper->keepActiving(); -// TARS_KEEPACTIVING; //等待initialize初始化完毕 std::unique_lock lock(kmtx); @@ -871,6 +856,9 @@ void Application::main(const string &config) } } + //绑定对象和端口 + bindAdapters(); + if (!_applicationCommunicator->getProperty("locator").empty() && _serverBaseInfo.BakType > 0) { int timeout = TC_Common::strto(_conf.get("/tars/application/server", "5000")); @@ -989,6 +977,51 @@ void Application::main(const string &config) LocalRollLogger::getInstance()->sync(false); } +void Application::initializeAdapter() +{ + //创建adapter, 不绑定端口 + vector adapters = createAdapter(); + + if (!_serverBaseInfo.Local.empty()) + { + _servantHelper->addServant("AdminObj", this); + + string adminAdapter = "AdminAdapter"; + + _servantHelper->setAdapterServant(adminAdapter, "AdminObj"); + + TC_EpollServer::BindAdapterPtr lsPtr = _epollServer->createBindAdapter(adminAdapter, _serverBaseInfo.Local, 1, this); + + setAdapter(lsPtr, adminAdapter); + + lsPtr->setMaxConns(TC_EpollServer::BindAdapter::DEFAULT_MAX_CONN); + + lsPtr->setQueueCapacity(TC_EpollServer::BindAdapter::DEFAULT_QUEUE_CAP); + + lsPtr->setQueueTimeout(TC_EpollServer::BindAdapter::DEFAULT_QUEUE_TIMEOUT); + + lsPtr->setProtocolName("tars"); + + lsPtr->setProtocol(AppProtocol::parse); + + adapters.push_back(lsPtr); +// _epollServer->bind(lsPtr); + } + + _epollServer->setAdapter(adapters); + + stringstream os; + + //输出所有adapter + outAllAdapter(os); + + __out__.info() << os.str(); + + __out__.info() << "\n" << TC_Common::outfill("[initialize server] ", '.') << " [Done]" << endl; + + __out__.info() << OUT_LINE_LONG << endl; + +} void Application::parseConfig(const string &config) { @@ -1038,6 +1071,7 @@ void Application::initializeClient() //一个进程内嵌多个Application时发生, 正常业务服务不会发生 _applicationCommunicator = CommunicatorFactory::getInstance()->getCommunicator(_conf, TC_Common::tostr(this)); } + _applicationCommunicator->initialize(); __out__.info() << TC_Common::outfill("[proxy config]:") << endl; @@ -1193,7 +1227,6 @@ void Application::initializeServer() ServerConfig::ServerName = toDefault(_conf.get("/tars/application/server"), exe); - #if TARGET_PLATFORM_WINDOWS ServerConfig::BasePath = TC_File::simplifyDirectory(_conf.get("/tars/application/server")) + FILE_SEP; if (ServerConfig::BasePath == FILE_SEP) @@ -1315,9 +1348,6 @@ void Application::initializeServer() _epollServer->setOnAccept(std::bind(&Application::onAccept, this, std::placeholders::_1)); //初始化服务是否对空链接进行超时检查 -// bool bEnable = (_conf.get("/tars/application/server","0")=="1")?true:false; - -// _epollServer->enAntiEmptyConnAttack(bEnable); _epollServer->setEmptyConnTimeout(TC_Common::strto(toDefault(_conf.get("/tars/application/server"), "0"))); @@ -1373,32 +1403,6 @@ void Application::initializeServer() //初始化管理对象 __out__.info() << OUT_LINE << "\n" << TC_Common::outfill("[set admin adapter]") << "OK" << endl; - if (!ServerConfig::Local.empty()) - { - _servantHelper->addServant("AdminObj", this); - - string adminAdapter = "AdminAdapter"; - - _servantHelper->setAdapterServant(adminAdapter, "AdminObj"); - - TC_EpollServer::BindAdapterPtr lsPtr = _epollServer->createBindAdapter(adminAdapter, ServerConfig::Local, 1, this); - - setAdapter(lsPtr, adminAdapter); - - lsPtr->setMaxConns(TC_EpollServer::BindAdapter::DEFAULT_MAX_CONN); - - lsPtr->setQueueCapacity(TC_EpollServer::BindAdapter::DEFAULT_QUEUE_CAP); - - lsPtr->setQueueTimeout(TC_EpollServer::BindAdapter::DEFAULT_QUEUE_TIMEOUT); - - lsPtr->setProtocolName("tars"); - - lsPtr->setProtocol(AppProtocol::parse); - - _epollServer->bind(lsPtr); - - } - //队列取平均值 if(!_applicationCommunicator->getProperty("property").empty()) { @@ -1450,9 +1454,11 @@ void Application::setAdapter(TC_EpollServer::BindAdapterPtr& adapter, const stri } -void Application::bindAdapter(vector& adapters) +vector Application::createAdapter() { - string sPrefix = ServerConfig::Application + "." + ServerConfig::ServerName + "."; + vector adapters; + + string sPrefix = _serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + "."; vector adapterName; @@ -1473,13 +1479,13 @@ void Application::bindAdapter(vector& adapters) ep.parse(_conf[sLastPath + ""]); if (ep.getHost() == "localip") { - ep.setHost(ServerConfig::LocalIp); + ep.setHost(_serverBaseInfo.LocalIp); } TC_EpollServer::BindAdapterPtr bindAdapter = _epollServer->createBindAdapter(adapterName[i], _conf[sLastPath + ""], TC_Common::strto(_conf.get(sLastPath + "", "1")), this); //init auth & ssl - setAdapter(bindAdapter, adapterName[i]); + setAdapter(bindAdapter, adapterName[i]); bindAdapter->setMaxConns(TC_Common::strto(_conf.get(sLastPath + "", "128"))); @@ -1495,11 +1501,11 @@ void Application::bindAdapter(vector& adapters) bindAdapter->setProtocolName(_conf.get(sLastPath + "", "tars")); - bindAdapter->setBackPacketBuffLimit(ServerConfig::BackPacketLimit); + bindAdapter->setBackPacketBuffLimit(ServerConfig::BackPacketLimit); - bindAdapter->setBackPacketBuffMin(ServerConfig::BackPacketMin); + bindAdapter->setBackPacketBuffMin(ServerConfig::BackPacketMin); - if (bindAdapter->isTarsProtocol()) + if (bindAdapter->isTarsProtocol()) { bindAdapter->setProtocol(AppProtocol::parse); } @@ -1513,15 +1519,12 @@ void Application::bindAdapter(vector& adapters) } #endif - if(ServerConfig::ManualListen) { + if(_serverBaseInfo.ManualListen) + { //手工监听 bindAdapter->enableManualListen(); } - _epollServer->bind(bindAdapter); - - adapters.push_back(bindAdapter); - //队列取平均值 if(!_applicationCommunicator->getProperty("property").empty()) { @@ -1536,15 +1539,27 @@ void Application::bindAdapter(vector& adapters) bindAdapter->_pReportTimeoutNum = p.get(); p = _applicationCommunicator->getStatReport()->createPropertyReport(bindAdapter->getName() + ".queueWaitTime", - PropertyReport::avg(), PropertyReport::min(), PropertyReport::max(), PropertyReport::count()); + PropertyReport::avg(), PropertyReport::min(), PropertyReport::max(), PropertyReport::count()); bindAdapter->_pReportQueueWaitTime = p.get(); p = _applicationCommunicator->getStatReport()->createPropertyReport(bindAdapter->getName() + ".servantHandleTime", - PropertyReport::avg(), PropertyReport::min(), PropertyReport::max(), PropertyReport::count()); + PropertyReport::avg(), PropertyReport::min(), PropertyReport::max(), PropertyReport::count()); bindAdapter->_pReportServantHandleTime = p.get(); } + + adapters.push_back(bindAdapter); } } + + return adapters; +} + +void Application::bindAdapters() +{ + for(auto adapter : _epollServer->getBindAdapters()) + { + _epollServer->bind(adapter); + } } void Application::checkServantNameValid(const string& servant, const string& sPrefix) diff --git a/servant/protocol b/servant/protocol index 0dbd080c..291877b3 160000 --- a/servant/protocol +++ b/servant/protocol @@ -1 +1 @@ -Subproject commit 0dbd080c8f1b927a7a3f7e5a36e134855dfa58c8 +Subproject commit 291877b3a9a7155f4530b0e639707eea135d7a2c diff --git a/servant/servant/AdminServant.h b/servant/servant/AdminServant.h index c4cc67de..94f8a40b 100644 --- a/servant/servant/AdminServant.h +++ b/servant/servant/AdminServant.h @@ -65,6 +65,10 @@ class AdminServant : public AdminF */ string notify(const string &command, CurrentPtr current); + /** + * 获取服务的pid + */ + long getPid(CurrentPtr current); }; //////////////////////////////////////////////////////////////// } diff --git a/servant/servant/Application.h b/servant/servant/Application.h index 3d7f358d..cc4fd22b 100644 --- a/servant/servant/Application.h +++ b/servant/servant/Application.h @@ -603,10 +603,21 @@ class Application: public BaseNotify */ TC_EpollServer::BindAdapter::EOrder parseOrder(const string &s); + /** + * 初始化adapter + */ + void initializeAdapter(); + + /** + * 根据配置创建adapter + * @return + */ + vector createAdapter(); + /** * bind server adapter */ - void bindAdapter(vector &adapters); + void bindAdapters(); /** * set adapter diff --git a/unit-test/rpc/test_admin.cpp b/unit-test/rpc/test_admin.cpp index 84bd3c66..53e9b523 100755 --- a/unit-test/rpc/test_admin.cpp +++ b/unit-test/rpc/test_admin.cpp @@ -22,6 +22,10 @@ TEST_F(HelloTest, testAdmin) { + LocalRollLogger::getInstance()->setLogInfo("tars", "test", ".", 1024*1024*10, 5, nullptr, ""); + + LocalRollLogger::getInstance()->logger()->setLogLevel("TARS"); + FrameworkServer fs; startServer(fs, FRAMEWORK_CONFIG()); @@ -31,15 +35,17 @@ TEST_F(HelloTest, testAdmin) WinServer ws; startServer(ws, WIN_CONFIG()); -// auto c = getCommunicator(); - CommunicatorPtr c = ws.getCommunicator(); string adminObj = "AdminObj@" + getLocalEndpoint(WIN_CONFIG()).toString(); AdminFPrx adminFPrx = c->stringToProxy(adminObj); + adminFPrx->tars_ping(); + + LOG_CONSOLE_DEBUG << endl; string loadconfig = adminFPrx->notify("tars.loadconfig test.conf"); + LOG_CONSOLE_DEBUG << loadconfig << endl; EXPECT_TRUE(loadconfig.find("[succ] get remote config:") != string::npos); loadconfig = adminFPrx->notify("tars.loadconfig no-test.conf"); diff --git a/unit-test/server/framework/QueryImp.cpp b/unit-test/server/framework/QueryImp.cpp index 271abec8..4b2e5e15 100755 --- a/unit-test/server/framework/QueryImp.cpp +++ b/unit-test/server/framework/QueryImp.cpp @@ -12,7 +12,7 @@ void QueryImp::initialize() vector QueryImp::findObjectById(const string & id, tars::CurrentPtr current) { - LOG_CONSOLE_DEBUG << endl; +// LOG_CONSOLE_DEBUG << endl; vector eps = _db.findObjectById(id); ostringstream os; @@ -23,7 +23,7 @@ vector QueryImp::findObjectById(const string & id, tars::CurrentPtr c tars::Int32 QueryImp::findObjectById4Any(const std::string & id,vector &activeEp,vector &inactiveEp,tars::CurrentPtr current) { - LOG_CONSOLE_DEBUG << endl; +// LOG_CONSOLE_DEBUG << endl; int iRet = _db.findObjectById4All(id, activeEp, inactiveEp); ostringstream os; @@ -34,7 +34,7 @@ tars::Int32 QueryImp::findObjectById4Any(const std::string & id,vector &activeEp,vector &inactiveEp,tars::CurrentPtr current) { - LOG_CONSOLE_DEBUG << endl; +// LOG_CONSOLE_DEBUG << endl; ostringstream os; int iRet = _db.findObjectByIdInGroupPriority(id,current->getIp(),activeEp, inactiveEp,os); @@ -46,7 +46,7 @@ int QueryImp::findObjectById4All(const std::string & id, vector int QueryImp::findObjectByIdInSameGroup(const std::string & id, vector &activeEp,vector &inactiveEp, tars::CurrentPtr current) { - LOG_CONSOLE_DEBUG << endl; +// LOG_CONSOLE_DEBUG << endl; ostringstream os; TLOGINFO(__FUNCTION__ << ":" << __LINE__ << "|" << id << "|" << current->getIp() << endl); @@ -59,7 +59,7 @@ int QueryImp::findObjectByIdInSameGroup(const std::string & id, vector &activeEp, vector &inactiveEp, tars::CurrentPtr current) { - LOG_CONSOLE_DEBUG << endl; +// LOG_CONSOLE_DEBUG << endl; ostringstream os; int iRet = _db.findObjectByIdInSameStation(id, sStation, activeEp, inactiveEp, os); @@ -71,7 +71,7 @@ Int32 QueryImp::findObjectByIdInSameStation(const std::string & id, const std::s Int32 QueryImp::findObjectByIdInSameSet(const std::string & id,const std::string & setId,vector &activeEp,vector &inactiveEp, tars::CurrentPtr current) { - LOG_CONSOLE_DEBUG << endl; +// LOG_CONSOLE_DEBUG << endl; vector vtSetInfo = TC_Common::sepstr(setId,"."); if (vtSetInfo.size()!=3 ||(vtSetInfo.size()==3&&(vtSetInfo[0]=="*"||vtSetInfo[1]=="*"))) diff --git a/util/include/util/tc_epoll_server.h b/util/include/util/tc_epoll_server.h index 57feaf35..82ebced3 100755 --- a/util/include/util/tc_epoll_server.h +++ b/util/include/util/tc_epoll_server.h @@ -1609,18 +1609,6 @@ class TC_EpollServer : public TC_HandleBase, public detail::LogInterface * 是否手工监听 */ bool _manualListen = false; -// /** -// * 创建一个udp句柄, 用来通知事后listen -// */ -// TC_Socket _udpNotify; -// -// /** -// * 通知 -// */ -// TC_Epoller::EpollInfo *_notifyInfo = NULL; - - //连接关闭的回调函数 -// close_functor _closeFunc; /** * ssl ctx @@ -2203,11 +2191,17 @@ class TC_EpollServer : public TC_HandleBase, public detail::LogInterface } /** - * 绑定监听socket + * 绑定并设置adapter * @param ls */ int bind(BindAdapterPtr &lsPtr); + /** + * 设置adapter + * @param adapters + */ + void setAdapter(const vector &adapters); + /** * 初始化handle对象 */ diff --git a/util/include/util/tc_port.h b/util/include/util/tc_port.h index 455b40ec..600a73f7 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -105,6 +105,12 @@ class TC_Port */ static void setEnv(const std::string &name, const std::string &value); + /** + * kill某个pid的进程 + * @param pid + */ + static void kill(int64_t pid); + /** * 运行一个脚本 * @param cmd diff --git a/util/src/tc_epoll_server.cpp b/util/src/tc_epoll_server.cpp index 7a9d12f5..34960e82 100644 --- a/util/src/tc_epoll_server.cpp +++ b/util/src/tc_epoll_server.cpp @@ -2227,6 +2227,11 @@ void TC_EpollServer::setEmptyConnTimeout(int timeout) } } +void TC_EpollServer::setAdapter(const vector &adapters) +{ + _bindAdapters = adapters; +} + int TC_EpollServer::bind(BindAdapterPtr & lsPtr) { auto it = _listeners.begin(); @@ -2247,7 +2252,11 @@ int TC_EpollServer::bind(BindAdapterPtr & lsPtr) _listeners[lsPtr->getSocket().getfd()] = lsPtr; } - _bindAdapters.push_back(lsPtr); + //如果adapter没有添加过, 则添加 + if(!getBindAdapter(lsPtr->getName())) + { + _bindAdapters.push_back(lsPtr); + } return lsPtr->getSocket().getfd(); } diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index bb467e03..99b9f0ce 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -251,6 +251,23 @@ void TC_Port::setEnv(const string &name, const string &value) #endif } +void TC_Port::kill(int64_t pid) +{ +#if TARGET_PLATFORM_WINDOWS + HANDLE hProcess = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid); + if (hProcess == NULL) + { + return; + } + + ::TerminateProcess(hProcess, 0); + + CloseHandle(hProcess); +#else + ::kill(static_cast(pid), SIGKILL); +#endif +} + string TC_Port::exec(const char *cmd) { string err; From b8354c6b03a60f04c4e95f14a82b23a5d993afeb Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Sun, 21 Jan 2024 18:47:47 +0800 Subject: [PATCH 35/81] tc_file add toAbsolute tc_port add getCwd Application first bind adminObj, then initialize, then bind other objs EndpointInfo add toEndpointF --- servant/libservant/AdminServant.cpp | 2 ++ servant/libservant/Application.cpp | 10 +++++-- servant/libservant/EndpointInfo.cpp | 22 ++++++++++++++ servant/protocol | 2 +- servant/servant/EndpointInfo.h | 7 +++++ util/include/util/tc_file.h | 7 +++++ util/include/util/tc_port.h | 6 ++++ util/src/tc_epoll_server.cpp | 45 +++++++++++++++-------------- util/src/tc_file.cpp | 9 ++++++ util/src/tc_port.cpp | 13 +++++++++ 10 files changed, 98 insertions(+), 25 deletions(-) diff --git a/servant/libservant/AdminServant.cpp b/servant/libservant/AdminServant.cpp index 6b481eb0..3ae7a582 100644 --- a/servant/libservant/AdminServant.cpp +++ b/servant/libservant/AdminServant.cpp @@ -44,6 +44,8 @@ void AdminServant::shutdown(CurrentPtr current) { TLOGERROR("[TARS][AdminServant::shutdown] from node" << endl); + _application->getApplicationCommunicator()->terminate(); + _application->terminate(); #if TARGET_PLATFORM_WINDOWS HANDLE hProcess = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId()); if (hProcess == NULL) diff --git a/servant/libservant/Application.cpp b/servant/libservant/Application.cpp index 246324f3..7962eb3f 100644 --- a/servant/libservant/Application.cpp +++ b/servant/libservant/Application.cpp @@ -1005,7 +1005,9 @@ void Application::initializeAdapter() lsPtr->setProtocol(AppProtocol::parse); adapters.push_back(lsPtr); -// _epollServer->bind(lsPtr); + + //admin端口先做绑定, 服务就算一直卡着initialize, 也能被外部管理了. + _epollServer->bind(lsPtr); } _epollServer->setAdapter(adapters); @@ -1558,7 +1560,11 @@ void Application::bindAdapters() { for(auto adapter : _epollServer->getBindAdapters()) { - _epollServer->bind(adapter); + if(!adapter->getSocket().isValid()) + { + //未绑定, 才绑定 + _epollServer->bind(adapter); + } } } diff --git a/servant/libservant/EndpointInfo.cpp b/servant/libservant/EndpointInfo.cpp index 463bf589..605419a0 100755 --- a/servant/libservant/EndpointInfo.cpp +++ b/servant/libservant/EndpointInfo.cpp @@ -65,5 +65,27 @@ string EndpointInfo::createCompareDesc() return ss.str(); } + +EndpointF EndpointInfo::toEndpointF(const TC_Endpoint &tep, const string &nodeName) +{ + EndpointF ep; + ep.host = tep.getHost(); + ep.port = tep.getPort(); + ep.istcp = tep.getType(); + ep.nodeName = nodeName; + if(ep.nodeName.empty()) + { + ep.nodeName = tep.getHost(); + } + ep.timeout = tep.getTimeout(); + ep.authType = tep.getAuthType(); + ep.qos = tep.getQos(); + ep.weight = tep.getWeight(); + ep.weightType = tep.getWeightType(); + + return ep; +} + + /////////////////////////////////////////////////////////// } diff --git a/servant/protocol b/servant/protocol index 291877b3..a35c297d 160000 --- a/servant/protocol +++ b/servant/protocol @@ -1 +1 @@ -Subproject commit 291877b3a9a7155f4530b0e639707eea135d7a2c +Subproject commit a35c297d7fc2ece47428d661a2834a5a3521e5a0 diff --git a/servant/servant/EndpointInfo.h b/servant/servant/EndpointInfo.h index 82faf9fc..b03751fd 100755 --- a/servant/servant/EndpointInfo.h +++ b/servant/servant/EndpointInfo.h @@ -55,6 +55,13 @@ class EndpointInfo */ EndpointInfo(const EndpointF &ep); + /** + * 转换 + * @param ep + * @return + */ + static EndpointF toEndpointF(const TC_Endpoint &ep, const string &nodeName); + /** * get endpoint * @return diff --git a/util/include/util/tc_file.h b/util/include/util/tc_file.h index 40946be0..901b2664 100644 --- a/util/include/util/tc_file.h +++ b/util/include/util/tc_file.h @@ -82,6 +82,13 @@ class TC_File */ static bool isAbsolute(const string &sFullFileName); + /** + * 如果是相对路径则转换为绝对路径 + * @param sFullFileName + * @return + */ + static string toAbsolute(const string &sFullFileName); + /** * @brief 判断给定路径的文件是否存在. * 如果文件是符号连接,则以符号连接判断而不是以符号连接指向的文件判断 diff --git a/util/include/util/tc_port.h b/util/include/util/tc_port.h index 600a73f7..6065de8f 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -105,6 +105,12 @@ class TC_Port */ static void setEnv(const std::string &name, const std::string &value); + /** + * 获取当前进程的目录 + * @return + */ + static string getCwd(); + /** * kill某个pid的进程 * @param pid diff --git a/util/src/tc_epoll_server.cpp b/util/src/tc_epoll_server.cpp index 34960e82..1f5f6da3 100644 --- a/util/src/tc_epoll_server.cpp +++ b/util/src/tc_epoll_server.cpp @@ -1908,17 +1908,23 @@ TC_EpollServer::TC_EpollServer(unsigned int iNetThreadNum) { #if TARGET_PLATFORM_WINDOWS WSADATA wsadata; -WSAStartup(MAKEWORD(2, 2), &wsadata); + WSAStartup(MAKEWORD(2, 2), &wsadata); #endif -// -// _epoller.create(10240); -// _epoller.setName("epollserver-epoller"); + + _epoller = new TC_Epoller(); + _epoller->create(10240); + _epoller->setName("epollserver-epoller"); + } TC_EpollServer::~TC_EpollServer() { terminate(); + delete _epoller; + + _epoller = NULL; + #if TARGET_PLATFORM_WINDOWS WSACleanup(); #endif @@ -2011,15 +2017,7 @@ bool TC_EpollServer::accept(int fd, int domain) return true; } - // else - // { - // //直到发生EAGAIN才不继续accept - // if (TC_Socket::isPending()) - // { - // return false; - // } - // } - // return true; + return false; } @@ -2105,9 +2103,7 @@ void TC_EpollServer::listenCallback(weak_ptr adapterPtr) void TC_EpollServer::waitForShutdown() { - _epoller = new TC_Epoller(); - _epoller->create(10240); - _epoller->setName("epollserver-epoller"); + _epoller->reset(); _readyThreadNum = 0; @@ -2122,7 +2118,7 @@ void TC_EpollServer::waitForShutdown() _epoller->postRepeated(5000, false, [&](){ _hf(this);}); } - for(auto it : _bindAdapters) + for(const auto& it : _bindAdapters) { if(it->getEndpoint().isTcp()) { @@ -2192,9 +2188,9 @@ void TC_EpollServer::waitForShutdown() bindAdapter->getHandles().clear(); } - delete _epoller; - - _epoller = NULL; +// delete _epoller; +// +// _epoller = NULL; std::unique_lock lock(_readyMutex); @@ -2205,11 +2201,15 @@ void TC_EpollServer::waitForShutdown() void TC_EpollServer::terminate() { - if(_epoller == NULL || _epoller->isTerminate()) + if(_epoller->isTerminate()) { return; } - +// if(_epoller == NULL || _epoller->isTerminate()) +// { +// return; +// } +// //先停止网络线程 _epoller->terminate(); @@ -2242,6 +2242,7 @@ int TC_EpollServer::bind(BindAdapterPtr & lsPtr) { throw TC_Exception("bind name '" + lsPtr->getName() + "' conflicts."); } + ++it; } diff --git a/util/src/tc_file.cpp b/util/src/tc_file.cpp index 96c72a10..5c6efe0f 100644 --- a/util/src/tc_file.cpp +++ b/util/src/tc_file.cpp @@ -60,6 +60,15 @@ bool TC_File::isAbsolute(const string &sFullFileName) #endif } +string TC_File::toAbsolute(const string &sFullFileName) +{ + if(!isAbsolute(sFullFileName)) + { + return simplifyDirectory(TC_Port::getCwd() + FILE_SEP + sFullFileName); + } + return sFullFileName; +} + bool TC_File::isFileExist(const string &sFullFileName, mode_t iFileType) { TC_Port::stat_t f_stat; diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index 99b9f0ce..75ea50a2 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -251,6 +251,17 @@ void TC_Port::setEnv(const string &name, const string &value) #endif } +string TC_Port::getCwd() +{ + char currentDirectory[FILENAME_MAX] = {0x00}; +#if TARGET_PLATFORM_WINDOWS + _getcwd(currentDirectory, sizeof(currentDirectory)); +#else + getcwd(currentDirectory, sizeof(currentDirectory)); +#endif + return currentDirectory; +} + void TC_Port::kill(int64_t pid) { #if TARGET_PLATFORM_WINDOWS @@ -627,6 +638,7 @@ BOOL WINAPI TC_Port::HandlerRoutine(DWORD dwCtrlType) } #endif +#if TARGET_PLATFORM_LINUX static int64_t reSize(int64_t i, const char unit) { @@ -643,6 +655,7 @@ static int64_t reSize(int64_t i, const char unit) } return i; } +#endif // 获取指定进程占用物理内存大小, 单位(字节) int64_t TC_Port::getPidMemUsed(int64_t pid, const char unit) From 563aa541a079eeedf74cb082bf9588bcd294a74c Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 23 Jan 2024 10:27:53 +0800 Subject: [PATCH 36/81] tc_file add joinPaths --- unit-test/util/test_tc_file.cpp | 7 +++++++ util/include/util/tc_file.h | 25 ++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/unit-test/util/test_tc_file.cpp b/unit-test/util/test_tc_file.cpp index 68f404f4..b26ebd94 100644 --- a/unit-test/util/test_tc_file.cpp +++ b/unit-test/util/test_tc_file.cpp @@ -150,3 +150,10 @@ TEST_F(UtilFileTest, config) ASSERT_TRUE(volumes.size() == 2); } + +TEST_F(UtilFileTest, join) +{ + string v = TC_File::joinPaths("abc", string("def"), string("ddd")); + + cout << v << endl; +} diff --git a/util/include/util/tc_file.h b/util/include/util/tc_file.h index 901b2664..02711e54 100644 --- a/util/include/util/tc_file.h +++ b/util/include/util/tc_file.h @@ -310,8 +310,31 @@ class TC_File */ static bool startWindowsPanfu(const string & sPath); + /** + * 连接参数, 变成路径 + * @tparam T + * @tparam Args + * @param t + * @param args + * @return + */ + template + static std::string joinPaths(T t, Args... args) { + return string(t) + FILE_SEP + joinPaths(args...); + } private: - static bool isPanfu(const string & sPath); + // Base case: single argument + template + static std::string joinPaths(T t) { + return t; + } + + /** + * 是否是windows的盘符 + * @param sPath + * @return + */ + static bool isPanfu(const string & sPath); }; } #endif // TC_FILE_H From e56c028714e1537589567b0e2f113abd6277e1dd Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 23 Jan 2024 11:35:25 +0800 Subject: [PATCH 37/81] feat: joinPaths auto check FILE_SEP --- unit-test/util/test_tc_file.cpp | 14 ++++++++++++-- util/include/util/tc_file.h | 6 +++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/unit-test/util/test_tc_file.cpp b/unit-test/util/test_tc_file.cpp index b26ebd94..7a75f856 100644 --- a/unit-test/util/test_tc_file.cpp +++ b/unit-test/util/test_tc_file.cpp @@ -153,7 +153,17 @@ TEST_F(UtilFileTest, config) TEST_F(UtilFileTest, join) { - string v = TC_File::joinPaths("abc", string("def"), string("ddd")); + string v1 = TC_File::joinPaths("abc", string("def"), string("ddd")); + + ASSERT_TRUE(v1 == string("abc") + FILE_SEP + "def" + FILE_SEP + "ddd"); + + string v2 = TC_File::joinPaths("abc/", string("def"), string("ddd")); + + ASSERT_TRUE(v2 == string("abc") + FILE_SEP + "def" + FILE_SEP + "ddd"); + + string v3 = TC_File::joinPaths("abc/", string("def/"), string("ddd")); + + ASSERT_TRUE(v3 == string("abc") + FILE_SEP + "def" + FILE_SEP + "ddd"); + - cout << v << endl; } diff --git a/util/include/util/tc_file.h b/util/include/util/tc_file.h index 02711e54..db051152 100644 --- a/util/include/util/tc_file.h +++ b/util/include/util/tc_file.h @@ -320,7 +320,11 @@ class TC_File */ template static std::string joinPaths(T t, Args... args) { - return string(t) + FILE_SEP + joinPaths(args...); + std::string str_t = string(t); + if (!str_t.empty() && str_t.back() != FILE_SEP[0]) + str_t += FILE_SEP; + return str_t + joinPaths(args...); +// return string(t) + FILE_SEP + joinPaths(args...); } private: // Base case: single argument From 2f4fa7c66747059853bdd2ff02a46ff8a771a183 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 23 Jan 2024 20:08:48 +0800 Subject: [PATCH 38/81] fix windows compiler --- servant/libservant/AdminServant.cpp | 2 +- servant/servant/AdminServant.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/servant/libservant/AdminServant.cpp b/servant/libservant/AdminServant.cpp index 3ae7a582..f024cbfd 100644 --- a/servant/libservant/AdminServant.cpp +++ b/servant/libservant/AdminServant.cpp @@ -67,7 +67,7 @@ string AdminServant::notify(const string &command, CurrentPtr current) return this->getApplication()->getNotifyObserver()->notify(command, current); } -long AdminServant::getPid(CurrentPtr current) +tars::Int64 AdminServant::getPid(CurrentPtr current) { return getpid(); } diff --git a/servant/servant/AdminServant.h b/servant/servant/AdminServant.h index 94f8a40b..442b5345 100644 --- a/servant/servant/AdminServant.h +++ b/servant/servant/AdminServant.h @@ -68,7 +68,7 @@ class AdminServant : public AdminF /** * 获取服务的pid */ - long getPid(CurrentPtr current); + tars::Int64 getPid(CurrentPtr current); }; //////////////////////////////////////////////////////////////// } From a5c650fe3ea5930410504db45df7e11d79157098 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 23 Jan 2024 20:39:05 +0800 Subject: [PATCH 39/81] fix tars-tools.cmake in windows --- servant/makefile/tars-tools.cmake.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/servant/makefile/tars-tools.cmake.in b/servant/makefile/tars-tools.cmake.in index e2fb3365..eb0d0259 100755 --- a/servant/makefile/tars-tools.cmake.in +++ b/servant/makefile/tars-tools.cmake.in @@ -3,8 +3,13 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +if(WIN32) +set(TARS2CPP "@CMAKE_INSTALL_PREFIX@/tools/tars2cpp.exe" CACHE STRING "set tars2cpp path") +set(TARSMERGE "@CMAKE_INSTALL_PREFIX@/tools/tarsmerge.exe" CACHE STRING "set tarsmerge path") +else() set(TARS2CPP "@CMAKE_INSTALL_PREFIX@/tools/tars2cpp" CACHE STRING "set tars2cpp path") set(TARSMERGE "@CMAKE_INSTALL_PREFIX@/tools/tarsmerge" CACHE STRING "set tarsmerge path") +endif() set(TARS_PATH "@CMAKE_INSTALL_PREFIX@") option(TARS_MYSQL "open mysql support" @TARS_MYSQL@) From 108f6a5e3706269908e2f40b933c8ea73bfb9c0f Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 24 Jan 2024 10:09:01 +0800 Subject: [PATCH 40/81] feat: tc_port getDiskInfo/getCPUProcessor/getSystemMemInfo/getUPTime/getPidStartTime/getPidMemUsed support windows/mac --- tools/tarsgrammar/tars.tab.cpp | 266 ++++++++++++++++---------------- tools/tarsparse/tars.lex.cpp | 36 ++--- tools/tarsparse/tars.tab.cpp | 266 ++++++++++++++++---------------- unit-test/util/test_tc_port.cpp | 64 ++++++++ util/include/util/tc_port.h | 13 +- util/src/tc_port.cpp | 260 +++++++++++++++++++++++++++---- 6 files changed, 586 insertions(+), 319 deletions(-) diff --git a/tools/tarsgrammar/tars.tab.cpp b/tools/tarsgrammar/tars.tab.cpp index ea2659e4..9fb66bc2 100644 --- a/tools/tarsgrammar/tars.tab.cpp +++ b/tools/tarsgrammar/tars.tab.cpp @@ -67,7 +67,7 @@ /* First part of user prologue. */ -#line 17 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 17 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" #include #include @@ -1384,14 +1384,14 @@ yyparse (void) switch (yyn) { case 3: /* $@1: %empty */ -#line 75 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 75 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1391 "tars.tab.cpp" break; case 5: /* $@2: %empty */ -#line 79 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 79 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyerrok; } @@ -1399,7 +1399,7 @@ yyparse (void) break; case 7: /* definitions: definition */ -#line 84 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 84 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } @@ -1407,14 +1407,14 @@ yyparse (void) break; case 8: /* definitions: %empty */ -#line 88 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 88 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1414 "tars.tab.cpp" break; case 9: /* definition: namespace_def */ -#line 96 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 96 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || NamespacePtr::dynamicCast(yyvsp[0])); } @@ -1422,7 +1422,7 @@ yyparse (void) break; case 10: /* definition: interface_def */ -#line 100 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 100 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || InterfacePtr::dynamicCast(yyvsp[0])); } @@ -1430,7 +1430,7 @@ yyparse (void) break; case 11: /* definition: struct_def */ -#line 104 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 104 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || StructPtr::dynamicCast(yyvsp[0])); } @@ -1438,14 +1438,14 @@ yyparse (void) break; case 12: /* definition: key_def */ -#line 108 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 108 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1445 "tars.tab.cpp" break; case 13: /* definition: enum_def */ -#line 111 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 111 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || EnumPtr::dynamicCast(yyvsp[0])); } @@ -1453,7 +1453,7 @@ yyparse (void) break; case 14: /* definition: const_def */ -#line 115 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 115 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || ConstPtr::dynamicCast(yyvsp[0])); } @@ -1461,7 +1461,7 @@ yyparse (void) break; case 15: /* @3: %empty */ -#line 124 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 124 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1469,7 +1469,7 @@ yyparse (void) break; case 16: /* enum_def: enum_id @3 '{' enumerator_list '}' */ -#line 128 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 128 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1487,7 +1487,7 @@ yyparse (void) break; case 17: /* enum_id: TARS_ENUM TARS_IDENTIFIER */ -#line 147 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 147 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { NamespacePtr c = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!c) @@ -1504,7 +1504,7 @@ yyparse (void) break; case 18: /* enum_id: TARS_ENUM keyword */ -#line 160 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 160 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumeration name"); @@ -1514,7 +1514,7 @@ yyparse (void) break; case 19: /* enumerator_list: enumerator ',' enumerator_list */ -#line 171 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 171 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[-1]; } @@ -1522,14 +1522,14 @@ yyparse (void) break; case 20: /* enumerator_list: enumerator */ -#line 175 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 175 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1529 "tars.tab.cpp" break; case 21: /* enumerator: TARS_IDENTIFIER */ -#line 183 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 183 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1544,7 +1544,7 @@ yyparse (void) break; case 22: /* enumerator: keyword */ -#line 194 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 194 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumerator"); @@ -1553,7 +1553,7 @@ yyparse (void) break; case 23: /* enumerator: TARS_IDENTIFIER '=' const_initializer */ -#line 199 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 199 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -1570,14 +1570,14 @@ yyparse (void) break; case 24: /* enumerator: %empty */ -#line 212 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 212 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1577 "tars.tab.cpp" break; case 25: /* @4: %empty */ -#line 220 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 220 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ContainerPtr c = g_parse->currentContainer(); @@ -1596,7 +1596,7 @@ yyparse (void) break; case 26: /* namespace_def: TARS_NAMESPACE TARS_IDENTIFIER @4 '{' definitions '}' */ -#line 235 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 235 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1612,7 +1612,7 @@ yyparse (void) break; case 27: /* $@5: %empty */ -#line 253 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 253 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-1]); StructPtr sp = StructPtr::dynamicCast(g_parse->findUserType(ident->v)); @@ -1627,14 +1627,14 @@ yyparse (void) break; case 28: /* key_def: TARS_KEY '[' scoped_name ',' $@5 key_members ']' */ -#line 264 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 264 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1634 "tars.tab.cpp" break; case 29: /* key_members: TARS_IDENTIFIER */ -#line 272 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 272 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1651,7 +1651,7 @@ yyparse (void) break; case 30: /* key_members: key_members ',' TARS_IDENTIFIER */ -#line 285 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 285 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1668,7 +1668,7 @@ yyparse (void) break; case 31: /* @6: %empty */ -#line 304 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 304 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1689,7 +1689,7 @@ yyparse (void) break; case 32: /* interface_def: interface_id @6 '{' interface_exports '}' */ -#line 321 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 321 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1705,7 +1705,7 @@ yyparse (void) break; case 33: /* interface_id: TARS_INTERFACE TARS_IDENTIFIER */ -#line 338 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 338 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1713,7 +1713,7 @@ yyparse (void) break; case 34: /* interface_id: TARS_INTERFACE keyword */ -#line 342 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 342 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as interface name"); @@ -1723,21 +1723,21 @@ yyparse (void) break; case 35: /* interface_exports: interface_export ';' interface_exports */ -#line 353 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 353 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1730 "tars.tab.cpp" break; case 36: /* interface_exports: error ';' interface_exports */ -#line 356 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 356 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1737 "tars.tab.cpp" break; case 37: /* interface_exports: interface_export */ -#line 359 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 359 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } @@ -1745,14 +1745,14 @@ yyparse (void) break; case 38: /* interface_exports: %empty */ -#line 363 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 363 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1752 "tars.tab.cpp" break; case 40: /* operation: operation_preamble parameters ')' */ -#line 377 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 377 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1768,7 +1768,7 @@ yyparse (void) break; case 41: /* operation_preamble: return_type TARS_OP */ -#line 394 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 394 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1796,7 +1796,7 @@ yyparse (void) break; case 43: /* return_type: TARS_VOID */ -#line 424 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 424 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = 0; } @@ -1804,14 +1804,14 @@ yyparse (void) break; case 44: /* parameters: %empty */ -#line 434 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 434 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1811 "tars.tab.cpp" break; case 45: /* parameters: type_id */ -#line 437 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 437 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1826,7 +1826,7 @@ yyparse (void) break; case 46: /* parameters: parameters ',' type_id */ -#line 448 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 448 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1841,7 +1841,7 @@ yyparse (void) break; case 47: /* parameters: out_qualifier type_id */ -#line 459 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 459 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1857,7 +1857,7 @@ yyparse (void) break; case 48: /* parameters: parameters ',' out_qualifier type_id */ -#line 471 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 471 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1873,7 +1873,7 @@ yyparse (void) break; case 49: /* parameters: routekey_qualifier type_id */ -#line 483 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 483 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1889,7 +1889,7 @@ yyparse (void) break; case 50: /* parameters: parameters ',' routekey_qualifier type_id */ -#line 495 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 495 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1905,7 +1905,7 @@ yyparse (void) break; case 51: /* parameters: out_qualifier */ -#line 507 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 507 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("'out' must be defined with a type"); } @@ -1913,7 +1913,7 @@ yyparse (void) break; case 52: /* parameters: routekey_qualifier */ -#line 511 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 511 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("'routekey' must be defined with a type"); } @@ -1921,7 +1921,7 @@ yyparse (void) break; case 53: /* routekey_qualifier: TARS_ROUTE_KEY */ -#line 520 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 520 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr routekey = new BoolGrammar; routekey->v = true; @@ -1931,7 +1931,7 @@ yyparse (void) break; case 54: /* out_qualifier: TARS_OUT */ -#line 531 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 531 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr out = new BoolGrammar; out->v = true; @@ -1941,7 +1941,7 @@ yyparse (void) break; case 55: /* @7: %empty */ -#line 542 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 542 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); @@ -1967,7 +1967,7 @@ yyparse (void) break; case 56: /* struct_def: struct_id @7 '{' struct_exports '}' */ -#line 564 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 564 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1986,7 +1986,7 @@ yyparse (void) break; case 57: /* struct_id: TARS_STRUCT TARS_IDENTIFIER */ -#line 584 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 584 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1994,7 +1994,7 @@ yyparse (void) break; case 58: /* struct_id: TARS_STRUCT keyword */ -#line 588 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 588 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2004,7 +2004,7 @@ yyparse (void) break; case 59: /* struct_id: TARS_STRUCT error */ -#line 594 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 594 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("abstract declarator '' used as declaration"); } @@ -2012,7 +2012,7 @@ yyparse (void) break; case 60: /* struct_exports: data_member ';' struct_exports */ -#line 603 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 603 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } @@ -2020,7 +2020,7 @@ yyparse (void) break; case 61: /* struct_exports: data_member */ -#line 607 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 607 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("';' missing after definition"); } @@ -2028,14 +2028,14 @@ yyparse (void) break; case 62: /* struct_exports: %empty */ -#line 611 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 611 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2035 "tars.tab.cpp" break; case 63: /* data_member: struct_type_id */ -#line 621 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 621 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2043,7 +2043,7 @@ yyparse (void) break; case 64: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id */ -#line 630 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 630 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2065,7 +2065,7 @@ yyparse (void) break; case 65: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id '=' const_initializer */ -#line 648 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 648 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2091,7 +2091,7 @@ yyparse (void) break; case 66: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id '=' const_initializer */ -#line 670 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 670 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2117,7 +2117,7 @@ yyparse (void) break; case 67: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id */ -#line 692 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 692 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2138,7 +2138,7 @@ yyparse (void) break; case 68: /* struct_type_id: TARS_REQUIRE type_id */ -#line 709 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 709 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } @@ -2146,7 +2146,7 @@ yyparse (void) break; case 69: /* struct_type_id: TARS_OPTIONAL type_id */ -#line 713 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 713 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } @@ -2154,7 +2154,7 @@ yyparse (void) break; case 70: /* struct_type_id: TARS_CONST_INTEGER type_id */ -#line 717 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 717 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'require' or 'optional'"); } @@ -2162,7 +2162,7 @@ yyparse (void) break; case 71: /* struct_type_id: type_id */ -#line 721 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 721 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag' or 'require' or 'optional'"); } @@ -2170,7 +2170,7 @@ yyparse (void) break; case 72: /* const_initializer: TARS_CONST_INTEGER */ -#line 730 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 730 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { IntergerGrammarPtr intVal = IntergerGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2184,7 +2184,7 @@ yyparse (void) break; case 73: /* const_initializer: TARS_CONST_FLOAT */ -#line 740 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 740 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { FloatGrammarPtr floatVal = FloatGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2198,7 +2198,7 @@ yyparse (void) break; case 74: /* const_initializer: TARS_STRING_LITERAL */ -#line 750 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 750 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2210,7 +2210,7 @@ yyparse (void) break; case 75: /* const_initializer: TARS_FALSE */ -#line 758 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 758 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2222,7 +2222,7 @@ yyparse (void) break; case 76: /* const_initializer: TARS_TRUE */ -#line 766 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 766 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2234,7 +2234,7 @@ yyparse (void) break; case 77: /* const_initializer: TARS_IDENTIFIER */ -#line 774 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 774 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2251,7 +2251,7 @@ yyparse (void) break; case 78: /* const_initializer: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 787 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 787 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2270,7 +2270,7 @@ yyparse (void) break; case 79: /* const_def: TARS_CONST type_id '=' const_initializer */ -#line 807 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 807 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!np) @@ -2287,7 +2287,7 @@ yyparse (void) break; case 80: /* type_id: type TARS_IDENTIFIER */ -#line 825 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 825 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2300,7 +2300,7 @@ yyparse (void) break; case 81: /* type_id: type TARS_IDENTIFIER '[' TARS_CONST_INTEGER ']' */ -#line 834 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 834 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-4])); IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast(yyvsp[-1]); @@ -2314,7 +2314,7 @@ yyparse (void) break; case 82: /* type_id: type '*' TARS_IDENTIFIER */ -#line 844 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 844 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-2])); //IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast($4); @@ -2328,7 +2328,7 @@ yyparse (void) break; case 83: /* type_id: type TARS_IDENTIFIER ':' TARS_CONST_INTEGER */ -#line 854 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 854 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-3]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2341,7 +2341,7 @@ yyparse (void) break; case 84: /* type_id: type keyword */ -#line 863 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 863 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as data member name"); @@ -2350,7 +2350,7 @@ yyparse (void) break; case 85: /* type_id: type */ -#line 868 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 868 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("missing data member name"); } @@ -2358,7 +2358,7 @@ yyparse (void) break; case 86: /* type_id: error */ -#line 872 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 872 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("unkown type"); } @@ -2366,7 +2366,7 @@ yyparse (void) break; case 87: /* type: type_no ':' TARS_CONST_INTEGER */ -#line 881 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 881 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-2]); @@ -2379,7 +2379,7 @@ yyparse (void) break; case 88: /* type: type_no */ -#line 890 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 890 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -2387,7 +2387,7 @@ yyparse (void) break; case 89: /* type: type_no ':' error */ -#line 894 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 894 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("array missing size"); } @@ -2395,7 +2395,7 @@ yyparse (void) break; case 90: /* type_no: TARS_BOOL */ -#line 903 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 903 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindBool); } @@ -2403,7 +2403,7 @@ yyparse (void) break; case 91: /* type_no: TARS_BYTE */ -#line 907 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 907 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindByte); } @@ -2411,7 +2411,7 @@ yyparse (void) break; case 92: /* type_no: TARS_UNSIGNED TARS_BYTE */ -#line 911 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 911 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort,true); } @@ -2419,7 +2419,7 @@ yyparse (void) break; case 93: /* type_no: TARS_SHORT */ -#line 915 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 915 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort); } @@ -2427,7 +2427,7 @@ yyparse (void) break; case 94: /* type_no: TARS_UNSIGNED TARS_SHORT */ -#line 919 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 919 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt,true); } @@ -2435,7 +2435,7 @@ yyparse (void) break; case 95: /* type_no: TARS_INT */ -#line 923 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 923 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt); } @@ -2443,7 +2443,7 @@ yyparse (void) break; case 96: /* type_no: TARS_UNSIGNED TARS_INT */ -#line 927 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 927 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong,true); } @@ -2451,7 +2451,7 @@ yyparse (void) break; case 97: /* type_no: TARS_LONG */ -#line 931 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 931 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong); } @@ -2459,7 +2459,7 @@ yyparse (void) break; case 98: /* type_no: TARS_FLOAT */ -#line 935 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 935 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindFloat); } @@ -2467,7 +2467,7 @@ yyparse (void) break; case 99: /* type_no: TARS_DOUBLE */ -#line 939 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 939 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindDouble); } @@ -2475,7 +2475,7 @@ yyparse (void) break; case 100: /* type_no: TARS_STRING */ -#line 943 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 943 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindString); } @@ -2483,7 +2483,7 @@ yyparse (void) break; case 101: /* type_no: vector */ -#line 947 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 947 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2491,7 +2491,7 @@ yyparse (void) break; case 102: /* type_no: map */ -#line 951 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 951 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2499,7 +2499,7 @@ yyparse (void) break; case 103: /* type_no: scoped_name */ -#line 955 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 955 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypePtr sp = g_parse->findUserType(ident->v); @@ -2516,7 +2516,7 @@ yyparse (void) break; case 104: /* vector: TARS_VECTOR '<' type '>' */ -#line 973 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 973 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createVector(TypePtr::dynamicCast(yyvsp[-1]))); } @@ -2524,7 +2524,7 @@ yyparse (void) break; case 105: /* vector: TARS_VECTOR '<' error */ -#line 977 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 977 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("vector error"); } @@ -2532,7 +2532,7 @@ yyparse (void) break; case 106: /* vector: TARS_VECTOR '<' type error */ -#line 981 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 981 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing '>'"); } @@ -2540,7 +2540,7 @@ yyparse (void) break; case 107: /* vector: TARS_VECTOR error */ -#line 985 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 985 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing type"); } @@ -2548,7 +2548,7 @@ yyparse (void) break; case 108: /* map: TARS_MAP '<' type ',' type '>' */ -#line 994 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 994 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createMap(TypePtr::dynamicCast(yyvsp[-3]), TypePtr::dynamicCast(yyvsp[-1]))); } @@ -2556,7 +2556,7 @@ yyparse (void) break; case 109: /* map: TARS_MAP '<' error */ -#line 998 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 998 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("map error"); } @@ -2564,14 +2564,14 @@ yyparse (void) break; case 110: /* scoped_name: TARS_IDENTIFIER */ -#line 1007 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1007 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2571 "tars.tab.cpp" break; case 111: /* scoped_name: TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1010 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1010 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ident->v = "::" + ident->v; @@ -2581,7 +2581,7 @@ yyparse (void) break; case 112: /* scoped_name: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1016 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1016 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2593,175 +2593,175 @@ yyparse (void) break; case 113: /* keyword: TARS_STRUCT */ -#line 1029 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1029 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2600 "tars.tab.cpp" break; case 114: /* keyword: TARS_VOID */ -#line 1032 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1032 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2607 "tars.tab.cpp" break; case 115: /* keyword: TARS_BOOL */ -#line 1035 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1035 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2614 "tars.tab.cpp" break; case 116: /* keyword: TARS_BYTE */ -#line 1038 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1038 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2621 "tars.tab.cpp" break; case 117: /* keyword: TARS_SHORT */ -#line 1041 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1041 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2628 "tars.tab.cpp" break; case 118: /* keyword: TARS_INT */ -#line 1044 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1044 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2635 "tars.tab.cpp" break; case 119: /* keyword: TARS_FLOAT */ -#line 1047 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1047 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2642 "tars.tab.cpp" break; case 120: /* keyword: TARS_DOUBLE */ -#line 1050 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1050 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2649 "tars.tab.cpp" break; case 121: /* keyword: TARS_STRING */ -#line 1053 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1053 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2656 "tars.tab.cpp" break; case 122: /* keyword: TARS_VECTOR */ -#line 1056 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1056 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2663 "tars.tab.cpp" break; case 123: /* keyword: TARS_KEY */ -#line 1059 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1059 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2670 "tars.tab.cpp" break; case 124: /* keyword: TARS_MAP */ -#line 1062 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1062 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2677 "tars.tab.cpp" break; case 125: /* keyword: TARS_NAMESPACE */ -#line 1065 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1065 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2684 "tars.tab.cpp" break; case 126: /* keyword: TARS_INTERFACE */ -#line 1068 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1068 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2691 "tars.tab.cpp" break; case 127: /* keyword: TARS_OUT */ -#line 1071 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1071 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2698 "tars.tab.cpp" break; case 128: /* keyword: TARS_REQUIRE */ -#line 1074 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1074 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2705 "tars.tab.cpp" break; case 129: /* keyword: TARS_OPTIONAL */ -#line 1077 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1077 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2712 "tars.tab.cpp" break; case 130: /* keyword: TARS_CONST_INTEGER */ -#line 1080 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1080 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2719 "tars.tab.cpp" break; case 131: /* keyword: TARS_CONST_FLOAT */ -#line 1083 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1083 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2726 "tars.tab.cpp" break; case 132: /* keyword: TARS_FALSE */ -#line 1086 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1086 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2733 "tars.tab.cpp" break; case 133: /* keyword: TARS_TRUE */ -#line 1089 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1089 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2740 "tars.tab.cpp" break; case 134: /* keyword: TARS_STRING_LITERAL */ -#line 1092 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1092 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2747 "tars.tab.cpp" break; case 135: /* keyword: TARS_CONST */ -#line 1095 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1095 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2754 "tars.tab.cpp" break; case 136: /* keyword: TARS_ENUM */ -#line 1098 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1098 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2761 "tars.tab.cpp" break; case 137: /* keyword: TARS_UNSIGNED */ -#line 1101 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1101 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2768 "tars.tab.cpp" @@ -2962,7 +2962,7 @@ yyparse (void) return yyresult; } -#line 1105 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1105 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" diff --git a/tools/tarsparse/tars.lex.cpp b/tools/tarsparse/tars.lex.cpp index bbba0ba7..f1d1280b 100644 --- a/tools/tarsparse/tars.lex.cpp +++ b/tools/tarsparse/tars.lex.cpp @@ -511,7 +511,7 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 1 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" /** * Tencent is pleased to support the open source community by making Tars available. * @@ -527,7 +527,7 @@ char *yytext; * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -#line 20 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 20 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" #include #include #include @@ -776,7 +776,7 @@ YY_DECL } { -#line 67 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 67 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" #line 782 "tars.lex.cpp" @@ -848,12 +848,12 @@ YY_DECL case 1: YY_RULE_SETUP -#line 69 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 69 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" { BEGIN(INCL); } YY_BREAK case 2: YY_RULE_SETUP -#line 71 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 71 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" { if ( include_file_stack_ptr >= MAX_INCLUDE_DEPTH ) { @@ -886,7 +886,7 @@ YY_RULE_SETUP YY_BREAK case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INCL): -#line 101 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 101 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" { --include_file_stack_ptr; if ( include_file_stack_ptr < 0 ) @@ -905,14 +905,14 @@ case YY_STATE_EOF(INCL): YY_BREAK case 3: YY_RULE_SETUP -#line 117 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 117 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" { return TARS_SCOPE_DELIMITER; } YY_BREAK case 4: YY_RULE_SETUP -#line 121 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 121 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" { // C++ comment bool e = false; @@ -933,7 +933,7 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 139 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 139 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" { // C comment bool e = false; @@ -984,7 +984,7 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 187 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 187 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" { StringGrammarPtr ident = new StringGrammar; ident->v = yytext; @@ -995,7 +995,7 @@ YY_RULE_SETUP case 7: /* rule 7 can match eol */ YY_RULE_SETUP -#line 194 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 194 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" { StringGrammarPtr ident = new StringGrammar; ident->v = yytext; @@ -1008,7 +1008,7 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 204 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 204 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" { StringGrammarPtr str = new StringGrammar; bool e = false; @@ -1123,7 +1123,7 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 316 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 316 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" { errno = 0; IntergerGrammarPtr ptr = new IntergerGrammar; @@ -1148,7 +1148,7 @@ YY_RULE_SETUP YY_BREAK case 10: YY_RULE_SETUP -#line 338 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 338 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" { errno = 0; FloatGrammarPtr ptr = new FloatGrammar; @@ -1183,7 +1183,7 @@ YY_RULE_SETUP case 11: /* rule 11 can match eol */ YY_RULE_SETUP -#line 369 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 369 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" { if(yytext[0] == '\n') { @@ -1193,7 +1193,7 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 376 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 376 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" { if(yytext[0] < 32 || yytext[0] > 126) { @@ -1212,7 +1212,7 @@ YY_RULE_SETUP YY_BREAK case 13: YY_RULE_SETUP -#line 392 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 392 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" ECHO; YY_BREAK #line 1218 "tars.lex.cpp" @@ -2230,7 +2230,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 392 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.l" +#line 392 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" diff --git a/tools/tarsparse/tars.tab.cpp b/tools/tarsparse/tars.tab.cpp index ea2659e4..9fb66bc2 100644 --- a/tools/tarsparse/tars.tab.cpp +++ b/tools/tarsparse/tars.tab.cpp @@ -67,7 +67,7 @@ /* First part of user prologue. */ -#line 17 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 17 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" #include #include @@ -1384,14 +1384,14 @@ yyparse (void) switch (yyn) { case 3: /* $@1: %empty */ -#line 75 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 75 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1391 "tars.tab.cpp" break; case 5: /* $@2: %empty */ -#line 79 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 79 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyerrok; } @@ -1399,7 +1399,7 @@ yyparse (void) break; case 7: /* definitions: definition */ -#line 84 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 84 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } @@ -1407,14 +1407,14 @@ yyparse (void) break; case 8: /* definitions: %empty */ -#line 88 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 88 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1414 "tars.tab.cpp" break; case 9: /* definition: namespace_def */ -#line 96 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 96 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || NamespacePtr::dynamicCast(yyvsp[0])); } @@ -1422,7 +1422,7 @@ yyparse (void) break; case 10: /* definition: interface_def */ -#line 100 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 100 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || InterfacePtr::dynamicCast(yyvsp[0])); } @@ -1430,7 +1430,7 @@ yyparse (void) break; case 11: /* definition: struct_def */ -#line 104 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 104 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || StructPtr::dynamicCast(yyvsp[0])); } @@ -1438,14 +1438,14 @@ yyparse (void) break; case 12: /* definition: key_def */ -#line 108 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 108 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1445 "tars.tab.cpp" break; case 13: /* definition: enum_def */ -#line 111 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 111 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || EnumPtr::dynamicCast(yyvsp[0])); } @@ -1453,7 +1453,7 @@ yyparse (void) break; case 14: /* definition: const_def */ -#line 115 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 115 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || ConstPtr::dynamicCast(yyvsp[0])); } @@ -1461,7 +1461,7 @@ yyparse (void) break; case 15: /* @3: %empty */ -#line 124 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 124 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1469,7 +1469,7 @@ yyparse (void) break; case 16: /* enum_def: enum_id @3 '{' enumerator_list '}' */ -#line 128 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 128 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1487,7 +1487,7 @@ yyparse (void) break; case 17: /* enum_id: TARS_ENUM TARS_IDENTIFIER */ -#line 147 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 147 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { NamespacePtr c = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!c) @@ -1504,7 +1504,7 @@ yyparse (void) break; case 18: /* enum_id: TARS_ENUM keyword */ -#line 160 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 160 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumeration name"); @@ -1514,7 +1514,7 @@ yyparse (void) break; case 19: /* enumerator_list: enumerator ',' enumerator_list */ -#line 171 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 171 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[-1]; } @@ -1522,14 +1522,14 @@ yyparse (void) break; case 20: /* enumerator_list: enumerator */ -#line 175 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 175 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1529 "tars.tab.cpp" break; case 21: /* enumerator: TARS_IDENTIFIER */ -#line 183 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 183 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1544,7 +1544,7 @@ yyparse (void) break; case 22: /* enumerator: keyword */ -#line 194 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 194 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumerator"); @@ -1553,7 +1553,7 @@ yyparse (void) break; case 23: /* enumerator: TARS_IDENTIFIER '=' const_initializer */ -#line 199 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 199 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -1570,14 +1570,14 @@ yyparse (void) break; case 24: /* enumerator: %empty */ -#line 212 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 212 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1577 "tars.tab.cpp" break; case 25: /* @4: %empty */ -#line 220 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 220 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ContainerPtr c = g_parse->currentContainer(); @@ -1596,7 +1596,7 @@ yyparse (void) break; case 26: /* namespace_def: TARS_NAMESPACE TARS_IDENTIFIER @4 '{' definitions '}' */ -#line 235 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 235 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1612,7 +1612,7 @@ yyparse (void) break; case 27: /* $@5: %empty */ -#line 253 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 253 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-1]); StructPtr sp = StructPtr::dynamicCast(g_parse->findUserType(ident->v)); @@ -1627,14 +1627,14 @@ yyparse (void) break; case 28: /* key_def: TARS_KEY '[' scoped_name ',' $@5 key_members ']' */ -#line 264 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 264 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1634 "tars.tab.cpp" break; case 29: /* key_members: TARS_IDENTIFIER */ -#line 272 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 272 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1651,7 +1651,7 @@ yyparse (void) break; case 30: /* key_members: key_members ',' TARS_IDENTIFIER */ -#line 285 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 285 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1668,7 +1668,7 @@ yyparse (void) break; case 31: /* @6: %empty */ -#line 304 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 304 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1689,7 +1689,7 @@ yyparse (void) break; case 32: /* interface_def: interface_id @6 '{' interface_exports '}' */ -#line 321 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 321 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1705,7 +1705,7 @@ yyparse (void) break; case 33: /* interface_id: TARS_INTERFACE TARS_IDENTIFIER */ -#line 338 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 338 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1713,7 +1713,7 @@ yyparse (void) break; case 34: /* interface_id: TARS_INTERFACE keyword */ -#line 342 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 342 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as interface name"); @@ -1723,21 +1723,21 @@ yyparse (void) break; case 35: /* interface_exports: interface_export ';' interface_exports */ -#line 353 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 353 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1730 "tars.tab.cpp" break; case 36: /* interface_exports: error ';' interface_exports */ -#line 356 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 356 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1737 "tars.tab.cpp" break; case 37: /* interface_exports: interface_export */ -#line 359 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 359 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } @@ -1745,14 +1745,14 @@ yyparse (void) break; case 38: /* interface_exports: %empty */ -#line 363 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 363 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1752 "tars.tab.cpp" break; case 40: /* operation: operation_preamble parameters ')' */ -#line 377 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 377 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1768,7 +1768,7 @@ yyparse (void) break; case 41: /* operation_preamble: return_type TARS_OP */ -#line 394 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 394 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1796,7 +1796,7 @@ yyparse (void) break; case 43: /* return_type: TARS_VOID */ -#line 424 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 424 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = 0; } @@ -1804,14 +1804,14 @@ yyparse (void) break; case 44: /* parameters: %empty */ -#line 434 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 434 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 1811 "tars.tab.cpp" break; case 45: /* parameters: type_id */ -#line 437 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 437 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1826,7 +1826,7 @@ yyparse (void) break; case 46: /* parameters: parameters ',' type_id */ -#line 448 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 448 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1841,7 +1841,7 @@ yyparse (void) break; case 47: /* parameters: out_qualifier type_id */ -#line 459 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 459 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1857,7 +1857,7 @@ yyparse (void) break; case 48: /* parameters: parameters ',' out_qualifier type_id */ -#line 471 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 471 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1873,7 +1873,7 @@ yyparse (void) break; case 49: /* parameters: routekey_qualifier type_id */ -#line 483 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 483 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1889,7 +1889,7 @@ yyparse (void) break; case 50: /* parameters: parameters ',' routekey_qualifier type_id */ -#line 495 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 495 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1905,7 +1905,7 @@ yyparse (void) break; case 51: /* parameters: out_qualifier */ -#line 507 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 507 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("'out' must be defined with a type"); } @@ -1913,7 +1913,7 @@ yyparse (void) break; case 52: /* parameters: routekey_qualifier */ -#line 511 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 511 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("'routekey' must be defined with a type"); } @@ -1921,7 +1921,7 @@ yyparse (void) break; case 53: /* routekey_qualifier: TARS_ROUTE_KEY */ -#line 520 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 520 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr routekey = new BoolGrammar; routekey->v = true; @@ -1931,7 +1931,7 @@ yyparse (void) break; case 54: /* out_qualifier: TARS_OUT */ -#line 531 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 531 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr out = new BoolGrammar; out->v = true; @@ -1941,7 +1941,7 @@ yyparse (void) break; case 55: /* @7: %empty */ -#line 542 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 542 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); @@ -1967,7 +1967,7 @@ yyparse (void) break; case 56: /* struct_def: struct_id @7 '{' struct_exports '}' */ -#line 564 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 564 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1986,7 +1986,7 @@ yyparse (void) break; case 57: /* struct_id: TARS_STRUCT TARS_IDENTIFIER */ -#line 584 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 584 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1994,7 +1994,7 @@ yyparse (void) break; case 58: /* struct_id: TARS_STRUCT keyword */ -#line 588 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 588 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2004,7 +2004,7 @@ yyparse (void) break; case 59: /* struct_id: TARS_STRUCT error */ -#line 594 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 594 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("abstract declarator '' used as declaration"); } @@ -2012,7 +2012,7 @@ yyparse (void) break; case 60: /* struct_exports: data_member ';' struct_exports */ -#line 603 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 603 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } @@ -2020,7 +2020,7 @@ yyparse (void) break; case 61: /* struct_exports: data_member */ -#line 607 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 607 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("';' missing after definition"); } @@ -2028,14 +2028,14 @@ yyparse (void) break; case 62: /* struct_exports: %empty */ -#line 611 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 611 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2035 "tars.tab.cpp" break; case 63: /* data_member: struct_type_id */ -#line 621 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 621 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2043,7 +2043,7 @@ yyparse (void) break; case 64: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id */ -#line 630 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 630 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2065,7 +2065,7 @@ yyparse (void) break; case 65: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id '=' const_initializer */ -#line 648 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 648 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2091,7 +2091,7 @@ yyparse (void) break; case 66: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id '=' const_initializer */ -#line 670 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 670 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2117,7 +2117,7 @@ yyparse (void) break; case 67: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id */ -#line 692 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 692 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2138,7 +2138,7 @@ yyparse (void) break; case 68: /* struct_type_id: TARS_REQUIRE type_id */ -#line 709 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 709 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } @@ -2146,7 +2146,7 @@ yyparse (void) break; case 69: /* struct_type_id: TARS_OPTIONAL type_id */ -#line 713 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 713 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } @@ -2154,7 +2154,7 @@ yyparse (void) break; case 70: /* struct_type_id: TARS_CONST_INTEGER type_id */ -#line 717 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 717 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'require' or 'optional'"); } @@ -2162,7 +2162,7 @@ yyparse (void) break; case 71: /* struct_type_id: type_id */ -#line 721 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 721 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag' or 'require' or 'optional'"); } @@ -2170,7 +2170,7 @@ yyparse (void) break; case 72: /* const_initializer: TARS_CONST_INTEGER */ -#line 730 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 730 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { IntergerGrammarPtr intVal = IntergerGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2184,7 +2184,7 @@ yyparse (void) break; case 73: /* const_initializer: TARS_CONST_FLOAT */ -#line 740 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 740 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { FloatGrammarPtr floatVal = FloatGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2198,7 +2198,7 @@ yyparse (void) break; case 74: /* const_initializer: TARS_STRING_LITERAL */ -#line 750 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 750 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2210,7 +2210,7 @@ yyparse (void) break; case 75: /* const_initializer: TARS_FALSE */ -#line 758 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 758 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2222,7 +2222,7 @@ yyparse (void) break; case 76: /* const_initializer: TARS_TRUE */ -#line 766 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 766 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2234,7 +2234,7 @@ yyparse (void) break; case 77: /* const_initializer: TARS_IDENTIFIER */ -#line 774 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 774 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2251,7 +2251,7 @@ yyparse (void) break; case 78: /* const_initializer: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 787 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 787 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2270,7 +2270,7 @@ yyparse (void) break; case 79: /* const_def: TARS_CONST type_id '=' const_initializer */ -#line 807 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 807 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!np) @@ -2287,7 +2287,7 @@ yyparse (void) break; case 80: /* type_id: type TARS_IDENTIFIER */ -#line 825 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 825 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2300,7 +2300,7 @@ yyparse (void) break; case 81: /* type_id: type TARS_IDENTIFIER '[' TARS_CONST_INTEGER ']' */ -#line 834 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 834 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-4])); IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast(yyvsp[-1]); @@ -2314,7 +2314,7 @@ yyparse (void) break; case 82: /* type_id: type '*' TARS_IDENTIFIER */ -#line 844 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 844 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-2])); //IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast($4); @@ -2328,7 +2328,7 @@ yyparse (void) break; case 83: /* type_id: type TARS_IDENTIFIER ':' TARS_CONST_INTEGER */ -#line 854 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 854 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-3]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2341,7 +2341,7 @@ yyparse (void) break; case 84: /* type_id: type keyword */ -#line 863 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 863 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as data member name"); @@ -2350,7 +2350,7 @@ yyparse (void) break; case 85: /* type_id: type */ -#line 868 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 868 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("missing data member name"); } @@ -2358,7 +2358,7 @@ yyparse (void) break; case 86: /* type_id: error */ -#line 872 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 872 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("unkown type"); } @@ -2366,7 +2366,7 @@ yyparse (void) break; case 87: /* type: type_no ':' TARS_CONST_INTEGER */ -#line 881 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 881 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-2]); @@ -2379,7 +2379,7 @@ yyparse (void) break; case 88: /* type: type_no */ -#line 890 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 890 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -2387,7 +2387,7 @@ yyparse (void) break; case 89: /* type: type_no ':' error */ -#line 894 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 894 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("array missing size"); } @@ -2395,7 +2395,7 @@ yyparse (void) break; case 90: /* type_no: TARS_BOOL */ -#line 903 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 903 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindBool); } @@ -2403,7 +2403,7 @@ yyparse (void) break; case 91: /* type_no: TARS_BYTE */ -#line 907 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 907 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindByte); } @@ -2411,7 +2411,7 @@ yyparse (void) break; case 92: /* type_no: TARS_UNSIGNED TARS_BYTE */ -#line 911 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 911 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort,true); } @@ -2419,7 +2419,7 @@ yyparse (void) break; case 93: /* type_no: TARS_SHORT */ -#line 915 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 915 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort); } @@ -2427,7 +2427,7 @@ yyparse (void) break; case 94: /* type_no: TARS_UNSIGNED TARS_SHORT */ -#line 919 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 919 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt,true); } @@ -2435,7 +2435,7 @@ yyparse (void) break; case 95: /* type_no: TARS_INT */ -#line 923 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 923 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt); } @@ -2443,7 +2443,7 @@ yyparse (void) break; case 96: /* type_no: TARS_UNSIGNED TARS_INT */ -#line 927 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 927 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong,true); } @@ -2451,7 +2451,7 @@ yyparse (void) break; case 97: /* type_no: TARS_LONG */ -#line 931 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 931 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong); } @@ -2459,7 +2459,7 @@ yyparse (void) break; case 98: /* type_no: TARS_FLOAT */ -#line 935 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 935 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindFloat); } @@ -2467,7 +2467,7 @@ yyparse (void) break; case 99: /* type_no: TARS_DOUBLE */ -#line 939 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 939 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindDouble); } @@ -2475,7 +2475,7 @@ yyparse (void) break; case 100: /* type_no: TARS_STRING */ -#line 943 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 943 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindString); } @@ -2483,7 +2483,7 @@ yyparse (void) break; case 101: /* type_no: vector */ -#line 947 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 947 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2491,7 +2491,7 @@ yyparse (void) break; case 102: /* type_no: map */ -#line 951 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 951 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2499,7 +2499,7 @@ yyparse (void) break; case 103: /* type_no: scoped_name */ -#line 955 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 955 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypePtr sp = g_parse->findUserType(ident->v); @@ -2516,7 +2516,7 @@ yyparse (void) break; case 104: /* vector: TARS_VECTOR '<' type '>' */ -#line 973 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 973 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createVector(TypePtr::dynamicCast(yyvsp[-1]))); } @@ -2524,7 +2524,7 @@ yyparse (void) break; case 105: /* vector: TARS_VECTOR '<' error */ -#line 977 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 977 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("vector error"); } @@ -2532,7 +2532,7 @@ yyparse (void) break; case 106: /* vector: TARS_VECTOR '<' type error */ -#line 981 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 981 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing '>'"); } @@ -2540,7 +2540,7 @@ yyparse (void) break; case 107: /* vector: TARS_VECTOR error */ -#line 985 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 985 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing type"); } @@ -2548,7 +2548,7 @@ yyparse (void) break; case 108: /* map: TARS_MAP '<' type ',' type '>' */ -#line 994 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 994 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createMap(TypePtr::dynamicCast(yyvsp[-3]), TypePtr::dynamicCast(yyvsp[-1]))); } @@ -2556,7 +2556,7 @@ yyparse (void) break; case 109: /* map: TARS_MAP '<' error */ -#line 998 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 998 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { g_parse->error("map error"); } @@ -2564,14 +2564,14 @@ yyparse (void) break; case 110: /* scoped_name: TARS_IDENTIFIER */ -#line 1007 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1007 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2571 "tars.tab.cpp" break; case 111: /* scoped_name: TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1010 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1010 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ident->v = "::" + ident->v; @@ -2581,7 +2581,7 @@ yyparse (void) break; case 112: /* scoped_name: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1016 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1016 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2593,175 +2593,175 @@ yyparse (void) break; case 113: /* keyword: TARS_STRUCT */ -#line 1029 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1029 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2600 "tars.tab.cpp" break; case 114: /* keyword: TARS_VOID */ -#line 1032 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1032 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2607 "tars.tab.cpp" break; case 115: /* keyword: TARS_BOOL */ -#line 1035 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1035 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2614 "tars.tab.cpp" break; case 116: /* keyword: TARS_BYTE */ -#line 1038 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1038 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2621 "tars.tab.cpp" break; case 117: /* keyword: TARS_SHORT */ -#line 1041 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1041 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2628 "tars.tab.cpp" break; case 118: /* keyword: TARS_INT */ -#line 1044 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1044 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2635 "tars.tab.cpp" break; case 119: /* keyword: TARS_FLOAT */ -#line 1047 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1047 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2642 "tars.tab.cpp" break; case 120: /* keyword: TARS_DOUBLE */ -#line 1050 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1050 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2649 "tars.tab.cpp" break; case 121: /* keyword: TARS_STRING */ -#line 1053 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1053 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2656 "tars.tab.cpp" break; case 122: /* keyword: TARS_VECTOR */ -#line 1056 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1056 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2663 "tars.tab.cpp" break; case 123: /* keyword: TARS_KEY */ -#line 1059 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1059 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2670 "tars.tab.cpp" break; case 124: /* keyword: TARS_MAP */ -#line 1062 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1062 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2677 "tars.tab.cpp" break; case 125: /* keyword: TARS_NAMESPACE */ -#line 1065 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1065 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2684 "tars.tab.cpp" break; case 126: /* keyword: TARS_INTERFACE */ -#line 1068 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1068 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2691 "tars.tab.cpp" break; case 127: /* keyword: TARS_OUT */ -#line 1071 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1071 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2698 "tars.tab.cpp" break; case 128: /* keyword: TARS_REQUIRE */ -#line 1074 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1074 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2705 "tars.tab.cpp" break; case 129: /* keyword: TARS_OPTIONAL */ -#line 1077 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1077 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2712 "tars.tab.cpp" break; case 130: /* keyword: TARS_CONST_INTEGER */ -#line 1080 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1080 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2719 "tars.tab.cpp" break; case 131: /* keyword: TARS_CONST_FLOAT */ -#line 1083 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1083 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2726 "tars.tab.cpp" break; case 132: /* keyword: TARS_FALSE */ -#line 1086 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1086 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2733 "tars.tab.cpp" break; case 133: /* keyword: TARS_TRUE */ -#line 1089 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1089 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2740 "tars.tab.cpp" break; case 134: /* keyword: TARS_STRING_LITERAL */ -#line 1092 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1092 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2747 "tars.tab.cpp" break; case 135: /* keyword: TARS_CONST */ -#line 1095 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1095 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2754 "tars.tab.cpp" break; case 136: /* keyword: TARS_ENUM */ -#line 1098 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1098 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2761 "tars.tab.cpp" break; case 137: /* keyword: TARS_UNSIGNED */ -#line 1101 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1101 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" { } #line 2768 "tars.tab.cpp" @@ -2962,7 +2962,7 @@ yyparse (void) return yyresult; } -#line 1105 "/Volumes/MyData/centos/Tars/framework/tarscpp/tools/tarsgrammar/tars.y" +#line 1105 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" diff --git a/unit-test/util/test_tc_port.cpp b/unit-test/util/test_tc_port.cpp index cfe889ce..64e5bf08 100755 --- a/unit-test/util/test_tc_port.cpp +++ b/unit-test/util/test_tc_port.cpp @@ -33,3 +33,67 @@ TEST_F(UtilPortTest, testExec) string result = TC_Port::exec("ls '*.txt'", err); cout << result << endl; } + +TEST_F(UtilPortTest, testGetPidMemUsed) +{ + int64_t used = TC_Port::getPidMemUsed(TC_Port::getpid()); + cout << "used:" << used << endl; + + ASSERT_TRUE(used > 0); +} + +TEST_F(UtilPortTest, testGetPidStartTime) +{ +int64_t t = TC_Port::getPidStartTime(TC_Port::getpid()); +cout << "time_t:" << t << +endl; + +ASSERT_TRUE(t +>= TNOW); +} + +TEST_F(UtilPortTest, testGetUPTime) +{ +time_t t = TC_Port::getUPTime(); +cout << "time_t:" << t << +endl; +ASSERT_TRUE(t >= TNOW); +} + +TEST_F(UtilPortTest, testGetSystemMemInfo) +{ +int64_t totalSize = 0; +int64_t availableSize = 0; +float usedPercent = 0; + +int flag = TC_Port::getSystemMemInfo(totalSize, availableSize, usedPercent); + +ASSERT_TRUE(flag == 0); +ASSERT_TRUE(totalSize > 0); +ASSERT_TRUE(availableSize > 0); +ASSERT_TRUE(usedPercent > 0); + +} + +TEST_F(UtilPortTest, testGetCPUProcessor) +{ +ASSERT_TRUE(TC_Port::getCPUProcessor() > 0); +} + +TEST_F(UtilPortTest, testGetCPUProcessor) +{ +float usedPercent = 0; +int64_t availableSize = 0; + +#if TARGET_PLATFORM_IOS || TARGET_PLATFORM_LINUX +TC_Port::getDiskInfo(usedPercent, availableSize, "/"); +#else +TC_Port::getDiskInfo(usedPercent, availableSize, "c:\\"); +#endif + +ASSERT_TRUE(usedPercent > 0); +ASSERT_TRUE(availableSize > 0); +} + + + diff --git a/util/include/util/tc_port.h b/util/include/util/tc_port.h index 6065de8f..a166c930 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -178,28 +178,29 @@ class TC_Port static void unregisterTerm(size_t id); /** - * 获取指定进程占用物理内存大小, 返回内存大小,默认单位(字节, 还支持K, M, G) (目前linux下才有效) + * 获取指定进程占用物理内存大小, 返回内存大小(K, M, G) * @param pid: 目标进程id + * @param unit: 指定单位 * return -1 表示获取失败 * */ static int64_t getPidMemUsed(int64_t pid, const char unit = 'M'); /** - * 获取进程启动时间(目前linux下才有效) + * 获取进程启动时间 * @param pid * @return */ static time_t getPidStartTime(int64_t pid); /** - * 服务器启动时间(目前linux下才有效) + * 服务器启动时间 * @return */ static time_t getUPTime(); /** - * 获取系统内存信息(目前linux下才有效) + * 获取系统内存信息 * @param totalSize, 总内存大小 * @param availableSize , 剩余可用内存大小 * @param usedPercent , 已使用内存百分比 @@ -209,7 +210,7 @@ class TC_Port static bool getSystemMemInfo(int64_t &totalSize, int64_t &availableSize, float &usedPercent, const char unit = 'M'); /** - * 获取系统逻辑CPU核数(目前linux下才有效) + * 获取系统逻辑CPU核数 * @return -1 表示获取失败 */ static int getCPUProcessor(); @@ -221,7 +222,7 @@ class TC_Port * @param path, 为该路径所在目标磁盘 */ - static bool getDiskInfo(float& usedPercent, int64_t& availableSize, const string& path = "/"); + static bool getDiskInfo(float& usedPercent, int64_t& availableSize, const string& path); protected: diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index 75ea50a2..ac00d400 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -35,14 +35,18 @@ #else #pragma comment(lib, "ws2_32.lib") -// #include +#include #include #include +#include +#include #include "util/tc_strptime.h" #endif #if TARGET_PLATFORM_IOS #include +#include +#include #endif namespace tars @@ -657,7 +661,7 @@ static int64_t reSize(int64_t i, const char unit) } #endif -// 获取指定进程占用物理内存大小, 单位(字节) +// 获取指定进程占用物理内存大小 int64_t TC_Port::getPidMemUsed(int64_t pid, const char unit) { #if TARGET_PLATFORM_LINUX @@ -673,11 +677,66 @@ int64_t TC_Port::getPidMemUsed(int64_t pid, const char unit) } } return -1; -#else - return -1; +#elif TARGET_PLATFORM_IOS + struct proc_taskinfo procInfo; + int ret = proc_pidinfo(pid, PROC_PIDTASKINFO, 0, &procInfo, PROC_PIDTASKINFO_SIZE); + if (ret <= 0) { + return -1; + } + + int64_t memUsed = procInfo.pti_resident_size; + + // Apply unit conversion if necessary + switch (unit) { + case 'K': // KB + memUsed /= 1024; + break; + case 'G': // GB + memUsed /= (1024 * 1024 * 1024); + break; + case 'M': // MB + memUsed /= (1024 * 1024); + break; + default: + break; + } + + return memUsed; +#elif TARGET_PLATFORM_WINDOWS + HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid); + if (processHandle == NULL) { + return -1; + } + + PROCESS_MEMORY_COUNTERS pmc; + if (!GetProcessMemoryInfo(processHandle, &pmc, sizeof(pmc))) { + CloseHandle(processHandle); + return -1; + } + + CloseHandle(processHandle); + int64_t memUsed = pmc.WorkingSetSize; + + // Apply unit conversion if necessary + switch (unit) { + case 'K': // KB + memUsed /= 1024; + break; + case 'G': // GB + memUsed /= (1024 * 1024 * 1024); + break; + case 'M': // MB + memUsed /= (1024 * 1024); + break; + default: + break; + } + + return memUsed; #endif } +//服务器启动时间 time_t TC_Port::getUPTime() { #if TARGET_PLATFORM_LINUX @@ -692,8 +751,22 @@ time_t TC_Port::getUPTime() return TNOW - (time_t)(TC_Common::strto(vs[0])); -#else - return 0; +#elif TARGET_PLATFORM_IOS + struct timeval boottime; + size_t size = sizeof(boottime); + int mib[2] = { CTL_KERN, KERN_BOOTTIME }; + if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 && boottime.tv_sec != 0) { + time_t bsec = boottime.tv_sec, busec = boottime.tv_usec; + time_t now = time(NULL); + return now - bsec; + } else { + return 0; + } + +#elif TARGET_PLATFORM_WINDOWS + ULONGLONG tickCount = GetTickCount64(); + time_t upTime = tickCount / 1000; + return upTime; #endif } @@ -715,8 +788,45 @@ time_t TC_Port::getPidStartTime(int64_t pid) return 0; } return bootTime + duration; -#else - return -1; +#elif TARGET_PLATFORM_IOS + struct proc_taskallinfo allinfo; + int ret = proc_pidinfo(pid, PROC_PIDTASKALLINFO, 0, &allinfo, sizeof(allinfo)); + if (ret <= 0) { + return -1; + } + + // Convert the process start time from absolute time to seconds since the Epoch + time_t startTime = allinfo.pbsd.pbi_start_tvsec + allinfo.pbsd.pbi_start_tvusec / 1e6; + return startTime; +#elif TARGET_PLATFORM_WINDOWS + HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + if(h == INVALID_HANDLE_VALUE) { + return -1; + } + + PROCESSENTRY32 pe = { 0 }; + pe.dwSize = sizeof(PROCESSENTRY32); + if(!Process32First(h, &pe)) { + CloseHandle(h); + return -1; + } + + do { + if(pe.th32ProcessID == pid) { + FILETIME ftCreate, ftExit, ftKernel, ftUser; + if (GetProcessTimes(h, &ftCreate, &ftExit, &ftKernel, &ftUser)) { + ULARGE_INTEGER uli; + uli.LowPart = ftCreate.dwLowDateTime; + uli.HighPart = ftCreate.dwHighDateTime; + time_t startTime = (uli.QuadPart / 10000000ULL - 11644473600ULL); + CloseHandle(h); + return startTime; + } + } + } while(Process32Next(h, &pe)); + + CloseHandle(h); + return -1; #endif } @@ -777,42 +887,134 @@ bool TC_Port::getSystemMemInfo(int64_t &totalSize, int64_t &availableSize, float totalSize = reSize(total, unit); availableSize = reSize(available, unit); return true; -#else - return false; +#elif TARGET_PLATFORM_IOS + int mib[2]; + int64_t physical_memory; + size_t length; + mib[0] = CTL_HW; + mib[1] = HW_MEMSIZE; + length = sizeof(int64_t); + sysctl(mib, 2, &physical_memory, &length, NULL, 0); + + vm_statistics64_data_t vmstat; + mach_msg_type_number_t count = sizeof(vmstat) / sizeof(natural_t); + if(KERN_SUCCESS != host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t)&vmstat, &count)){ + return false; + } + + totalSize = physical_memory; + availableSize = vmstat.free_count * vm_page_size; + + if (totalSize == 0) { + return false; + } + + usedPercent = ((totalSize - availableSize) * 100.0) / totalSize; + + // Apply unit conversion if necessary + switch (unit) { + case 'K': // KB + totalSize /= 1024; + availableSize /= 1024; + break; + case 'G': // GB + totalSize /= (1024 * 1024 * 1024); + availableSize /= (1024 * 1024 * 1024); + break; + case 'M': // MB + totalSize /= (1024 * 1024); + availableSize /= (1024 * 1024); + break; + default: + break; + } + + return true; +#elif TARGET_PLATFORM_WINDOWS + MEMORYSTATUSEX memInfo; + memInfo.dwLength = sizeof(MEMORYSTATUSEX); + if (!GlobalMemoryStatusEx(&memInfo)) { + return false; + } + + totalSize = memInfo.ullTotalPhys / (1024 * 1024); // Convert to MB + availableSize = memInfo.ullAvailPhys / (1024 * 1024); // Convert to MB + + if (totalSize == 0) { + return false; + } + + usedPercent = ((totalSize - availableSize) * 100.0) / totalSize; + + // Apply unit conversion if necessary + switch (unit) { + case 'K': // KB + totalSize *= 1024; + availableSize *= 1024; + break; + case 'G': // GB + totalSize /= 1024; + availableSize /= 1024; + break; + // case 'M': // MB - no conversion necessary + default: + break; + } + + return true; #endif } // 获取系统CPU核数 int TC_Port::getCPUProcessor() { -#if TARGET_PLATFORM_LINUX - return get_nprocs(); -#else - return -1; +#if TARGET_PLATFORM_WINDOWS + SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + return sysinfo.dwNumberOfProcessors; #endif + return get_nprocs(); } bool TC_Port::getDiskInfo(float& usedPercent, int64_t& availableSize, const string& path) { -#if TARGET_PLATFORM_LINUX - struct statfs64 buf; +#if TARGET_PLATFORM_WINDOWS + ULARGE_INTEGER freeBytesAvailableToCaller; + ULARGE_INTEGER totalNumberOfBytes; + ULARGE_INTEGER totalNumberOfFreeBytes; - if(statfs64(path.c_str(),&buf)==-1) - { - return false; - } + if (!GetDiskFreeSpaceEx(path.c_str(), &freeBytesAvailableToCaller, &totalNumberOfBytes, &totalNumberOfFreeBytes)) { + return false; + } - size_t totalSize = (buf.f_blocks / 1024) * (buf.f_bsize / 1024); - if (totalSize == 0) - { - return false; - } + ULONGLONG totalSize = totalNumberOfBytes.QuadPart / (1024 * 1024); // Convert to MB + ULONGLONG freeSize = totalNumberOfFreeBytes.QuadPart / (1024 * 1024); // Convert to MB - availableSize = (buf.f_bavail / 1024) * (buf.f_bsize / 1024); - usedPercent = (totalSize - availableSize) * 1.0 / totalSize * 100; - return true; + if (totalSize == 0) { + return false; + } + + availableSize = freeSize; + usedPercent = (totalSize - freeSize) * 100.0 / totalSize; + + return true; #else - return false; + struct statfs64 buf; + + if(statfs64(path.c_str(),&buf)==-1) + { + return false; + } + + size_t totalSize = (buf.f_blocks / 1024) * (buf.f_bsize / 1024); + if (totalSize == 0) + { + return false; + } + + availableSize = (buf.f_bavail / 1024) * (buf.f_bsize / 1024); + usedPercent = (totalSize - availableSize) * 1.0 / totalSize * 100; + return true; #endif } From c439c0df4837936d802c093d879abac20ed7b911 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 24 Jan 2024 11:09:10 +0800 Subject: [PATCH 41/81] fix tc_port in mac --- unit-test/util/test_tc_port.cpp | 62 ++++++++++++++++++--------------- util/include/util/tc_port.h | 2 +- util/src/tc_port.cpp | 22 ++++++++++-- 3 files changed, 55 insertions(+), 31 deletions(-) diff --git a/unit-test/util/test_tc_port.cpp b/unit-test/util/test_tc_port.cpp index 64e5bf08..ff7ce16b 100755 --- a/unit-test/util/test_tc_port.cpp +++ b/unit-test/util/test_tc_port.cpp @@ -44,55 +44,61 @@ TEST_F(UtilPortTest, testGetPidMemUsed) TEST_F(UtilPortTest, testGetPidStartTime) { -int64_t t = TC_Port::getPidStartTime(TC_Port::getpid()); -cout << "time_t:" << t << -endl; + int64_t t = TC_Port::getPidStartTime(TC_Port::getpid()); + cout << "testGetPidStartTime:" << t << endl; -ASSERT_TRUE(t ->= TNOW); + ASSERT_TRUE(t >= time(NULL)); } TEST_F(UtilPortTest, testGetUPTime) { -time_t t = TC_Port::getUPTime(); -cout << "time_t:" << t << -endl; -ASSERT_TRUE(t >= TNOW); + time_t t = TC_Port::getUPTime(); + cout << "testGetUPTime:" << t/60/60/24 << "day" << endl; + ASSERT_TRUE(t > 0); } TEST_F(UtilPortTest, testGetSystemMemInfo) { -int64_t totalSize = 0; -int64_t availableSize = 0; -float usedPercent = 0; - -int flag = TC_Port::getSystemMemInfo(totalSize, availableSize, usedPercent); - -ASSERT_TRUE(flag == 0); -ASSERT_TRUE(totalSize > 0); -ASSERT_TRUE(availableSize > 0); -ASSERT_TRUE(usedPercent > 0); - + int64_t totalSize = 0; + int64_t availableSize = 0; + float usedPercent = 0; + + bool flag = TC_Port::getSystemMemInfo(totalSize, availableSize, usedPercent); + + cout << "totalSize: " << totalSize << endl; + cout << "availableSize: " << availableSize << endl; + cout << "usedPercent: " << usedPercent << endl; + ASSERT_TRUE(flag); + ASSERT_TRUE(totalSize > 0); + ASSERT_TRUE(availableSize > 0); + ASSERT_TRUE(usedPercent > 0); } TEST_F(UtilPortTest, testGetCPUProcessor) { -ASSERT_TRUE(TC_Port::getCPUProcessor() > 0); + int n = TC_Port::getCPUProcessor(); + + cout << "cpu: " << n << endl; + + ASSERT_TRUE(n > 0); } -TEST_F(UtilPortTest, testGetCPUProcessor) +TEST_F(UtilPortTest, testGetDiskInfo) { -float usedPercent = 0; -int64_t availableSize = 0; + float usedPercent = 0; + int64_t availableSize = 0; #if TARGET_PLATFORM_IOS || TARGET_PLATFORM_LINUX -TC_Port::getDiskInfo(usedPercent, availableSize, "/"); + TC_Port::getDiskInfo(usedPercent, availableSize, "/"); #else -TC_Port::getDiskInfo(usedPercent, availableSize, "c:\\"); + TC_Port::getDiskInfo(usedPercent, availableSize, "c:\\"); #endif -ASSERT_TRUE(usedPercent > 0); -ASSERT_TRUE(availableSize > 0); + cout << "usedPercent: " << usedPercent << endl; + cout << "availableSize: " << availableSize << endl; + + ASSERT_TRUE(usedPercent > 0); + ASSERT_TRUE(availableSize > 0); } diff --git a/util/include/util/tc_port.h b/util/include/util/tc_port.h index a166c930..9bb33b7c 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -194,7 +194,7 @@ class TC_Port static time_t getPidStartTime(int64_t pid); /** - * 服务器启动时间 + * 服务器启动时间到现在的时间 * @return */ static time_t getUPTime(); diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index ac00d400..e227643b 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -44,7 +44,9 @@ #endif #if TARGET_PLATFORM_IOS +#include #include +#include #include #include #endif @@ -756,7 +758,7 @@ time_t TC_Port::getUPTime() size_t size = sizeof(boottime); int mib[2] = { CTL_KERN, KERN_BOOTTIME }; if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 && boottime.tv_sec != 0) { - time_t bsec = boottime.tv_sec, busec = boottime.tv_usec; + time_t bsec = boottime.tv_sec;//, busec = boottime.tv_usec; time_t now = time(NULL); return now - bsec; } else { @@ -972,8 +974,24 @@ int TC_Port::getCPUProcessor() SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); return sysinfo.dwNumberOfProcessors; +#elif TARGET_PLATFORM_IOS + int nm[2]; + size_t len = 4; + uint32_t count; + + nm[0] = CTL_HW; + nm[1] = HW_AVAILCPU; + sysctl(nm, 2, &count, &len, NULL, 0); + + if (count < 1) { + nm[1] = HW_NCPU; + sysctl(nm, 2, &count, &len, NULL, 0); + if (count < 1) { count = 1; } + } + return count; +#else + return get_nprocs(); #endif - return get_nprocs(); } bool TC_Port::getDiskInfo(float& usedPercent, int64_t& availableSize, const string& path) From 6d28e7647ce0dc87f98f91d22d0c42c8eac1341d Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 24 Jan 2024 11:37:12 +0800 Subject: [PATCH 42/81] fix tc_Port getUPTime bug in mac --- unit-test/util/test_tc_port.cpp | 2 +- util/include/util/tc_port.h | 4 ++-- util/src/tc_port.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/unit-test/util/test_tc_port.cpp b/unit-test/util/test_tc_port.cpp index ff7ce16b..f27be149 100755 --- a/unit-test/util/test_tc_port.cpp +++ b/unit-test/util/test_tc_port.cpp @@ -53,7 +53,7 @@ TEST_F(UtilPortTest, testGetPidStartTime) TEST_F(UtilPortTest, testGetUPTime) { time_t t = TC_Port::getUPTime(); - cout << "testGetUPTime:" << t/60/60/24 << "day" << endl; + cout << "testGetUPTime:" << (time(NULL)-t)/60/60/24 << "day" << endl; ASSERT_TRUE(t > 0); } diff --git a/util/include/util/tc_port.h b/util/include/util/tc_port.h index 9bb33b7c..23faf746 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -187,14 +187,14 @@ class TC_Port static int64_t getPidMemUsed(int64_t pid, const char unit = 'M'); /** - * 获取进程启动时间 + * 获取进程启动时间(秒) * @param pid * @return */ static time_t getPidStartTime(int64_t pid); /** - * 服务器启动时间到现在的时间 + * 服务器启动的绝对时间(秒) * @return */ static time_t getUPTime(); diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index e227643b..b7ff45c0 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -759,8 +759,8 @@ time_t TC_Port::getUPTime() int mib[2] = { CTL_KERN, KERN_BOOTTIME }; if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 && boottime.tv_sec != 0) { time_t bsec = boottime.tv_sec;//, busec = boottime.tv_usec; - time_t now = time(NULL); - return now - bsec; +// time_t now = time(NULL); + return bsec; } else { return 0; } From a8e371db589e446824242fd60d30230f36f4f93f Mon Sep 17 00:00:00 2001 From: wuxiaofeng1 Date: Wed, 24 Jan 2024 18:20:56 +0800 Subject: [PATCH 43/81] =?UTF-8?q?rpc=E5=A4=84=E7=90=86=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=A2=9E=E5=8A=A0=E5=88=86=E5=B8=83=E7=89=B9?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- servant/libservant/Application.cpp | 6 ++++-- servant/libservant/PropertyReport.cpp | 10 ++++++++++ servant/servant/PropertyReport.h | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/servant/libservant/Application.cpp b/servant/libservant/Application.cpp index 7962eb3f..d1066611 100644 --- a/servant/libservant/Application.cpp +++ b/servant/libservant/Application.cpp @@ -1541,11 +1541,13 @@ vector Application::createAdapter() bindAdapter->_pReportTimeoutNum = p.get(); p = _applicationCommunicator->getStatReport()->createPropertyReport(bindAdapter->getName() + ".queueWaitTime", - PropertyReport::avg(), PropertyReport::min(), PropertyReport::max(), PropertyReport::count()); + PropertyReport::avg(), PropertyReport::min(), PropertyReport::max(), PropertyReport::count(), + PropertyReport::distr({5, 10, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000})); bindAdapter->_pReportQueueWaitTime = p.get(); p = _applicationCommunicator->getStatReport()->createPropertyReport(bindAdapter->getName() + ".servantHandleTime", - PropertyReport::avg(), PropertyReport::min(), PropertyReport::max(), PropertyReport::count()); + PropertyReport::avg(), PropertyReport::min(), PropertyReport::max(), PropertyReport::count(), + PropertyReport::distr({5, 10, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000})); bindAdapter->_pReportServantHandleTime = p.get(); } diff --git a/servant/libservant/PropertyReport.cpp b/servant/libservant/PropertyReport.cpp index b5b77f90..326e8a24 100644 --- a/servant/libservant/PropertyReport.cpp +++ b/servant/libservant/PropertyReport.cpp @@ -63,6 +63,10 @@ void PropertyReport::distr::set(int o) ++_result[n]; } + else + { + ++_max; + } } string PropertyReport::distr::get() @@ -81,6 +85,12 @@ string PropertyReport::distr::get() { _result[i] = 0; } + if (!s.empty()) + { + s += ","; + } + s += "max|" + TC_Common::tostr(_max); + _max = 0; return s; } diff --git a/servant/servant/PropertyReport.h b/servant/servant/PropertyReport.h index e10b2942..bc509e46 100755 --- a/servant/servant/PropertyReport.h +++ b/servant/servant/PropertyReport.h @@ -98,10 +98,11 @@ class PropertyReport : public TC_HandleBase void set(int o); string get(); protected: - void clear() { _result.clear();} + void clear() { _result.clear(); _max = 0;} private: vector _range; vector _result; + int _max = 0; }; /** From 2421a301a45d1f383622862cea91f1bf7836a5f8 Mon Sep 17 00:00:00 2001 From: wuxiaofeng1 Date: Thu, 25 Jan 2024 10:56:09 +0800 Subject: [PATCH 44/81] =?UTF-8?q?=E5=B9=B3=E5=9D=87=E5=80=BC=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E5=8F=AF=E8=83=BD=E6=BA=A2=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- servant/servant/PropertyReport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servant/servant/PropertyReport.h b/servant/servant/PropertyReport.h index bc509e46..12250be5 100755 --- a/servant/servant/PropertyReport.h +++ b/servant/servant/PropertyReport.h @@ -82,7 +82,7 @@ class PropertyReport : public TC_HandleBase protected: void clear() { _sum = 0; _count = 0; } private: - int _sum; + long _sum; int _count; }; From 098093521a601a149824c210c6ca152733991321 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 1 Feb 2024 17:53:21 +0800 Subject: [PATCH 45/81] feat: tc_port add getCpuLoad --- unit-test/hello_test.h | 15 +++------ unit-test/util/test_tc_port.cpp | 20 +++++++++++ util/include/util/tc_port.h | 8 +++++ util/src/tc_port.cpp | 59 +++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 10 deletions(-) diff --git a/unit-test/hello_test.h b/unit-test/hello_test.h index 8bc92905..57d10c5b 100755 --- a/unit-test/hello_test.h +++ b/unit-test/hello_test.h @@ -268,8 +268,11 @@ class HelloTest : public testing::Test return prx; } - int GetUsedFileDescriptorCount() - { + int getFdCounts() + { +#if TARGET_PLATFORM_WINDOWS + return 0; +#else // 使用 shell 命令 "lsof" 获取已使用的文件句柄数量 FILE* file = popen("lsof -p $$ | wc -l", "r"); if (!file) { @@ -287,14 +290,6 @@ class HelloTest : public testing::Test // 解析结果并提取文件句柄数量 int usedFileDescriptors = std::stoi(result); return usedFileDescriptors; - } - - int getFdCounts() - { -#if TARGET_PLATFORM_WINDOWS - return 0; -#else - return GetUsedFileDescriptorCount(); #endif } diff --git a/unit-test/util/test_tc_port.cpp b/unit-test/util/test_tc_port.cpp index f27be149..7bcecd82 100755 --- a/unit-test/util/test_tc_port.cpp +++ b/unit-test/util/test_tc_port.cpp @@ -101,5 +101,25 @@ TEST_F(UtilPortTest, testGetDiskInfo) ASSERT_TRUE(availableSize > 0); } +TEST_F(UtilPortTest, testGetCpuLoad) +{ + cout << "cpu load:" << TC_Port::getCpuLoad(500) << endl; +} + +#if TARGET_PLATFORM_WINDOWS +#include +TEST_F(UtilPortTest, testGetDisk) +{ + DWORD aDrive = GetLogicalDrives(); + + for (int i = 0; i < 26; i++) { + if (aDrive & (1 << i)) { + char drive[4]; + sprintf(drive, "%c:\\", 'A' + i); + std::cout << drive << std::endl; + } + } +} +#endif diff --git a/util/include/util/tc_port.h b/util/include/util/tc_port.h index 23faf746..c343992a 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -177,6 +177,14 @@ class TC_Port */ static void unregisterTerm(size_t id); + /** + * 获取cpu负载 + * @param queryTime, windows下有效, 会阻塞的时间, 毫秒 + * + * @return, 如果失败, 返回-1, 否在返回cpu负载的值 + */ + static double getCpuLoad(uint32_t queryTime = 500); + /** * 获取指定进程占用物理内存大小, 返回内存大小(K, M, G) * @param pid: 目标进程id diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index b7ff45c0..47160c00 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -35,11 +35,15 @@ #else #pragma comment(lib, "ws2_32.lib") +#pragma comment(lib, "pdh.lib") + #include #include #include #include #include +#include +#include #include "util/tc_strptime.h" #endif @@ -663,6 +667,61 @@ static int64_t reSize(int64_t i, const char unit) } #endif +double TC_Port::getCpuLoad(uint32_t queryTime) +{ +#if TARGET_PLATFORM_LINUX || TARGET_PLATFORM_IOS + double loadAvg[3]; + if ( getloadavg( loadAvg, 3 ) != -1 ) + { + return static_cast( loadAvg[0] ); + } + return -1; +#else + PDH_HQUERY cpuQuery; + PDH_HCOUNTER cpuTotal; + + // Initialize the PDH query + if (PdhOpenQuery(NULL, NULL, &cpuQuery) != ERROR_SUCCESS) { + return -1; + } + + // Add the CPU Time counter to the query + if (PdhAddCounter(cpuQuery, "\\Processor(_Total)\\% Processor Time", NULL, &cpuTotal) != ERROR_SUCCESS) { + return -1; + } + + // Collect the query data + if (PdhCollectQueryData(cpuQuery) != ERROR_SUCCESS) { + return -1; + } + + // Wait for some time + TC_Common::msleep(queryTime); + + // Collect the updated query data + if (PdhCollectQueryData(cpuQuery) != ERROR_SUCCESS) { + return -1; + } + + // Get the collected data + PDH_FMT_COUNTERVALUE counterVal; + + if (PdhGetFormattedCounterValue(cpuTotal, PDH_FMT_DOUBLE, NULL, &counterVal) != ERROR_SUCCESS) { + return -1; + } + + // Print the CPU usage +// std::cout << "CPU Usage: " << counterVal.doubleValue << " %\n"; + + // Close the query + if (PdhCloseQuery(cpuQuery) != ERROR_SUCCESS) { + return -1; + } + + return counterVal.doubleValue; +#endif +} + // 获取指定进程占用物理内存大小 int64_t TC_Port::getPidMemUsed(int64_t pid, const char unit) { From 166143e3e797489769aecf8d850dfbb874830330 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 1 Feb 2024 18:30:55 +0800 Subject: [PATCH 46/81] fix tc_port getDiskInfo --- unit-test/util/test_tc_port.cpp | 7 +++++-- util/include/util/tc_port.h | 6 +++--- util/src/tc_port.cpp | 10 +++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/unit-test/util/test_tc_port.cpp b/unit-test/util/test_tc_port.cpp index 7bcecd82..f47bfddd 100755 --- a/unit-test/util/test_tc_port.cpp +++ b/unit-test/util/test_tc_port.cpp @@ -87,16 +87,19 @@ TEST_F(UtilPortTest, testGetDiskInfo) { float usedPercent = 0; int64_t availableSize = 0; + int64_t totalSize = 0; #if TARGET_PLATFORM_IOS || TARGET_PLATFORM_LINUX - TC_Port::getDiskInfo(usedPercent, availableSize, "/"); + TC_Port::getDiskInfo(totalSize, availableSize, usedPercent, "/"); #else - TC_Port::getDiskInfo(usedPercent, availableSize, "c:\\"); + TC_Port::getDiskInfo(totalSize, availableSize, usedPercent, "c:\\"); #endif + cout << "totalSize: " << totalSize << endl; cout << "usedPercent: " << usedPercent << endl; cout << "availableSize: " << availableSize << endl; + ASSERT_TRUE(totalSize > 0); ASSERT_TRUE(usedPercent > 0); ASSERT_TRUE(availableSize > 0); } diff --git a/util/include/util/tc_port.h b/util/include/util/tc_port.h index c343992a..632c0c4f 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -212,7 +212,7 @@ class TC_Port * @param totalSize, 总内存大小 * @param availableSize , 剩余可用内存大小 * @param usedPercent , 已使用内存百分比 - * @param unit, 内存单位 + * @param unit, 内存单位(B, K, G, M) * @return */ static bool getSystemMemInfo(int64_t &totalSize, int64_t &availableSize, float &usedPercent, const char unit = 'M'); @@ -226,11 +226,11 @@ class TC_Port /** * 获取磁盘信息 * @param usedPercent 磁盘使用百分比 - * @param availableSize 剩余磁盘空间(单位M) + * @param availableSize 剩余磁盘空间(字节数) * @param path, 为该路径所在目标磁盘 */ - static bool getDiskInfo(float& usedPercent, int64_t& availableSize, const string& path); + static bool getDiskInfo(int64_t &totalSize, int64_t& availableSize, float& usedPercent, const string& path); protected: diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index 47160c00..64c482af 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -1053,7 +1053,7 @@ int TC_Port::getCPUProcessor() #endif } -bool TC_Port::getDiskInfo(float& usedPercent, int64_t& availableSize, const string& path) +bool TC_Port::getDiskInfo(int64_t &totalSize, int64_t& availableSize, float& usedPercent, const string& path) { #if TARGET_PLATFORM_WINDOWS ULARGE_INTEGER freeBytesAvailableToCaller; @@ -1064,8 +1064,8 @@ bool TC_Port::getDiskInfo(float& usedPercent, int64_t& availableSize, const stri return false; } - ULONGLONG totalSize = totalNumberOfBytes.QuadPart / (1024 * 1024); // Convert to MB - ULONGLONG freeSize = totalNumberOfFreeBytes.QuadPart / (1024 * 1024); // Convert to MB + totalSize = totalNumberOfBytes.QuadPart; + ULONGLONG freeSize = totalNumberOfFreeBytes.QuadPart; if (totalSize == 0) { return false; @@ -1083,13 +1083,13 @@ bool TC_Port::getDiskInfo(float& usedPercent, int64_t& availableSize, const stri return false; } - size_t totalSize = (buf.f_blocks / 1024) * (buf.f_bsize / 1024); + totalSize = buf.f_blocks * buf.f_bsize; if (totalSize == 0) { return false; } - availableSize = (buf.f_bavail / 1024) * (buf.f_bsize / 1024); + availableSize = buf.f_bavail * buf.f_bsize; usedPercent = (totalSize - availableSize) * 1.0 / totalSize * 100; return true; #endif From f6ed0da6cd0e65eb0400a3088605db79966eecd8 Mon Sep 17 00:00:00 2001 From: BeyondWUXF <46481385+BeyondWUXF@users.noreply.github.com> Date: Thu, 1 Feb 2024 19:47:55 +0800 Subject: [PATCH 47/81] Update PropertyReport.h --- servant/servant/PropertyReport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servant/servant/PropertyReport.h b/servant/servant/PropertyReport.h index 12250be5..2d7b5a7e 100755 --- a/servant/servant/PropertyReport.h +++ b/servant/servant/PropertyReport.h @@ -82,7 +82,7 @@ class PropertyReport : public TC_HandleBase protected: void clear() { _sum = 0; _count = 0; } private: - long _sum; + int64_t _sum; int _count; }; From 6b250408fae68c0df23207ac29ee7c72a33a9605 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 1 Feb 2024 21:16:17 +0800 Subject: [PATCH 48/81] fix windows compiler --- util/include/util/tc_common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/include/util/tc_common.h b/util/include/util/tc_common.h index 2de16469..b3f0d13b 100644 --- a/util/include/util/tc_common.h +++ b/util/include/util/tc_common.h @@ -1438,8 +1438,8 @@ bool TC_Common::equal(const unordered_map& mx , const unordered_map< } #if TARGET_PLATFORM_WINDOWS -#define __filename__(x) (strrchr(x, '\\') ? strrchr(x, '\\') + 1 : x) -#define FILE_FUNC_LINE "[" << __filename__(__FILE__) << "::" << __FUNCTION__ << "::" << __LINE__ << "]" +#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) +#define FILE_FUNC_LINE "[" << __FILENAME__ << "::" << __FUNCTION__ << "::" << __LINE__ << "]" #else #define __FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) #define FILE_FUNC_LINE "[" << __FILENAME__ << "::" << __FUNCTION__ << "::" << __LINE__ << "]" From 90dc83a955c828bb108e57fe8f07f0d78e7d5ce1 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Fri, 2 Feb 2024 11:48:39 +0800 Subject: [PATCH 49/81] v3.0.19 --- Changelist-3.x.md | 38 ++++++++++++++++++++++++++++++++++++++ cmake/Common.cmake | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Changelist-3.x.md b/Changelist-3.x.md index 4343f4b4..2c9184ca 100644 --- a/Changelist-3.x.md +++ b/Changelist-3.x.md @@ -1,3 +1,41 @@ +# v3.0.19 20240202 + +## en +- fix: tars-tools.cmake in windows +- fix: tc_port fix forkExec bug +- fix: remote logger remove ServerConfig::Context +- fix: current not report one_way stat(useless) +- fix: StatReport interface, remove parameters not used +- fix: tc_option support parameter with ", like this: --test="abc" +- fix: When the server actively closes the connection, RPC may cause memory leak issues +- fix: push callback may crash +- fix: KeepAliveNodeFHelper no singleton +- fix: gzip compress coredump +- fix: PingCallback set servantPrx +- fix: remote config, when tarsconfig timeout not use local config file bug +- fix: tars-tools.cmake.in add: list(APPEND TARS_TOOL_FLAG "") +- fix: trace, no not depend ServerConfig +- fix: tars-tools.cmake set TARS_SSL/TARS_MYSQL/TARS_HTTP2 depends tarscpp compiler +- feat: modify xxx_fcontext name to avoid conflict with other co lib +- feat: rpc add time distr report +- feat: tc_port add getDiskInfo/getCpuLoad/getUPTime/getPidStartTime/getPidMemUsed/getCwd/kill and support mac/windows/linux +- feat: tc_port add closeAllFileDescriptors in linux/mac +- feat: tc_file add joinPaths/toAbsolute +- feat: Application first bind adminObj, then initialize, then bind other objs +- feat: EndpointInfo add toEndpointF +- feat: AdminF.tars add getPid +- feat: ServantHandle in servant use shared ptr +- feat: ClientConfig change to Communicator subclass, no global static object +- feat: ClientConfig add context, when call other core tars server with this context, node_name in context +- feat: add ApplicationCommunicator to support multi Appliations in one process +- feat: support master-slave mode in frameworkPro +- feat: Application add ServerBaseInfo in Application +- optimize: bind after initialize when Applicaion start +- optimize: RemoteConfig remove singleton +- optimize: loading local ip list cache +- optimize: AppCache only initialize once +- optimize: global rolllog only init once + # v3.0.18 20231106 ### en - fix: udp ipv6 bug diff --git a/cmake/Common.cmake b/cmake/Common.cmake index e8e3817d..4a432e55 100755 --- a/cmake/Common.cmake +++ b/cmake/Common.cmake @@ -1,6 +1,6 @@ -set(TARS_VERSION "3.0.18") +set(TARS_VERSION "3.0.19") add_definitions(-DTARS_VERSION="${TARS_VERSION}") set(CMAKE_VERBOSE_MAKEFILE off) From 6e52062bfe4d4296b50d9768be928e6f9fbd1f09 Mon Sep 17 00:00:00 2001 From: wuxiaofeng1 Date: Mon, 24 Apr 2023 16:08:26 +0800 Subject: [PATCH 50/81] ObjectProxy invoke exception callback --- servant/libservant/ObjectProxy.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/servant/libservant/ObjectProxy.cpp b/servant/libservant/ObjectProxy.cpp index c0f56df2..b55b45b7 100755 --- a/servant/libservant/ObjectProxy.cpp +++ b/servant/libservant/ObjectProxy.cpp @@ -282,18 +282,8 @@ void ObjectProxy::doInvokeException(ReqMessage * msg) } else { - //先确保adapter 非null - if (msg->adapter) - { - //异步回调,放入回调处理线程中 - _communicatorEpoll->pushAsyncThreadQueue(msg); - } - else - { - TLOGERROR("[ObjectProxy::doInvokeException push adapter is null|" << __LINE__ << endl); - delete msg; - msg = NULL; - } + _communicatorEpoll->pushAsyncThreadQueue(msg); + TLOGERROR("[ObjectProxy::doInvokeException push adapter is null|" << __LINE__ << endl); } } else From 8add82f4f624b5da80d96d787bd0a37dc0536bec Mon Sep 17 00:00:00 2001 From: BeyondWUXF <46481385+BeyondWUXF@users.noreply.github.com> Date: Sun, 4 Feb 2024 17:54:12 +0800 Subject: [PATCH 51/81] =?UTF-8?q?Application=E5=A2=9E=E5=8A=A0getRemoteCon?= =?UTF-8?q?fig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- servant/servant/Application.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/servant/servant/Application.h b/servant/servant/Application.h index cc4fd22b..2e0297a7 100644 --- a/servant/servant/Application.h +++ b/servant/servant/Application.h @@ -264,6 +264,12 @@ class Application: public BaseNotify */ CommunicatorPtr& getApplicationCommunicator(); + /** + * application自己的获取远程系统配置 + * @return + */ + shared_ptr getRemoteConfig() { return _remoteConfig; } + /** * 获取服务Server对象 * From e445690526f2cbd05a4fd22126f4d4a6f3dafe87 Mon Sep 17 00:00:00 2001 From: shenyuhit Date: Tue, 20 Feb 2024 09:33:02 +0800 Subject: [PATCH 52/81] ft:(support build_with_std_shared_ptr for python) --- .gitignore | 3 +- cmake/Common.cmake | 8 ++++ servant/libservant/AdapterProxy.cpp | 3 +- servant/libservant/Communicator.cpp | 6 +++ servant/libservant/Current.cpp | 45 ++++++++++++++++++++++ servant/libservant/EndpointManager.cpp | 10 ++--- servant/libservant/Servant.cpp | 26 +++++++++++-- servant/libservant/ServantHandle.cpp | 4 +- servant/libservant/ServantHelper.cpp | 24 ++++++++++++ servant/libservant/ServantProxy.cpp | 37 +++++++++++++++++- servant/libservant/ServantProxyFactory.cpp | 27 +++++++++++++ servant/servant/Communicator.h | 4 +- servant/servant/Current.h | 1 + servant/servant/EndpointManager.h | 2 +- servant/servant/Global.h | 17 +++++++- servant/servant/Servant.h | 13 +++++++ servant/servant/ServantHelper.h | 14 ++++++- servant/servant/ServantProxy.h | 8 ++++ servant/servant/ServantProxyFactory.h | 2 + tools/tars2cpp/tars2cpp.cpp | 29 ++++++++++++-- tools/tarsparse/CMakeLists.txt | 3 ++ 21 files changed, 266 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index b456bebb..0bad24b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ servant/makefile/tars-tools.cmake -.idea \ No newline at end of file +.idea +/cmake-build-debug-177 diff --git a/cmake/Common.cmake b/cmake/Common.cmake index 4a432e55..073708c2 100755 --- a/cmake/Common.cmake +++ b/cmake/Common.cmake @@ -11,6 +11,13 @@ IF (CMAKE_BUILD_TYPE STREQUAL "") ENDIF() +# 设置一个选项,用于控制是否定义 BUILD_STD_SHARED_PTR 宏 +option(USE_STD_SHARED_PTR "Use std::shared_ptr instead of tars::AutoPtr" OFF) +if(USE_STD_SHARED_PTR) + add_definitions(-DBUILD_STD_SHARED_PTR) +endif() + + #编译的可执行程序输出目录 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) @@ -119,5 +126,6 @@ message("BIN: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") message("TARS2CPP: ${TARS2CPP}") #message("TARS_OPENTRACKING: ${TARS_OPENTRACKING}") message("ONLY_LIB: ${ONLY_LIB}" ) +message("USE_STD_SHARED_PTR: ${USE_STD_SHARED_PTR}" ) #------------------------------------------------------------- diff --git a/servant/libservant/AdapterProxy.cpp b/servant/libservant/AdapterProxy.cpp index 9a331b98..c61c6d65 100755 --- a/servant/libservant/AdapterProxy.cpp +++ b/servant/libservant/AdapterProxy.cpp @@ -1054,7 +1054,8 @@ void AdapterProxy::doKeepAlive() TLOGTARS("[AdapterProxy::doKeepAlive, " << _objectProxy->name() << ", " << _trans->getConnectionString() << "]" << endl); ReqMessage *msg = new ReqMessage(); - ServantProxyCallbackPtr callback = new PingCallback(); +// ServantProxyCallbackPtr callback = new PingCallback(); + ServantProxyCallbackPtr callback (new PingCallback()); callback->setServantPrx(_objectProxy->getServantProxy()); msg->init(ReqMessage::ASYNC_CALL, _objectProxy->getServantProxy()); diff --git a/servant/libservant/Communicator.cpp b/servant/libservant/Communicator.cpp index 50cc45d0..0160ad32 100644 --- a/servant/libservant/Communicator.cpp +++ b/servant/libservant/Communicator.cpp @@ -751,6 +751,12 @@ ServantProxy* Communicator::getServantProxy(const string& objectName, const stri return _servantProxyFactory->getServantProxy(objectName, setName, rootServant); } +ServantProxy * Communicator::setServantProxy(ServantProxy * proxy,const string& objectName,const string& setName, bool rootServant) +{ + Communicator::initialize(); + proxy->setComm(this , objectName,setName); + return _servantProxyFactory->setServantProxy(proxy,objectName, setName, rootServant); +} StatReport* Communicator::getStatReport() { Communicator::initialize(); diff --git a/servant/libservant/Current.cpp b/servant/libservant/Current.cpp index ca1eeb88..ca785087 100644 --- a/servant/libservant/Current.cpp +++ b/servant/libservant/Current.cpp @@ -376,6 +376,51 @@ void Current::sendResponse(int iRet, ResponsePacket &response, const map &buff ) +{ + ResponsePacket response; + buff.swap(response.sBuffer); + + _ret = iRet; + + shared_ptr send = _data->createSendContext(); + + Int32 iHeaderLen = 0; + + // JceOutputStream os; +// JceOutputStream os; + TarsOutputStream os; + + //先预留4个字节长度 + os.writeBuf((const char *)&iHeaderLen, sizeof(iHeaderLen)); + + response.iRequestId = 0; + response.cPacketType = TARSNORMAL; + response.iMessageType = 0; + response.iVersion = TARSVERSION; + response.context = _responseContext; +// response.sServantName = _request.sServantName; +// response.sFuncName = funcName; + response.iRet = iRet; + response.sResultDesc = ""; + + TLOGTARS("[TAF]Current::sendPushResponse :"<< response.iMessageType << "|"<< response.iRequestId << endl); + + response.writeTo(os); + + assert(os.getLength() >= 4); + + iHeaderLen = htonl((int)(os.getLength())); + + memcpy((void*)os.getBuffer(), (const char *)&iHeaderLen, sizeof(iHeaderLen)); + + send->setBuffer(ProxyProtocol::toBuffer(os)); + + _servantHandle->sendResponse(send); +} + + void Current::sendPushResponse(int iRet, const string &funcName, TarsOutputStream& oss, const map &context) { ResponsePacket response; diff --git a/servant/libservant/EndpointManager.cpp b/servant/libservant/EndpointManager.cpp index fa4f8de3..2bc1924b 100644 --- a/servant/libservant/EndpointManager.cpp +++ b/servant/libservant/EndpointManager.cpp @@ -429,17 +429,17 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) { case E_ALL: { - _queryFPrx->async_findObjectById4Any(this,_objName, _communicator->getClientConfig().Context); + _queryFPrx->async_findObjectById4Any(shared_from_this(),_objName, _communicator->getClientConfig().Context); break; } case E_STATION: { - _queryFPrx->async_findObjectByIdInSameStation(this,_objName,sName, _communicator->getClientConfig().Context); + _queryFPrx->async_findObjectByIdInSameStation(shared_from_this(),_objName,sName, _communicator->getClientConfig().Context); break; } case E_SET: { - _queryFPrx->async_findObjectByIdInSameSet(this,_objName,sName, _communicator->getClientConfig().Context); + _queryFPrx->async_findObjectByIdInSameSet(shared_from_this(),_objName,sName, _communicator->getClientConfig().Context); break; } case E_DEFAULT: @@ -449,11 +449,11 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) { //指定set调用时,指定set的优先级最高 string setId = _invokeSetId.empty()?_communicator->getClientConfig().SetDivision:_invokeSetId; - _queryFPrx->async_findObjectByIdInSameSet(this,_objName,setId, _communicator->getClientConfig().Context); + _queryFPrx->async_findObjectByIdInSameSet(shared_from_this(),_objName,setId, _communicator->getClientConfig().Context); } else { - _queryFPrx->async_findObjectByIdInSameGroup(this,_objName, _communicator->getClientConfig().Context); + _queryFPrx->async_findObjectByIdInSameGroup(shared_from_this(),_objName, _communicator->getClientConfig().Context); } break; } diff --git a/servant/libservant/Servant.cpp b/servant/libservant/Servant.cpp index 5ac263cc..264c2235 100644 --- a/servant/libservant/Servant.cpp +++ b/servant/libservant/Servant.cpp @@ -72,6 +72,16 @@ shared_ptr Servant::getHandle() return _handle.lock(); } +void Servant::setModePython( bool forPython) +{ + _modePython = forPython; +} + +bool Servant::isPython() +{ + return _modePython; +} + int Servant::dispatch(CurrentPtr current, vector &buffer) { int ret = TARSSERVERUNKNOWNERR; @@ -90,9 +100,19 @@ int Servant::dispatch(CurrentPtr current, vector &buffer) } else { - TC_LockT lock(*this); - - ret = onDispatch(current, buffer); + if (isPython()) + { +// TC_LockT lock(*this); + BufferWrapper bufferWrapper; + ret = onDispatch(current, &bufferWrapper); + buffer.swap(bufferWrapper.buffer); + } + else + { + TC_LockT lock(*this); + + ret = onDispatch(current, buffer); + } } return ret; } diff --git a/servant/libservant/ServantHandle.cpp b/servant/libservant/ServantHandle.cpp index 3748d1bc..0847c7f0 100644 --- a/servant/libservant/ServantHandle.cpp +++ b/servant/libservant/ServantHandle.cpp @@ -217,7 +217,7 @@ void ServantHandle::heartbeat() CurrentPtr ServantHandle::createCurrent(const shared_ptr &data) { - CurrentPtr current = new Current(shared_from_this()); + CurrentPtr current (new Current(shared_from_this())); try { @@ -262,7 +262,7 @@ CurrentPtr ServantHandle::createCurrent(const shared_ptr &data) { - CurrentPtr current = new Current(shared_from_this()); + CurrentPtr current ( new Current(shared_from_this())); current->initializeClose(data); // current->setReportStat(false); diff --git a/servant/libservant/ServantHelper.cpp b/servant/libservant/ServantHelper.cpp index eea8bc9a..37d09e1a 100644 --- a/servant/libservant/ServantHelper.cpp +++ b/servant/libservant/ServantHelper.cpp @@ -18,6 +18,22 @@ namespace tars { +void ServantHelperManager::setServant(Servant * servant , const string &servantObj) +{ + ServantPtr ptr = servant; + _servant_ptr[servantObj] = ptr; +// LOG_CONSOLE_DEBUG << "setServant:" << servant << "|" << ptr->getName() << "|" << ptr.get() <create(s); diff --git a/servant/libservant/ServantProxy.cpp b/servant/libservant/ServantProxy.cpp index 58c0c12c..cc09b1e0 100644 --- a/servant/libservant/ServantProxy.cpp +++ b/servant/libservant/ServantProxy.cpp @@ -428,6 +428,41 @@ string ServantProxy::STATUS_SETNAME_VALUE = "STATUS_SETNAME_VALUE"; string ServantProxy::STATUS_TRACE_KEY = "STATUS_TRACE_KEY"; +ServantProxy::ServantProxy() +{ +} + +void ServantProxy::setComm(Communicator* pCommunicator, const string& name, const string& setName) +{ + _communicator = pCommunicator; + _syncTimeout = DEFAULT_SYNCTIMEOUT; + _asyncTimeout = DEFAULT_ASYNCTIMEOUT; + _id = 0; + _masterFlag = false; + _minTimeout =100; + + _proxyProtocol.requestFunc = ProxyProtocol::tarsRequest; + _proxyProtocol.responseFunc = ProxyProtocol::tarsResponse; + + //在每个公有网络线程对象中创建ObjectProxy + for (size_t i = 0; i < _communicator->getCommunicatorEpollNum(); ++i) + { + _communicator->getCommunicatorEpoll(i)->createObjectProxy(this, name, setName); + } + + //用第一个ObjectProxy返回数据 + _objectProxy = this->getObjectProxy(0); + + _endpointInfo.reset(new EndpointManagerThread(_communicator, _objectProxy->name())); + + _minTimeout = pCommunicator->getMinTimeout(); + if (_minTimeout < 1) + { + _minTimeout = 1; + } + +} + //////////////////////////////////// ServantProxy::ServantProxy(Communicator *pCommunicator, const string &name, const string &setName) : _communicator(pCommunicator), _syncTimeout(DEFAULT_SYNCTIMEOUT), _asyncTimeout(DEFAULT_ASYNCTIMEOUT), _id(0), _masterFlag(false), _minTimeout(100) @@ -1530,7 +1565,7 @@ void ServantProxy::http_call_async(const string &funcName, const shared_ptr *)(msg->request.sBuffer.data()) = request; - ServantProxyCallbackPtr callback = new HttpServantProxyCallback(cb); + ServantProxyCallbackPtr callback (new HttpServantProxyCallback(cb)); msg->callback = callback; diff --git a/servant/libservant/ServantProxyFactory.cpp b/servant/libservant/ServantProxyFactory.cpp index be912d86..797a1f5c 100644 --- a/servant/libservant/ServantProxyFactory.cpp +++ b/servant/libservant/ServantProxyFactory.cpp @@ -56,5 +56,32 @@ ServantPrx::element_type* ServantProxyFactory::getServantProxy(const string& nam return sp.get(); } +ServantProxy* ServantProxyFactory::setServantProxy(ServantProxy * proxy,const string& name,const string& setName, bool rootServant) +{ + TC_LockT lock(*this); + + string tmpObjName = name + ":" + setName; + + map::iterator it = _servantProxy.find(tmpObjName); + if(it != _servantProxy.end()) + return it->second.get(); + +// ServantPrx sp = proxy; + ServantPrx sp ( proxy); + //需要主动初始化一次 + sp->tars_initialize(rootServant); + + int syncTimeout = TC_Common::strto(_comm->getProperty("sync-invoke-timeout", "3000")); + int asyncTimeout = TC_Common::strto(_comm->getProperty("async-invoke-timeout", "5000")); + int conTimeout = TC_Common::strto(_comm->getProperty("connect-timeout", "1500")); + + sp->tars_timeout(syncTimeout); + sp->tars_async_timeout(asyncTimeout); + sp->tars_connect_timeout(conTimeout); + + _servantProxy[tmpObjName] = sp; + + return sp.get(); +} /////////////////////////////////////////////////////////////////////////////// } diff --git a/servant/servant/Communicator.h b/servant/servant/Communicator.h index adbe98c4..201270af 100644 --- a/servant/servant/Communicator.h +++ b/servant/servant/Communicator.h @@ -216,7 +216,9 @@ class SVT_DLL_API Communicator : public TC_HandleBase, public TC_ThreadRecMutex ServantProxy *pServantProxy = getServantProxy(objectName, setName, true); proxy = (typename T::element_type *)(pServantProxy); } - + + ServantProxy * setServantProxy( ServantProxy * proxy, const string& objectName,const string& setName, bool rootServant); + /** * 获取公有网络线程个数 * @return diff --git a/servant/servant/Current.h b/servant/servant/Current.h index 8af0160b..709fd756 100644 --- a/servant/servant/Current.h +++ b/servant/servant/Current.h @@ -271,6 +271,7 @@ class Current : public TC_HandleBase * @param len */ void sendPushResponse(int iRet, const string &funcName, TarsOutputStream& oss, const map &context = tars::Current::TARS_STATUS()); + void sendPushResponse(int iRet, const string &funcName , vector &buff ); /** * 设置调用链追踪信息,服务端主动回包时用 diff --git a/servant/servant/EndpointManager.h b/servant/servant/EndpointManager.h index 4cb2bed1..20175d28 100644 --- a/servant/servant/EndpointManager.h +++ b/servant/servant/EndpointManager.h @@ -51,7 +51,7 @@ enum EndpointWeightType /* * 路由请求与回调的实现类 */ -class QueryEpBase : public QueryFPrxCallback +class QueryEpBase : public QueryFPrxCallback ,public enable_shared_from_this { public: /* diff --git a/servant/servant/Global.h b/servant/servant/Global.h index 2e5fe0a6..2a397437 100755 --- a/servant/servant/Global.h +++ b/servant/servant/Global.h @@ -65,14 +65,29 @@ class RemoteNotify; typedef TC_AutoPtr CommunicatorPtr; typedef TC_AutoPtr ServantPrx; +typedef TC_AutoPtr StatFPrx; + +#ifdef BUILD_STD_SHARED_PTR + +typedef std::shared_ptr ServantProxyCallbackPtr; +typedef std::shared_ptr ObjectPrx; +typedef std::shared_ptr CurrentPtr; +typedef std::shared_ptr StatReportPtr; +typedef std::shared_ptr FDReactorPtr; +typedef std::shared_ptr AsyncProcThreadPtr; + +#else + typedef TC_AutoPtr ServantProxyCallbackPtr; typedef TC_AutoPtr ObjectPrx; typedef TC_AutoPtr CurrentPtr; -typedef TC_AutoPtr StatFPrx; typedef TC_AutoPtr StatReportPtr; typedef TC_AutoPtr FDReactorPtr; typedef TC_AutoPtr AsyncProcThreadPtr; +#endif + + typedef CurrentPtr TarsCurrentPtr; typedef RemoteConfig TarsRemoteConfig; typedef RemoteNotify TarsRemoteNotify; diff --git a/servant/servant/Servant.h b/servant/servant/Servant.h index 89a2c2c6..891c3b40 100644 --- a/servant/servant/Servant.h +++ b/servant/servant/Servant.h @@ -30,6 +30,13 @@ namespace tars class Application; class ServantHandle; +class BufferWrapper +{ +public: + vector buffer; +}; + +typedef std::shared_ptr BufferWrapperPtr; //////////////////////////////////////////////////////////////////// /** @@ -101,6 +108,8 @@ class Servant : public BaseNotify */ virtual void destroy() = 0; + void setModePython( bool forPython); + bool isPython() ; public: /** * 分发收到的请求 @@ -119,6 +128,8 @@ class Servant : public BaseNotify * @return int */ virtual int onDispatch(CurrentPtr current, vector &buffer) { return -1; } + + virtual int onDispatch(CurrentPtr current, BufferWrapper * bufferWrapper) { return -1; } public: /** @@ -217,6 +228,8 @@ class Servant : public BaseNotify * 缺点就是Servant::onDispatch, 通知ServantImp时, 需要把所有线程都唤醒 */ TC_CasQueue _asyncResponseQueue; + + bool _modePython = false; }; typedef TC_AutoPtr ServantPtr; diff --git a/servant/servant/ServantHelper.h b/servant/servant/ServantHelper.h index cd12b235..a71b29c7 100644 --- a/servant/servant/ServantHelper.h +++ b/servant/servant/ServantHelper.h @@ -64,6 +64,13 @@ struct ServantCreationWithParams : public ServantHelperCreation ////////////////////////////////////////////////////////////////////////////// // +using function_servant_create = std::function< Servant * (void) >; + +struct ServantCreateHelper +{ + function_servant_create creator; + Application *application = nullptr; +}; /** * Servant管理 */ @@ -189,7 +196,9 @@ class SVT_DLL_API ServantHelperManager// : public TC_Singleton _servant_adapter; + map _servant_ptr; + + map _servant_creator_ptr; protected: /** diff --git a/servant/servant/ServantProxy.h b/servant/servant/ServantProxy.h index 4bbc0954..90b8fba4 100644 --- a/servant/servant/ServantProxy.h +++ b/servant/servant/ServantProxy.h @@ -842,12 +842,20 @@ class ServantProxy : public TC_HandleBase, public TC_ThreadMutex PROXY_HTTP, //支持http代理 }; + ServantProxy() ; + /** * 构造函数 * @param op */ ServantProxy(Communicator * pCommunicator, const string& name,const string& setName); + /** + * 主动设置通信器参数 + * @param op + */ + void setComm(Communicator* pCommunicator, const string& name, const string& setName); + /** * 析构函数 */ diff --git a/servant/servant/ServantProxyFactory.h b/servant/servant/ServantProxyFactory.h index fe8dfe09..5f01daef 100644 --- a/servant/servant/ServantProxyFactory.h +++ b/servant/servant/ServantProxyFactory.h @@ -48,6 +48,8 @@ class ServantProxyFactory : public TC_ThreadRecMutex * @return ServantPrx */ ServantPrx::element_type* getServantProxy(const string& name,const string& setName, bool rootServant); + + ServantProxy* setServantProxy(ServantProxy * proxy, const string& name,const string& setName, bool rootServant); private: /** diff --git a/tools/tars2cpp/tars2cpp.cpp b/tools/tars2cpp/tars2cpp.cpp index 6cba3e55..84993bd2 100755 --- a/tools/tars2cpp/tars2cpp.cpp +++ b/tools/tars2cpp/tars2cpp.cpp @@ -2232,7 +2232,10 @@ string Tars2Cpp::generateHAsync(const OperationPtr& pPtr, const string& cn) cons s << TAB << "this->tars_setMasterFlag(true);" << endl; } s << TAB << "tars::Promise< " << cn <<"PrxCallbackPromise::Promise" << sStruct << "Ptr > promise;" << endl; - s << TAB << cn << "PrxCallbackPromisePtr callback = new " << cn << "PrxCallbackPromise(promise);" << endl; + +// s << TAB << cn << "PrxCallbackPromisePtr callback = new " << cn << "PrxCallbackPromise(promise);" << endl; + s << TAB << cn << "PrxCallbackPromisePtr callback (new " << cn << "PrxCallbackPromise(promise));" << endl; + s << endl; s << TAB << _namespace + "::TarsOutputStream<" + _namespace + "::BufferWriterVector> _os;" << endl; for(size_t i = 0; i < vParamDecl.size(); i++) @@ -2782,7 +2785,12 @@ string Tars2Cpp::generateHPromiseAsync(const InterfacePtr &pInter, const Operati DEL_TAB; s << TAB << "};" << endl; s << TAB << endl; +#ifdef BUILD_STD_SHARED_PTR + s << TAB << "typedef std::shared_ptr< " << pInter->getId() << "PrxCallbackPromise::Promise" << sStruct << " > Promise" << sStruct << "Ptr;" << endl; +#else s << TAB << "typedef tars::TC_AutoPtr< " << pInter->getId() << "PrxCallbackPromise::Promise" << sStruct << " > Promise" << sStruct << "Ptr;" << endl; +#endif + s << endl; s << TAB << pInter->getId() << "PrxCallbackPromise(const tars::Promise< " << pInter->getId() << "PrxCallbackPromise::Promise" << sStruct << "Ptr > &promise)" << endl; s << TAB << ": _promise_" << sStruct << "(promise)" << endl; @@ -2827,7 +2835,9 @@ string Tars2Cpp::generateDispatchPromiseAsync(const OperationPtr &pPtr, const st s << TAB << "_is.setBuffer(_msg_->response->sBuffer);" << endl; s << endl; string sStruct = pPtr->getId(); - s << TAB << cn << "PrxCallbackPromise::Promise" << sStruct << "Ptr ptr = new "<< cn << "PrxCallbackPromise::Promise" << sStruct << "();" << endl; + +// s << TAB << cn << "PrxCallbackPromise::Promise" << sStruct << "Ptr ptr = new "<< cn << "PrxCallbackPromise::Promise" << sStruct << "();" << endl; + s << TAB << cn << "PrxCallbackPromise::Promise" << sStruct << "Ptr ptr (new "<< cn << "PrxCallbackPromise::Promise" << sStruct << "());" << endl; s << endl; if(pPtr->getReturnPtr()->getTypePtr() || vParamDecl.size() >0) { @@ -2986,7 +2996,12 @@ string Tars2Cpp::generateH(const InterfacePtr &pPtr, const NamespacePtr &nPtr) c DEL_TAB; s << TAB << "};" << endl; +#ifdef BUILD_STD_SHARED_PTR + s << TAB << "typedef std::shared_ptr<" << pPtr->getId() << "PrxCallback> " << pPtr->getId() << "PrxCallbackPtr;" << endl; +#else s << TAB << "typedef tars::TC_AutoPtr<" << pPtr->getId() << "PrxCallback> " << pPtr->getId() << "PrxCallbackPtr;" << endl; +#endif + s << endl; //生成promise异步回调Proxy s << TAB << "//callback of promise async proxy for client" << endl; @@ -3044,7 +3059,12 @@ string Tars2Cpp::generateH(const InterfacePtr &pPtr, const NamespacePtr &nPtr) c s << endl; DEL_TAB; s << TAB << "};" << endl; + +#ifdef BUILD_STD_SHARED_PTR + s << TAB << "typedef std::shared_ptr<" << pPtr->getId() << "PrxCallbackPromise> " << pPtr->getId() << "PrxCallbackPromisePtr;" << endl; +#else s << TAB << "typedef tars::TC_AutoPtr<" << pPtr->getId() << "PrxCallbackPromise> " << pPtr->getId() << "PrxCallbackPromisePtr;" << endl; +#endif s << endl; //生成协程异步回调类,用于并发请求 s << TAB << "/* callback of coroutine async proxy for client */" << endl; @@ -3131,8 +3151,11 @@ string Tars2Cpp::generateH(const InterfacePtr &pPtr, const NamespacePtr &nPtr) c DEL_TAB; s << TAB << "};" << endl; - +#ifdef BUILD_STD_SHARED_PTR + s << TAB << "typedef std::shared_ptr<" << pPtr->getId() << "CoroPrxCallback> " << pPtr->getId() << "CoroPrxCallbackPtr;" << endl; +#else s << TAB << "typedef tars::TC_AutoPtr<" << pPtr->getId() << "CoroPrxCallback> " << pPtr->getId() << "CoroPrxCallbackPtr;" << endl; +#endif s << endl; //生成客户端代理 diff --git a/tools/tarsparse/CMakeLists.txt b/tools/tarsparse/CMakeLists.txt index b47e3170..d9f7788e 100644 --- a/tools/tarsparse/CMakeLists.txt +++ b/tools/tarsparse/CMakeLists.txt @@ -37,3 +37,6 @@ endif(UNIX) install(TARGETS tarsparse LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + +FILE(GLOB HEADERS "*.h") +install(FILES ${HEADERS} DESTINATION include/tarsparse) \ No newline at end of file From 88dec50671cfdd20778a88bdc4f5dbc046a9939c Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 20 Feb 2024 11:05:04 +0800 Subject: [PATCH 53/81] fix tc_socket getLocalHosts support ipv4 feat EndpointInfo add toEndpointFs --- servant/libservant/EndpointInfo.cpp | 89 ++++++++++++++ servant/servant/EndpointInfo.h | 11 ++ unit-test/util/test_tc_socket.cpp | 45 +++++++ util/include/util/tc_socket.h | 2 +- util/src/tc_socket.cpp | 183 +++++++++------------------- 5 files changed, 203 insertions(+), 127 deletions(-) create mode 100755 unit-test/util/test_tc_socket.cpp diff --git a/servant/libservant/EndpointInfo.cpp b/servant/libservant/EndpointInfo.cpp index 605419a0..452493be 100755 --- a/servant/libservant/EndpointInfo.cpp +++ b/servant/libservant/EndpointInfo.cpp @@ -86,6 +86,95 @@ EndpointF EndpointInfo::toEndpointF(const TC_Endpoint &tep, const string &nodeNa return ep; } +vector EndpointInfo::toEndpointFs(const TC_Endpoint &ep, const string &nodeName) +{ + //如果ep的host是0.0.0.0, 则使用本地ip地址 + string host = ep.getHost(); + if (host == "0.0.0.0") + { + vector v; + vector ips = TC_Socket::getLocalHosts(AF_INET); + + for(const auto &ip : ips) + { + if(ip == "127.0.0.1") + { + continue; + } + + TC_Endpoint theEp = ep; + theEp.setHost(ip); + + v.push_back(EndpointInfo::toEndpointF(theEp, nodeName)); + } + + return v; + } + else if (host == "::1") + { + vector v; + vector ips = TC_Socket::getLocalHosts(AF_INET6); + + for(const auto &ip : ips) + { + if(ip == "::1") + { + continue; + } + + TC_Endpoint theEp = ep; + theEp.setHost(ip); + + v.push_back(EndpointInfo::toEndpointF(theEp, nodeName)); + } + + return v; + } + else if (host == "*") + { + vector v; + { + vector ips = TC_Socket::getLocalHosts(AF_INET); + + for (const auto &ip: ips) + { + if (ip == "127.0.0.1") + { + continue; + } + + TC_Endpoint theEp = ep; + theEp.setHost(ip); + + v.push_back(EndpointInfo::toEndpointF(theEp, nodeName)); + } + } + + { + vector ips = TC_Socket::getLocalHosts(AF_INET6); + + for (const auto &ip: ips) + { + if (ip == "::1") + { + continue; + } + + TC_Endpoint theEp = ep; + theEp.setHost(ip); + + v.push_back(EndpointInfo::toEndpointF(theEp, nodeName)); + } + } + + return v; + } + else + { + return {EndpointInfo::toEndpointF(ep, nodeName)}; + } +} + /////////////////////////////////////////////////////////// } diff --git a/servant/servant/EndpointInfo.h b/servant/servant/EndpointInfo.h index b03751fd..7592afc4 100755 --- a/servant/servant/EndpointInfo.h +++ b/servant/servant/EndpointInfo.h @@ -62,6 +62,17 @@ class EndpointInfo */ static EndpointF toEndpointF(const TC_Endpoint &ep, const string &nodeName); + /** + * 转换数据结构 + * 如果是0.0.0.0 则换成本机实际ipv4的所有地址(多网卡), 注意去掉了127.0.0.1 + * 如果是::1, 则换成本机实际ipv6的所有地址(多网卡), 注意去掉了::1 + * 如果是*, 则换成本机所有的ipv4/ipv6的所有地址(多网卡), 注意去掉了127.0.0.1 和 ::1 + * @param ep + * @param nodeName + * @return + */ + static vector toEndpointFs(const TC_Endpoint &ep, const string &nodeName); + /** * get endpoint * @return diff --git a/unit-test/util/test_tc_socket.cpp b/unit-test/util/test_tc_socket.cpp new file mode 100755 index 00000000..f4c155df --- /dev/null +++ b/unit-test/util/test_tc_socket.cpp @@ -0,0 +1,45 @@ +#include "util/tc_common.h" +#include "util/tc_socket.h" +#include "gtest/gtest.h" + +#include +#include + +using namespace std; +using namespace tars; + +class UtilSocketTest : public testing::Test +{ +public: + //添加日志 + static void SetUpTestCase() + { + } + static void TearDownTestCase() + { + } + virtual void SetUp() //TEST跑之前会执行SetUp + { + } + virtual void TearDown() //TEST跑完之后会执行TearDown + { + } +}; + +TEST_F(UtilSocketTest, testGetLocalHosts) +{ + vector v1 = TC_Socket::getLocalHosts(AF_INET); + + for(size_t i = 0; i < v1.size(); i++) + { + cout << v1[i] << endl; + } + + vector v2 = TC_Socket::getLocalHosts(AF_INET6); + + for(size_t i = 0; i < v2.size(); i++) + { + cout << v2[i] << endl; + } +} + diff --git a/util/include/util/tc_socket.h b/util/include/util/tc_socket.h index d09eabaa..884a7244 100644 --- a/util/include/util/tc_socket.h +++ b/util/include/util/tc_socket.h @@ -107,7 +107,7 @@ class TC_Socket * * @param fd socket句柄 * @param bOwner 是否拥有socket - * @param iDomain sokect协议族,缺省为AF_INET,代表TCP/IP协议族 + * @param iDomain socket协议族,缺省为AF_INET,代表TCP/IP协议族 */ void init(int fd, bool bOwner, int iDomain = AF_INET); diff --git a/util/src/tc_socket.cpp b/util/src/tc_socket.cpp index f81946bf..45513cc8 100755 --- a/util/src/tc_socket.cpp +++ b/util/src/tc_socket.cpp @@ -895,147 +895,78 @@ void TC_Socket::createPipe(int fds[2], bool bBlock) THROW_EXCEPTION_SYSCODE(TC_Socket_Exception, "[TC_Socket::createPipe] error"); } -#if TARGET_PLATFORM_LINUX -vector TC_Socket::getLocalHosts(int domain) -{ - vector result; - TC_Socket ts; - ts.createSocket(SOCK_STREAM, domain); - - int cmd = SIOCGIFCONF; - - struct ifconf ifc; - - int numaddrs = 10; - - int old_ifc_len = 0; - - while(true) - { - int bufsize = numaddrs * static_cast(sizeof(struct ifreq)); - ifc.ifc_len = bufsize; - ifc.ifc_buf = (char*)malloc(bufsize); - int rs = ioctl(ts.getfd(), cmd, &ifc); - - if(rs == -1) - { - free(ifc.ifc_buf); - throw TC_Socket_Exception("[TC_Socket::getLocalHosts] ioctl error", errno); - } - else if(ifc.ifc_len == old_ifc_len) - { - break; - } - else - { - old_ifc_len = ifc.ifc_len; - } - - numaddrs += 10; - free(ifc.ifc_buf); - } - - numaddrs = ifc.ifc_len / static_cast(sizeof(struct ifreq)); - struct ifreq* ifr = ifc.ifc_req; - for(int i = 0; i < numaddrs; ++i) - { - if(ifr[i].ifr_addr.sa_family == AF_INET) - { - struct sockaddr_in* addr = reinterpret_cast(&ifr[i].ifr_addr); - if(addr->sin_addr.s_addr != 0) - { - char sAddr[INET_ADDRSTRLEN] = "\0"; - inet_ntop(AF_INET, &(*addr).sin_addr, sAddr, sizeof(sAddr)); - result.push_back(sAddr); - } - } - else if (ifr[i].ifr_addr.sa_family == AF_INET6) - { - struct sockaddr_in6* addr = reinterpret_cast(&ifr[i].ifr_addr); - if(!memcmp(&addr->sin6_addr, &in6addr_any, sizeof(addr->sin6_addr))) - { - char sAddr[INET6_ADDRSTRLEN] = "\0"; - inet_ntop(AF_INET6, &(*addr).sin6_addr, sAddr, sizeof(sAddr)); - result.push_back(sAddr); - } - } - } - - free(ifc.ifc_buf); - - return result; -} -#elif TARGET_PLATFORM_IOS +//#if TARGET_PLATFORM_LINUX || TARGET_PLATFORM_IOS vector TC_Socket::getLocalHosts(int domain) { vector hosts; char local[255] = { 0 }; gethostname(local, sizeof(local)); - hostent* ph = gethostbyname(local); - if (ph == NULL) - { - return hosts; - } - in_addr addr; - if (ph->h_addrtype == AF_INET) - { - int i = 0; - while (ph->h_addr_list[i] != 0) - { - addr.s_addr = *(u_long*)ph->h_addr_list[i++]; - hosts.emplace_back(inet_ntoa(addr)); - } - } - else - { - // unsupport AF_INET6 ... - return hosts; - } - return hosts; -} -#endif + struct addrinfo hints, *res, *p; + int status; + char ipstr[INET6_ADDRSTRLEN]; -#if TARGET_PLATFORM_WINDOWS -vector TC_Socket::getLocalHosts(int domain) -{ - vector hosts; - WORD wVersionRequested = MAKEWORD(2, 2); + memset(&hints, 0, sizeof hints); + hints.ai_family = domain; // AF_UNSPEC means any: AF_INET, AF_INET6, etc. + hints.ai_socktype = SOCK_STREAM; - WSADATA wsaData; - if (WSAStartup(wVersionRequested, &wsaData) != 0) - { + if ((status = getaddrinfo(local, NULL, &hints, &res)) != 0) { return hosts; } - char local[255] = { 0 }; - gethostname(local, sizeof(local)); - hostent* ph = gethostbyname(local); - if (ph == NULL) - { - return hosts; - } - - in_addr addr; - if (ph->h_addrtype == AF_INET) - { - int i = 0; - while (ph->h_addr_list[i] != 0) - { - addr.s_addr = *(u_long*)ph->h_addr_list[i++]; - hosts.emplace_back(inet_ntoa(addr)); + for(p = res;p != NULL; p = p->ai_next) { + void *addr; + if (p->ai_family == AF_INET) { // IPv4 + struct sockaddr_in *ipv4 = (struct sockaddr_in *)p->ai_addr; + addr = &(ipv4->sin_addr); + } else if (p->ai_family == AF_INET6) { // IPv6 + struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)p->ai_addr; + addr = &(ipv6->sin6_addr); } + + // convert IP to a string and add it to the list + inet_ntop(p->ai_family, addr, ipstr, sizeof ipstr); + hosts.emplace_back(ipstr); } - else - { - // unsupport AF_INET6 ... - return hosts; - } - WSACleanup(); + + freeaddrinfo(res); // free the linked list + return hosts; } - -#endif +//#endif +// +//#if TARGET_PLATFORM_WINDOWS +//vector TC_Socket::getLocalHosts(int domain) +//{ +// vector hosts; +// +// char local[255] = { 0 }; +// gethostname(local, sizeof(local)); +// hostent* ph = gethostbyname(local); +// if (ph == NULL) +// { +// return hosts; +// } +// +// in_addr addr; +// if (ph->h_addrtype == AF_INET) +// { +// int i = 0; +// while (ph->h_addr_list[i] != 0) +// { +// addr.s_addr = *(u_long*)ph->h_addr_list[i++]; +// hosts.emplace_back(inet_ntoa(addr)); +// } +// } +// else +// { +// // unsupport AF_INET6 ... +// return hosts; +// } +// return hosts; +//} +// +//#endif bool TC_Socket::isPending() { From 2399ef0cb6825138d4057a08df1a7c05be2e8c86 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 20 Feb 2024 14:59:11 +0800 Subject: [PATCH 54/81] feat EndpointInfo add vectorEndpointFToStr/strToVectorEndpointF/toNodeEndpointF to support multi network interfaces --- servant/libservant/EndpointInfo.cpp | 87 +++++++++++++++++++++++++---- servant/servant/EndpointInfo.h | 29 ++++++++++ 2 files changed, 104 insertions(+), 12 deletions(-) diff --git a/servant/libservant/EndpointInfo.cpp b/servant/libservant/EndpointInfo.cpp index 452493be..0804caa9 100755 --- a/servant/libservant/EndpointInfo.cpp +++ b/servant/libservant/EndpointInfo.cpp @@ -40,23 +40,12 @@ EndpointInfo::EndpointInfo(const TC_Endpoint &ep, const string &setDivision) EndpointInfo::EndpointInfo(const EndpointF &ep) : _setDivision(ep.setId) { - _ep.setHost(ep.host); - _ep.setPort(ep.port); - _ep.setTimeout(ep.timeout); - _ep.setType((TC_Endpoint::EType)ep.istcp); - _ep.setGrid(ep.grid); - _ep.setQos(ep.qos); - _ep.setWeight(ep.weight); - _ep.setWeightType(ep.weightType); - - _ep.setAuthType((TC_Endpoint::AUTH_TYPE)ep.authType); + _ep = toEndpointF(ep); _cmpDesc = createCompareDesc(); _desc = createDesc(); - } - string EndpointInfo::createCompareDesc() { stringstream ss; @@ -65,6 +54,22 @@ string EndpointInfo::createCompareDesc() return ss.str(); } +TC_Endpoint EndpointInfo::toEndpointF(const EndpointF &ep) +{ + TC_Endpoint tEp; + tEp.setHost(ep.host); + tEp.setPort(ep.port); + tEp.setTimeout(ep.timeout); + tEp.setType((TC_Endpoint::EType)ep.istcp); + tEp.setGrid(ep.grid); + tEp.setQos(ep.qos); + tEp.setWeight(ep.weight); + tEp.setWeightType(ep.weightType); + + tEp.setAuthType((TC_Endpoint::AUTH_TYPE)ep.authType); + + return tEp; +} EndpointF EndpointInfo::toEndpointF(const TC_Endpoint &tep, const string &nodeName) { @@ -175,6 +180,64 @@ vector EndpointInfo::toEndpointFs(const TC_Endpoint &ep, const string } } +string EndpointInfo::vectorEndpointFToStr(const vector &eps, bool complete) +{ + ostringstream os; + if(!complete) + { + for (size_t i = 0; i < eps.size(); i++) + { + os << eps[i].host << ":" << eps[i].port; + if (i != eps.size() - 1) + { + os << ","; + } + } + } + else + { + for (size_t i = 0; i < eps.size(); i++) + { + os << toEndpointF(eps[i]).toString(); + if (i != eps.size() - 1) + { + os << ":"; + } + } + } + return os.str(); +} + +vector EndpointInfo::strToVectorEndpointF(const string &str, const string &nodeName) +{ + vector eps = TC_Endpoint::sepEndpoint(str); + + //遍历转换格式 + vector epsF; + for (size_t i = 0; i < eps.size(); i++) + { + TC_Endpoint ep(eps[i]); + + epsF.push_back(EndpointInfo::toEndpointF(ep, nodeName)); + } + return epsF; +} + +map> EndpointInfo::toNodeEndpointF(const vector &eps) +{ + map> data; + for(auto ep : eps) + { + if(ep.nodeName.empty()) + { + //兼容旧框架, 没有赋值nodeName + ep.nodeName = ep.host; + } + + data[ep.nodeName].push_back(ep); + } + return data; +} /////////////////////////////////////////////////////////// } diff --git a/servant/servant/EndpointInfo.h b/servant/servant/EndpointInfo.h index 7592afc4..6da493bb 100755 --- a/servant/servant/EndpointInfo.h +++ b/servant/servant/EndpointInfo.h @@ -55,6 +55,13 @@ class EndpointInfo */ EndpointInfo(const EndpointF &ep); + /** + * 转换 + * @param ep + * @return + */ + static TC_Endpoint toEndpointF(const EndpointF &ep); + /** * 转换 * @param ep @@ -73,6 +80,28 @@ class EndpointInfo */ static vector toEndpointFs(const TC_Endpoint &ep, const string &nodeName); + /** + * 转换成字符串, 方便输出 + * @param eps + * @param complete: 是否完整转换 + * @return complete: false->ip1:port,ip2:port2,... complete: true -> tcp -h .. -p ..:tcp -h .. -p .. + */ + static string vectorEndpointFToStr(const vector &eps, bool complete = true); + + /** + * 字符串转换成vector + * @param str, tcp -h .. -p ..:tcp -h .. -p .. + * @param nodeName + * @return + */ + static vector strToVectorEndpointF(const string &str, const string &nodeName); + + /** + * 按照节点名称归并 + * @return <节点名称, [地址]> + */ + static map> toNodeEndpointF(const vector &eps); + /** * get endpoint * @return From 4a8a27c8f587efc5fb7afef43107c3a84fb3a378 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 22 Feb 2024 10:24:17 +0800 Subject: [PATCH 55/81] fix mysql 8.0 --- cmake/Thirdparty.cmake | 4 +- .../HelloServer/Client/main.cpp | 3 +- unit-test/CMakeLists.txt | 4 ++ unit-test/util/test_tc_mysql.cpp | 62 +++++++++++++++++++ util/src/tc_mysql.cpp | 3 + 5 files changed, 73 insertions(+), 3 deletions(-) create mode 100755 unit-test/util/test_tc_mysql.cpp diff --git a/cmake/Thirdparty.cmake b/cmake/Thirdparty.cmake index 10c373e5..a48edfc1 100755 --- a/cmake/Thirdparty.cmake +++ b/cmake/Thirdparty.cmake @@ -272,7 +272,7 @@ if (TARS_MYSQL) DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download PREFIX ${CMAKE_BINARY_DIR} INSTALL_DIR ${CMAKE_SOURCE_DIR} - CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/mysql -DBUILD_CONFIG=mysql_release + CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/mysql -DBUILD_CONFIG=mysql_release -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci SOURCE_DIR ${CMAKE_BINARY_DIR}/src/mysql-lib BUILD_IN_SOURCE 1 BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release @@ -288,7 +288,7 @@ if (TARS_MYSQL) DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download PREFIX ${CMAKE_BINARY_DIR} INSTALL_DIR ${CMAKE_SOURCE_DIR} - CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DDISABLE_SHARED=1 -DSTACK_DIRECTION=1 -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/mysql -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DDISABLE_SHARED=1 -DSTACK_DIRECTION=1 -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} SOURCE_DIR ${CMAKE_BINARY_DIR}/src/mysql-lib BUILD_IN_SOURCE 1 BUILD_COMMAND make mysqlclient diff --git a/examples/QuickStartDemo/HelloServer/Client/main.cpp b/examples/QuickStartDemo/HelloServer/Client/main.cpp index 30741587..bb25b8b6 100644 --- a/examples/QuickStartDemo/HelloServer/Client/main.cpp +++ b/examples/QuickStartDemo/HelloServer/Client/main.cpp @@ -172,9 +172,10 @@ void syncTupCall(int c) rsp.decode(package.sBuffer.data(), package.sBuffer.size()); - int ret = rsp.get(""); + int ret = rsp.get(""); string sRsp = rsp.get("sRsp"); + cout << "ret:" << ret << ", rsp:" << sRsp << endl; // assert(ret == 0); // assert(sRsp == buffer); } diff --git a/unit-test/CMakeLists.txt b/unit-test/CMakeLists.txt index fcaac208..04ad1afa 100755 --- a/unit-test/CMakeLists.txt +++ b/unit-test/CMakeLists.txt @@ -13,4 +13,8 @@ build_tars_server("unit-test" "") add_definitions(-DCMAKE_SOURCE_DIR="${PROJECT_SOURCE_DIR}") target_link_libraries(unit-test ${LIB_GTEST}) +if(TARS_MYSQL) + target_link_libraries(unit-test ${LIB_MYSQL}) +endif() + add_dependencies(unit-test FRAMEWORK-PROTOCOL) diff --git a/unit-test/util/test_tc_mysql.cpp b/unit-test/util/test_tc_mysql.cpp new file mode 100755 index 00000000..fca1dbbf --- /dev/null +++ b/unit-test/util/test_tc_mysql.cpp @@ -0,0 +1,62 @@ +#include "util/tc_common.h" +#include "util/tc_mysql.h" +#include "gtest/gtest.h" + +#include +#include + +using namespace std; +using namespace tars; + +class UtilMysqlTest : public testing::Test +{ +public: + //添加日志 + static void SetUpTestCase() + { + } + static void TearDownTestCase() + { + } + virtual void SetUp() //TEST跑之前会执行SetUp + { + } + virtual void TearDown() //TEST跑完之后会执行TearDown + { + } +}; + +#ifdef TARS_MYSQL + +TEST_F(UtilMysqlTest, test80) +{ + try + { + TC_Mysql mysql; + + mysql.init("127.0.0.1", "root", "123456", "", "utf8", 3307, 0); + + mysql.queryRecord("select 1"); + } + catch(exception &ex) + { + cerr << ex.what() << endl; + } + + try + { + TC_Mysql mysql; + + mysql.init("127.0.0.1", "root", "tars@12345", "", "utf8", 3306, 0); + + mysql.queryRecord("select 1"); + + cout << "success" << endl; + } + catch(exception &ex) + { + cerr << ex.what() << endl; + } +} + +#endif \ No newline at end of file diff --git a/util/src/tc_mysql.cpp b/util/src/tc_mysql.cpp index 986f9faa..ff88d59a 100644 --- a/util/src/tc_mysql.cpp +++ b/util/src/tc_mysql.cpp @@ -114,6 +114,9 @@ void TC_Mysql::connect() } } + unsigned int i = 1; + + mysql_options(_pstMql, MYSQL_OPT_SSL_MODE, &i); if (mysql_real_connect(_pstMql, _dbConf._host.c_str(), _dbConf._user.c_str(), _dbConf._password.c_str(), _dbConf._database.c_str(), _dbConf._port, NULL, _dbConf._flag) == NULL) { From 185acd60e8a9cb9bc69d0ad5164cc3f1405372b1 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Fri, 23 Feb 2024 12:13:24 +0800 Subject: [PATCH 56/81] fix no USE_STD_SHARED_PTR compiler --- servant/libservant/EndpointManager.cpp | 20 ++ tools/tarsgrammar/tars.tab.cpp | 266 ++++++++++++------------- tools/tarsparse/tars.lex.cpp | 36 ++-- tools/tarsparse/tars.tab.cpp | 266 ++++++++++++------------- 4 files changed, 304 insertions(+), 284 deletions(-) diff --git a/servant/libservant/EndpointManager.cpp b/servant/libservant/EndpointManager.cpp index 2bc1924b..95ef5b18 100644 --- a/servant/libservant/EndpointManager.cpp +++ b/servant/libservant/EndpointManager.cpp @@ -429,17 +429,29 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) { case E_ALL: { +#if USE_STD_SHARED_PTR _queryFPrx->async_findObjectById4Any(shared_from_this(),_objName, _communicator->getClientConfig().Context); +#else + _queryFPrx->async_findObjectById4Any(this,_objName, _communicator->getClientConfig().Context); +#endif break; } case E_STATION: { +#if USE_STD_SHARED_PTR _queryFPrx->async_findObjectByIdInSameStation(shared_from_this(),_objName,sName, _communicator->getClientConfig().Context); +#else + _queryFPrx->async_findObjectByIdInSameStation(this,_objName,sName, _communicator->getClientConfig().Context); +#endif break; } case E_SET: { +#if USE_STD_SHARED_PTR _queryFPrx->async_findObjectByIdInSameSet(shared_from_this(),_objName,sName, _communicator->getClientConfig().Context); +#else + _queryFPrx->async_findObjectByIdInSameSet(this,_objName,sName, _communicator->getClientConfig().Context); +#endif break; } case E_DEFAULT: @@ -449,11 +461,19 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) { //指定set调用时,指定set的优先级最高 string setId = _invokeSetId.empty()?_communicator->getClientConfig().SetDivision:_invokeSetId; +#if USE_STD_SHARED_PTR _queryFPrx->async_findObjectByIdInSameSet(shared_from_this(),_objName,setId, _communicator->getClientConfig().Context); +#else + _queryFPrx->async_findObjectByIdInSameSet(this,_objName,setId, _communicator->getClientConfig().Context); +#endif } else { +#if USE_STD_SHARED_PTR _queryFPrx->async_findObjectByIdInSameGroup(shared_from_this(),_objName, _communicator->getClientConfig().Context); +#else + _queryFPrx->async_findObjectByIdInSameGroup(this,_objName, _communicator->getClientConfig().Context); +#endif } break; } diff --git a/tools/tarsgrammar/tars.tab.cpp b/tools/tarsgrammar/tars.tab.cpp index 9fb66bc2..83215380 100644 --- a/tools/tarsgrammar/tars.tab.cpp +++ b/tools/tarsgrammar/tars.tab.cpp @@ -67,7 +67,7 @@ /* First part of user prologue. */ -#line 17 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 17 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" #include #include @@ -1384,14 +1384,14 @@ yyparse (void) switch (yyn) { case 3: /* $@1: %empty */ -#line 75 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 75 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1391 "tars.tab.cpp" break; case 5: /* $@2: %empty */ -#line 79 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 79 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyerrok; } @@ -1399,7 +1399,7 @@ yyparse (void) break; case 7: /* definitions: definition */ -#line 84 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 84 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } @@ -1407,14 +1407,14 @@ yyparse (void) break; case 8: /* definitions: %empty */ -#line 88 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 88 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1414 "tars.tab.cpp" break; case 9: /* definition: namespace_def */ -#line 96 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 96 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || NamespacePtr::dynamicCast(yyvsp[0])); } @@ -1422,7 +1422,7 @@ yyparse (void) break; case 10: /* definition: interface_def */ -#line 100 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 100 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || InterfacePtr::dynamicCast(yyvsp[0])); } @@ -1430,7 +1430,7 @@ yyparse (void) break; case 11: /* definition: struct_def */ -#line 104 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 104 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || StructPtr::dynamicCast(yyvsp[0])); } @@ -1438,14 +1438,14 @@ yyparse (void) break; case 12: /* definition: key_def */ -#line 108 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 108 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1445 "tars.tab.cpp" break; case 13: /* definition: enum_def */ -#line 111 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 111 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || EnumPtr::dynamicCast(yyvsp[0])); } @@ -1453,7 +1453,7 @@ yyparse (void) break; case 14: /* definition: const_def */ -#line 115 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 115 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || ConstPtr::dynamicCast(yyvsp[0])); } @@ -1461,7 +1461,7 @@ yyparse (void) break; case 15: /* @3: %empty */ -#line 124 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 124 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1469,7 +1469,7 @@ yyparse (void) break; case 16: /* enum_def: enum_id @3 '{' enumerator_list '}' */ -#line 128 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 128 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1487,7 +1487,7 @@ yyparse (void) break; case 17: /* enum_id: TARS_ENUM TARS_IDENTIFIER */ -#line 147 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 147 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { NamespacePtr c = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!c) @@ -1504,7 +1504,7 @@ yyparse (void) break; case 18: /* enum_id: TARS_ENUM keyword */ -#line 160 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 160 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumeration name"); @@ -1514,7 +1514,7 @@ yyparse (void) break; case 19: /* enumerator_list: enumerator ',' enumerator_list */ -#line 171 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 171 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[-1]; } @@ -1522,14 +1522,14 @@ yyparse (void) break; case 20: /* enumerator_list: enumerator */ -#line 175 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 175 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1529 "tars.tab.cpp" break; case 21: /* enumerator: TARS_IDENTIFIER */ -#line 183 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 183 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1544,7 +1544,7 @@ yyparse (void) break; case 22: /* enumerator: keyword */ -#line 194 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 194 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumerator"); @@ -1553,7 +1553,7 @@ yyparse (void) break; case 23: /* enumerator: TARS_IDENTIFIER '=' const_initializer */ -#line 199 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 199 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -1570,14 +1570,14 @@ yyparse (void) break; case 24: /* enumerator: %empty */ -#line 212 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 212 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1577 "tars.tab.cpp" break; case 25: /* @4: %empty */ -#line 220 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 220 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ContainerPtr c = g_parse->currentContainer(); @@ -1596,7 +1596,7 @@ yyparse (void) break; case 26: /* namespace_def: TARS_NAMESPACE TARS_IDENTIFIER @4 '{' definitions '}' */ -#line 235 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 235 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1612,7 +1612,7 @@ yyparse (void) break; case 27: /* $@5: %empty */ -#line 253 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 253 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-1]); StructPtr sp = StructPtr::dynamicCast(g_parse->findUserType(ident->v)); @@ -1627,14 +1627,14 @@ yyparse (void) break; case 28: /* key_def: TARS_KEY '[' scoped_name ',' $@5 key_members ']' */ -#line 264 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 264 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1634 "tars.tab.cpp" break; case 29: /* key_members: TARS_IDENTIFIER */ -#line 272 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 272 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1651,7 +1651,7 @@ yyparse (void) break; case 30: /* key_members: key_members ',' TARS_IDENTIFIER */ -#line 285 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 285 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1668,7 +1668,7 @@ yyparse (void) break; case 31: /* @6: %empty */ -#line 304 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 304 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1689,7 +1689,7 @@ yyparse (void) break; case 32: /* interface_def: interface_id @6 '{' interface_exports '}' */ -#line 321 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 321 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1705,7 +1705,7 @@ yyparse (void) break; case 33: /* interface_id: TARS_INTERFACE TARS_IDENTIFIER */ -#line 338 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 338 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1713,7 +1713,7 @@ yyparse (void) break; case 34: /* interface_id: TARS_INTERFACE keyword */ -#line 342 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 342 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as interface name"); @@ -1723,21 +1723,21 @@ yyparse (void) break; case 35: /* interface_exports: interface_export ';' interface_exports */ -#line 353 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 353 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1730 "tars.tab.cpp" break; case 36: /* interface_exports: error ';' interface_exports */ -#line 356 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 356 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1737 "tars.tab.cpp" break; case 37: /* interface_exports: interface_export */ -#line 359 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 359 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } @@ -1745,14 +1745,14 @@ yyparse (void) break; case 38: /* interface_exports: %empty */ -#line 363 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 363 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1752 "tars.tab.cpp" break; case 40: /* operation: operation_preamble parameters ')' */ -#line 377 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 377 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1768,7 +1768,7 @@ yyparse (void) break; case 41: /* operation_preamble: return_type TARS_OP */ -#line 394 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 394 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1796,7 +1796,7 @@ yyparse (void) break; case 43: /* return_type: TARS_VOID */ -#line 424 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 424 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = 0; } @@ -1804,14 +1804,14 @@ yyparse (void) break; case 44: /* parameters: %empty */ -#line 434 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 434 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1811 "tars.tab.cpp" break; case 45: /* parameters: type_id */ -#line 437 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 437 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1826,7 +1826,7 @@ yyparse (void) break; case 46: /* parameters: parameters ',' type_id */ -#line 448 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 448 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1841,7 +1841,7 @@ yyparse (void) break; case 47: /* parameters: out_qualifier type_id */ -#line 459 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 459 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1857,7 +1857,7 @@ yyparse (void) break; case 48: /* parameters: parameters ',' out_qualifier type_id */ -#line 471 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 471 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1873,7 +1873,7 @@ yyparse (void) break; case 49: /* parameters: routekey_qualifier type_id */ -#line 483 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 483 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1889,7 +1889,7 @@ yyparse (void) break; case 50: /* parameters: parameters ',' routekey_qualifier type_id */ -#line 495 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 495 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1905,7 +1905,7 @@ yyparse (void) break; case 51: /* parameters: out_qualifier */ -#line 507 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 507 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("'out' must be defined with a type"); } @@ -1913,7 +1913,7 @@ yyparse (void) break; case 52: /* parameters: routekey_qualifier */ -#line 511 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 511 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("'routekey' must be defined with a type"); } @@ -1921,7 +1921,7 @@ yyparse (void) break; case 53: /* routekey_qualifier: TARS_ROUTE_KEY */ -#line 520 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 520 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr routekey = new BoolGrammar; routekey->v = true; @@ -1931,7 +1931,7 @@ yyparse (void) break; case 54: /* out_qualifier: TARS_OUT */ -#line 531 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 531 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr out = new BoolGrammar; out->v = true; @@ -1941,7 +1941,7 @@ yyparse (void) break; case 55: /* @7: %empty */ -#line 542 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 542 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); @@ -1967,7 +1967,7 @@ yyparse (void) break; case 56: /* struct_def: struct_id @7 '{' struct_exports '}' */ -#line 564 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 564 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1986,7 +1986,7 @@ yyparse (void) break; case 57: /* struct_id: TARS_STRUCT TARS_IDENTIFIER */ -#line 584 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 584 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1994,7 +1994,7 @@ yyparse (void) break; case 58: /* struct_id: TARS_STRUCT keyword */ -#line 588 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 588 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2004,7 +2004,7 @@ yyparse (void) break; case 59: /* struct_id: TARS_STRUCT error */ -#line 594 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 594 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("abstract declarator '' used as declaration"); } @@ -2012,7 +2012,7 @@ yyparse (void) break; case 60: /* struct_exports: data_member ';' struct_exports */ -#line 603 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 603 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } @@ -2020,7 +2020,7 @@ yyparse (void) break; case 61: /* struct_exports: data_member */ -#line 607 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 607 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("';' missing after definition"); } @@ -2028,14 +2028,14 @@ yyparse (void) break; case 62: /* struct_exports: %empty */ -#line 611 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 611 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2035 "tars.tab.cpp" break; case 63: /* data_member: struct_type_id */ -#line 621 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 621 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2043,7 +2043,7 @@ yyparse (void) break; case 64: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id */ -#line 630 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 630 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2065,7 +2065,7 @@ yyparse (void) break; case 65: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id '=' const_initializer */ -#line 648 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 648 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2091,7 +2091,7 @@ yyparse (void) break; case 66: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id '=' const_initializer */ -#line 670 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 670 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2117,7 +2117,7 @@ yyparse (void) break; case 67: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id */ -#line 692 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 692 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2138,7 +2138,7 @@ yyparse (void) break; case 68: /* struct_type_id: TARS_REQUIRE type_id */ -#line 709 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 709 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } @@ -2146,7 +2146,7 @@ yyparse (void) break; case 69: /* struct_type_id: TARS_OPTIONAL type_id */ -#line 713 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 713 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } @@ -2154,7 +2154,7 @@ yyparse (void) break; case 70: /* struct_type_id: TARS_CONST_INTEGER type_id */ -#line 717 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 717 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'require' or 'optional'"); } @@ -2162,7 +2162,7 @@ yyparse (void) break; case 71: /* struct_type_id: type_id */ -#line 721 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 721 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag' or 'require' or 'optional'"); } @@ -2170,7 +2170,7 @@ yyparse (void) break; case 72: /* const_initializer: TARS_CONST_INTEGER */ -#line 730 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 730 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { IntergerGrammarPtr intVal = IntergerGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2184,7 +2184,7 @@ yyparse (void) break; case 73: /* const_initializer: TARS_CONST_FLOAT */ -#line 740 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 740 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { FloatGrammarPtr floatVal = FloatGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2198,7 +2198,7 @@ yyparse (void) break; case 74: /* const_initializer: TARS_STRING_LITERAL */ -#line 750 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 750 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2210,7 +2210,7 @@ yyparse (void) break; case 75: /* const_initializer: TARS_FALSE */ -#line 758 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 758 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2222,7 +2222,7 @@ yyparse (void) break; case 76: /* const_initializer: TARS_TRUE */ -#line 766 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 766 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2234,7 +2234,7 @@ yyparse (void) break; case 77: /* const_initializer: TARS_IDENTIFIER */ -#line 774 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 774 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2251,7 +2251,7 @@ yyparse (void) break; case 78: /* const_initializer: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 787 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 787 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2270,7 +2270,7 @@ yyparse (void) break; case 79: /* const_def: TARS_CONST type_id '=' const_initializer */ -#line 807 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 807 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!np) @@ -2287,7 +2287,7 @@ yyparse (void) break; case 80: /* type_id: type TARS_IDENTIFIER */ -#line 825 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 825 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2300,7 +2300,7 @@ yyparse (void) break; case 81: /* type_id: type TARS_IDENTIFIER '[' TARS_CONST_INTEGER ']' */ -#line 834 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 834 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-4])); IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast(yyvsp[-1]); @@ -2314,7 +2314,7 @@ yyparse (void) break; case 82: /* type_id: type '*' TARS_IDENTIFIER */ -#line 844 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 844 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-2])); //IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast($4); @@ -2328,7 +2328,7 @@ yyparse (void) break; case 83: /* type_id: type TARS_IDENTIFIER ':' TARS_CONST_INTEGER */ -#line 854 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 854 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-3]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2341,7 +2341,7 @@ yyparse (void) break; case 84: /* type_id: type keyword */ -#line 863 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 863 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as data member name"); @@ -2350,7 +2350,7 @@ yyparse (void) break; case 85: /* type_id: type */ -#line 868 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 868 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("missing data member name"); } @@ -2358,7 +2358,7 @@ yyparse (void) break; case 86: /* type_id: error */ -#line 872 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 872 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("unkown type"); } @@ -2366,7 +2366,7 @@ yyparse (void) break; case 87: /* type: type_no ':' TARS_CONST_INTEGER */ -#line 881 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 881 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-2]); @@ -2379,7 +2379,7 @@ yyparse (void) break; case 88: /* type: type_no */ -#line 890 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 890 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -2387,7 +2387,7 @@ yyparse (void) break; case 89: /* type: type_no ':' error */ -#line 894 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 894 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("array missing size"); } @@ -2395,7 +2395,7 @@ yyparse (void) break; case 90: /* type_no: TARS_BOOL */ -#line 903 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 903 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindBool); } @@ -2403,7 +2403,7 @@ yyparse (void) break; case 91: /* type_no: TARS_BYTE */ -#line 907 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 907 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindByte); } @@ -2411,7 +2411,7 @@ yyparse (void) break; case 92: /* type_no: TARS_UNSIGNED TARS_BYTE */ -#line 911 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 911 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort,true); } @@ -2419,7 +2419,7 @@ yyparse (void) break; case 93: /* type_no: TARS_SHORT */ -#line 915 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 915 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort); } @@ -2427,7 +2427,7 @@ yyparse (void) break; case 94: /* type_no: TARS_UNSIGNED TARS_SHORT */ -#line 919 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 919 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt,true); } @@ -2435,7 +2435,7 @@ yyparse (void) break; case 95: /* type_no: TARS_INT */ -#line 923 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 923 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt); } @@ -2443,7 +2443,7 @@ yyparse (void) break; case 96: /* type_no: TARS_UNSIGNED TARS_INT */ -#line 927 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 927 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong,true); } @@ -2451,7 +2451,7 @@ yyparse (void) break; case 97: /* type_no: TARS_LONG */ -#line 931 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 931 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong); } @@ -2459,7 +2459,7 @@ yyparse (void) break; case 98: /* type_no: TARS_FLOAT */ -#line 935 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 935 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindFloat); } @@ -2467,7 +2467,7 @@ yyparse (void) break; case 99: /* type_no: TARS_DOUBLE */ -#line 939 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 939 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindDouble); } @@ -2475,7 +2475,7 @@ yyparse (void) break; case 100: /* type_no: TARS_STRING */ -#line 943 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 943 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindString); } @@ -2483,7 +2483,7 @@ yyparse (void) break; case 101: /* type_no: vector */ -#line 947 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 947 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2491,7 +2491,7 @@ yyparse (void) break; case 102: /* type_no: map */ -#line 951 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 951 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2499,7 +2499,7 @@ yyparse (void) break; case 103: /* type_no: scoped_name */ -#line 955 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 955 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypePtr sp = g_parse->findUserType(ident->v); @@ -2516,7 +2516,7 @@ yyparse (void) break; case 104: /* vector: TARS_VECTOR '<' type '>' */ -#line 973 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 973 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createVector(TypePtr::dynamicCast(yyvsp[-1]))); } @@ -2524,7 +2524,7 @@ yyparse (void) break; case 105: /* vector: TARS_VECTOR '<' error */ -#line 977 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 977 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector error"); } @@ -2532,7 +2532,7 @@ yyparse (void) break; case 106: /* vector: TARS_VECTOR '<' type error */ -#line 981 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 981 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing '>'"); } @@ -2540,7 +2540,7 @@ yyparse (void) break; case 107: /* vector: TARS_VECTOR error */ -#line 985 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 985 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing type"); } @@ -2548,7 +2548,7 @@ yyparse (void) break; case 108: /* map: TARS_MAP '<' type ',' type '>' */ -#line 994 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 994 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createMap(TypePtr::dynamicCast(yyvsp[-3]), TypePtr::dynamicCast(yyvsp[-1]))); } @@ -2556,7 +2556,7 @@ yyparse (void) break; case 109: /* map: TARS_MAP '<' error */ -#line 998 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 998 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("map error"); } @@ -2564,14 +2564,14 @@ yyparse (void) break; case 110: /* scoped_name: TARS_IDENTIFIER */ -#line 1007 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1007 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2571 "tars.tab.cpp" break; case 111: /* scoped_name: TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1010 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1010 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ident->v = "::" + ident->v; @@ -2581,7 +2581,7 @@ yyparse (void) break; case 112: /* scoped_name: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1016 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1016 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2593,175 +2593,175 @@ yyparse (void) break; case 113: /* keyword: TARS_STRUCT */ -#line 1029 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1029 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2600 "tars.tab.cpp" break; case 114: /* keyword: TARS_VOID */ -#line 1032 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1032 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2607 "tars.tab.cpp" break; case 115: /* keyword: TARS_BOOL */ -#line 1035 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1035 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2614 "tars.tab.cpp" break; case 116: /* keyword: TARS_BYTE */ -#line 1038 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1038 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2621 "tars.tab.cpp" break; case 117: /* keyword: TARS_SHORT */ -#line 1041 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1041 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2628 "tars.tab.cpp" break; case 118: /* keyword: TARS_INT */ -#line 1044 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1044 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2635 "tars.tab.cpp" break; case 119: /* keyword: TARS_FLOAT */ -#line 1047 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1047 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2642 "tars.tab.cpp" break; case 120: /* keyword: TARS_DOUBLE */ -#line 1050 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1050 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2649 "tars.tab.cpp" break; case 121: /* keyword: TARS_STRING */ -#line 1053 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1053 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2656 "tars.tab.cpp" break; case 122: /* keyword: TARS_VECTOR */ -#line 1056 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1056 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2663 "tars.tab.cpp" break; case 123: /* keyword: TARS_KEY */ -#line 1059 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1059 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2670 "tars.tab.cpp" break; case 124: /* keyword: TARS_MAP */ -#line 1062 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1062 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2677 "tars.tab.cpp" break; case 125: /* keyword: TARS_NAMESPACE */ -#line 1065 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1065 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2684 "tars.tab.cpp" break; case 126: /* keyword: TARS_INTERFACE */ -#line 1068 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1068 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2691 "tars.tab.cpp" break; case 127: /* keyword: TARS_OUT */ -#line 1071 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1071 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2698 "tars.tab.cpp" break; case 128: /* keyword: TARS_REQUIRE */ -#line 1074 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1074 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2705 "tars.tab.cpp" break; case 129: /* keyword: TARS_OPTIONAL */ -#line 1077 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1077 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2712 "tars.tab.cpp" break; case 130: /* keyword: TARS_CONST_INTEGER */ -#line 1080 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1080 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2719 "tars.tab.cpp" break; case 131: /* keyword: TARS_CONST_FLOAT */ -#line 1083 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1083 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2726 "tars.tab.cpp" break; case 132: /* keyword: TARS_FALSE */ -#line 1086 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1086 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2733 "tars.tab.cpp" break; case 133: /* keyword: TARS_TRUE */ -#line 1089 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1089 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2740 "tars.tab.cpp" break; case 134: /* keyword: TARS_STRING_LITERAL */ -#line 1092 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1092 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2747 "tars.tab.cpp" break; case 135: /* keyword: TARS_CONST */ -#line 1095 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1095 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2754 "tars.tab.cpp" break; case 136: /* keyword: TARS_ENUM */ -#line 1098 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1098 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2761 "tars.tab.cpp" break; case 137: /* keyword: TARS_UNSIGNED */ -#line 1101 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1101 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2768 "tars.tab.cpp" @@ -2962,7 +2962,7 @@ yyparse (void) return yyresult; } -#line 1105 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1105 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" diff --git a/tools/tarsparse/tars.lex.cpp b/tools/tarsparse/tars.lex.cpp index f1d1280b..ab0f0635 100644 --- a/tools/tarsparse/tars.lex.cpp +++ b/tools/tarsparse/tars.lex.cpp @@ -511,7 +511,7 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 1 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" /** * Tencent is pleased to support the open source community by making Tars available. * @@ -527,7 +527,7 @@ char *yytext; * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -#line 20 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 20 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" #include #include #include @@ -776,7 +776,7 @@ YY_DECL } { -#line 67 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 67 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" #line 782 "tars.lex.cpp" @@ -848,12 +848,12 @@ YY_DECL case 1: YY_RULE_SETUP -#line 69 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 69 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" { BEGIN(INCL); } YY_BREAK case 2: YY_RULE_SETUP -#line 71 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 71 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" { if ( include_file_stack_ptr >= MAX_INCLUDE_DEPTH ) { @@ -886,7 +886,7 @@ YY_RULE_SETUP YY_BREAK case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INCL): -#line 101 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 101 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" { --include_file_stack_ptr; if ( include_file_stack_ptr < 0 ) @@ -905,14 +905,14 @@ case YY_STATE_EOF(INCL): YY_BREAK case 3: YY_RULE_SETUP -#line 117 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 117 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" { return TARS_SCOPE_DELIMITER; } YY_BREAK case 4: YY_RULE_SETUP -#line 121 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 121 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" { // C++ comment bool e = false; @@ -933,7 +933,7 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 139 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 139 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" { // C comment bool e = false; @@ -984,7 +984,7 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 187 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 187 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" { StringGrammarPtr ident = new StringGrammar; ident->v = yytext; @@ -995,7 +995,7 @@ YY_RULE_SETUP case 7: /* rule 7 can match eol */ YY_RULE_SETUP -#line 194 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 194 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" { StringGrammarPtr ident = new StringGrammar; ident->v = yytext; @@ -1008,7 +1008,7 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 204 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 204 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" { StringGrammarPtr str = new StringGrammar; bool e = false; @@ -1123,7 +1123,7 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 316 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 316 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" { errno = 0; IntergerGrammarPtr ptr = new IntergerGrammar; @@ -1148,7 +1148,7 @@ YY_RULE_SETUP YY_BREAK case 10: YY_RULE_SETUP -#line 338 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 338 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" { errno = 0; FloatGrammarPtr ptr = new FloatGrammar; @@ -1183,7 +1183,7 @@ YY_RULE_SETUP case 11: /* rule 11 can match eol */ YY_RULE_SETUP -#line 369 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 369 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" { if(yytext[0] == '\n') { @@ -1193,7 +1193,7 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 376 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 376 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" { if(yytext[0] < 32 || yytext[0] > 126) { @@ -1212,7 +1212,7 @@ YY_RULE_SETUP YY_BREAK case 13: YY_RULE_SETUP -#line 392 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 392 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" ECHO; YY_BREAK #line 1218 "tars.lex.cpp" @@ -2230,7 +2230,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 392 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.l" +#line 392 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" diff --git a/tools/tarsparse/tars.tab.cpp b/tools/tarsparse/tars.tab.cpp index 9fb66bc2..83215380 100644 --- a/tools/tarsparse/tars.tab.cpp +++ b/tools/tarsparse/tars.tab.cpp @@ -67,7 +67,7 @@ /* First part of user prologue. */ -#line 17 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 17 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" #include #include @@ -1384,14 +1384,14 @@ yyparse (void) switch (yyn) { case 3: /* $@1: %empty */ -#line 75 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 75 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1391 "tars.tab.cpp" break; case 5: /* $@2: %empty */ -#line 79 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 79 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyerrok; } @@ -1399,7 +1399,7 @@ yyparse (void) break; case 7: /* definitions: definition */ -#line 84 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 84 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } @@ -1407,14 +1407,14 @@ yyparse (void) break; case 8: /* definitions: %empty */ -#line 88 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 88 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1414 "tars.tab.cpp" break; case 9: /* definition: namespace_def */ -#line 96 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 96 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || NamespacePtr::dynamicCast(yyvsp[0])); } @@ -1422,7 +1422,7 @@ yyparse (void) break; case 10: /* definition: interface_def */ -#line 100 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 100 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || InterfacePtr::dynamicCast(yyvsp[0])); } @@ -1430,7 +1430,7 @@ yyparse (void) break; case 11: /* definition: struct_def */ -#line 104 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 104 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || StructPtr::dynamicCast(yyvsp[0])); } @@ -1438,14 +1438,14 @@ yyparse (void) break; case 12: /* definition: key_def */ -#line 108 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 108 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1445 "tars.tab.cpp" break; case 13: /* definition: enum_def */ -#line 111 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 111 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || EnumPtr::dynamicCast(yyvsp[0])); } @@ -1453,7 +1453,7 @@ yyparse (void) break; case 14: /* definition: const_def */ -#line 115 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 115 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || ConstPtr::dynamicCast(yyvsp[0])); } @@ -1461,7 +1461,7 @@ yyparse (void) break; case 15: /* @3: %empty */ -#line 124 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 124 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1469,7 +1469,7 @@ yyparse (void) break; case 16: /* enum_def: enum_id @3 '{' enumerator_list '}' */ -#line 128 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 128 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1487,7 +1487,7 @@ yyparse (void) break; case 17: /* enum_id: TARS_ENUM TARS_IDENTIFIER */ -#line 147 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 147 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { NamespacePtr c = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!c) @@ -1504,7 +1504,7 @@ yyparse (void) break; case 18: /* enum_id: TARS_ENUM keyword */ -#line 160 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 160 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumeration name"); @@ -1514,7 +1514,7 @@ yyparse (void) break; case 19: /* enumerator_list: enumerator ',' enumerator_list */ -#line 171 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 171 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[-1]; } @@ -1522,14 +1522,14 @@ yyparse (void) break; case 20: /* enumerator_list: enumerator */ -#line 175 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 175 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1529 "tars.tab.cpp" break; case 21: /* enumerator: TARS_IDENTIFIER */ -#line 183 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 183 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1544,7 +1544,7 @@ yyparse (void) break; case 22: /* enumerator: keyword */ -#line 194 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 194 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumerator"); @@ -1553,7 +1553,7 @@ yyparse (void) break; case 23: /* enumerator: TARS_IDENTIFIER '=' const_initializer */ -#line 199 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 199 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -1570,14 +1570,14 @@ yyparse (void) break; case 24: /* enumerator: %empty */ -#line 212 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 212 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1577 "tars.tab.cpp" break; case 25: /* @4: %empty */ -#line 220 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 220 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ContainerPtr c = g_parse->currentContainer(); @@ -1596,7 +1596,7 @@ yyparse (void) break; case 26: /* namespace_def: TARS_NAMESPACE TARS_IDENTIFIER @4 '{' definitions '}' */ -#line 235 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 235 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1612,7 +1612,7 @@ yyparse (void) break; case 27: /* $@5: %empty */ -#line 253 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 253 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-1]); StructPtr sp = StructPtr::dynamicCast(g_parse->findUserType(ident->v)); @@ -1627,14 +1627,14 @@ yyparse (void) break; case 28: /* key_def: TARS_KEY '[' scoped_name ',' $@5 key_members ']' */ -#line 264 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 264 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1634 "tars.tab.cpp" break; case 29: /* key_members: TARS_IDENTIFIER */ -#line 272 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 272 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1651,7 +1651,7 @@ yyparse (void) break; case 30: /* key_members: key_members ',' TARS_IDENTIFIER */ -#line 285 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 285 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1668,7 +1668,7 @@ yyparse (void) break; case 31: /* @6: %empty */ -#line 304 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 304 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1689,7 +1689,7 @@ yyparse (void) break; case 32: /* interface_def: interface_id @6 '{' interface_exports '}' */ -#line 321 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 321 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1705,7 +1705,7 @@ yyparse (void) break; case 33: /* interface_id: TARS_INTERFACE TARS_IDENTIFIER */ -#line 338 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 338 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1713,7 +1713,7 @@ yyparse (void) break; case 34: /* interface_id: TARS_INTERFACE keyword */ -#line 342 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 342 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as interface name"); @@ -1723,21 +1723,21 @@ yyparse (void) break; case 35: /* interface_exports: interface_export ';' interface_exports */ -#line 353 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 353 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1730 "tars.tab.cpp" break; case 36: /* interface_exports: error ';' interface_exports */ -#line 356 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 356 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1737 "tars.tab.cpp" break; case 37: /* interface_exports: interface_export */ -#line 359 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 359 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } @@ -1745,14 +1745,14 @@ yyparse (void) break; case 38: /* interface_exports: %empty */ -#line 363 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 363 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1752 "tars.tab.cpp" break; case 40: /* operation: operation_preamble parameters ')' */ -#line 377 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 377 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1768,7 +1768,7 @@ yyparse (void) break; case 41: /* operation_preamble: return_type TARS_OP */ -#line 394 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 394 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1796,7 +1796,7 @@ yyparse (void) break; case 43: /* return_type: TARS_VOID */ -#line 424 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 424 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = 0; } @@ -1804,14 +1804,14 @@ yyparse (void) break; case 44: /* parameters: %empty */ -#line 434 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 434 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 1811 "tars.tab.cpp" break; case 45: /* parameters: type_id */ -#line 437 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 437 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1826,7 +1826,7 @@ yyparse (void) break; case 46: /* parameters: parameters ',' type_id */ -#line 448 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 448 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1841,7 +1841,7 @@ yyparse (void) break; case 47: /* parameters: out_qualifier type_id */ -#line 459 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 459 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1857,7 +1857,7 @@ yyparse (void) break; case 48: /* parameters: parameters ',' out_qualifier type_id */ -#line 471 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 471 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1873,7 +1873,7 @@ yyparse (void) break; case 49: /* parameters: routekey_qualifier type_id */ -#line 483 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 483 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1889,7 +1889,7 @@ yyparse (void) break; case 50: /* parameters: parameters ',' routekey_qualifier type_id */ -#line 495 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 495 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1905,7 +1905,7 @@ yyparse (void) break; case 51: /* parameters: out_qualifier */ -#line 507 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 507 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("'out' must be defined with a type"); } @@ -1913,7 +1913,7 @@ yyparse (void) break; case 52: /* parameters: routekey_qualifier */ -#line 511 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 511 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("'routekey' must be defined with a type"); } @@ -1921,7 +1921,7 @@ yyparse (void) break; case 53: /* routekey_qualifier: TARS_ROUTE_KEY */ -#line 520 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 520 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr routekey = new BoolGrammar; routekey->v = true; @@ -1931,7 +1931,7 @@ yyparse (void) break; case 54: /* out_qualifier: TARS_OUT */ -#line 531 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 531 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr out = new BoolGrammar; out->v = true; @@ -1941,7 +1941,7 @@ yyparse (void) break; case 55: /* @7: %empty */ -#line 542 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 542 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); @@ -1967,7 +1967,7 @@ yyparse (void) break; case 56: /* struct_def: struct_id @7 '{' struct_exports '}' */ -#line 564 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 564 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1986,7 +1986,7 @@ yyparse (void) break; case 57: /* struct_id: TARS_STRUCT TARS_IDENTIFIER */ -#line 584 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 584 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1994,7 +1994,7 @@ yyparse (void) break; case 58: /* struct_id: TARS_STRUCT keyword */ -#line 588 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 588 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2004,7 +2004,7 @@ yyparse (void) break; case 59: /* struct_id: TARS_STRUCT error */ -#line 594 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 594 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("abstract declarator '' used as declaration"); } @@ -2012,7 +2012,7 @@ yyparse (void) break; case 60: /* struct_exports: data_member ';' struct_exports */ -#line 603 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 603 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } @@ -2020,7 +2020,7 @@ yyparse (void) break; case 61: /* struct_exports: data_member */ -#line 607 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 607 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("';' missing after definition"); } @@ -2028,14 +2028,14 @@ yyparse (void) break; case 62: /* struct_exports: %empty */ -#line 611 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 611 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2035 "tars.tab.cpp" break; case 63: /* data_member: struct_type_id */ -#line 621 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 621 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2043,7 +2043,7 @@ yyparse (void) break; case 64: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id */ -#line 630 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 630 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2065,7 +2065,7 @@ yyparse (void) break; case 65: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id '=' const_initializer */ -#line 648 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 648 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2091,7 +2091,7 @@ yyparse (void) break; case 66: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id '=' const_initializer */ -#line 670 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 670 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2117,7 +2117,7 @@ yyparse (void) break; case 67: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id */ -#line 692 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 692 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2138,7 +2138,7 @@ yyparse (void) break; case 68: /* struct_type_id: TARS_REQUIRE type_id */ -#line 709 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 709 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } @@ -2146,7 +2146,7 @@ yyparse (void) break; case 69: /* struct_type_id: TARS_OPTIONAL type_id */ -#line 713 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 713 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } @@ -2154,7 +2154,7 @@ yyparse (void) break; case 70: /* struct_type_id: TARS_CONST_INTEGER type_id */ -#line 717 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 717 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'require' or 'optional'"); } @@ -2162,7 +2162,7 @@ yyparse (void) break; case 71: /* struct_type_id: type_id */ -#line 721 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 721 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag' or 'require' or 'optional'"); } @@ -2170,7 +2170,7 @@ yyparse (void) break; case 72: /* const_initializer: TARS_CONST_INTEGER */ -#line 730 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 730 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { IntergerGrammarPtr intVal = IntergerGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2184,7 +2184,7 @@ yyparse (void) break; case 73: /* const_initializer: TARS_CONST_FLOAT */ -#line 740 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 740 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { FloatGrammarPtr floatVal = FloatGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2198,7 +2198,7 @@ yyparse (void) break; case 74: /* const_initializer: TARS_STRING_LITERAL */ -#line 750 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 750 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2210,7 +2210,7 @@ yyparse (void) break; case 75: /* const_initializer: TARS_FALSE */ -#line 758 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 758 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2222,7 +2222,7 @@ yyparse (void) break; case 76: /* const_initializer: TARS_TRUE */ -#line 766 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 766 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2234,7 +2234,7 @@ yyparse (void) break; case 77: /* const_initializer: TARS_IDENTIFIER */ -#line 774 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 774 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2251,7 +2251,7 @@ yyparse (void) break; case 78: /* const_initializer: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 787 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 787 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2270,7 +2270,7 @@ yyparse (void) break; case 79: /* const_def: TARS_CONST type_id '=' const_initializer */ -#line 807 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 807 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!np) @@ -2287,7 +2287,7 @@ yyparse (void) break; case 80: /* type_id: type TARS_IDENTIFIER */ -#line 825 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 825 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2300,7 +2300,7 @@ yyparse (void) break; case 81: /* type_id: type TARS_IDENTIFIER '[' TARS_CONST_INTEGER ']' */ -#line 834 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 834 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-4])); IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast(yyvsp[-1]); @@ -2314,7 +2314,7 @@ yyparse (void) break; case 82: /* type_id: type '*' TARS_IDENTIFIER */ -#line 844 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 844 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-2])); //IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast($4); @@ -2328,7 +2328,7 @@ yyparse (void) break; case 83: /* type_id: type TARS_IDENTIFIER ':' TARS_CONST_INTEGER */ -#line 854 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 854 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-3]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2341,7 +2341,7 @@ yyparse (void) break; case 84: /* type_id: type keyword */ -#line 863 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 863 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as data member name"); @@ -2350,7 +2350,7 @@ yyparse (void) break; case 85: /* type_id: type */ -#line 868 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 868 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("missing data member name"); } @@ -2358,7 +2358,7 @@ yyparse (void) break; case 86: /* type_id: error */ -#line 872 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 872 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("unkown type"); } @@ -2366,7 +2366,7 @@ yyparse (void) break; case 87: /* type: type_no ':' TARS_CONST_INTEGER */ -#line 881 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 881 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-2]); @@ -2379,7 +2379,7 @@ yyparse (void) break; case 88: /* type: type_no */ -#line 890 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 890 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -2387,7 +2387,7 @@ yyparse (void) break; case 89: /* type: type_no ':' error */ -#line 894 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 894 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("array missing size"); } @@ -2395,7 +2395,7 @@ yyparse (void) break; case 90: /* type_no: TARS_BOOL */ -#line 903 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 903 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindBool); } @@ -2403,7 +2403,7 @@ yyparse (void) break; case 91: /* type_no: TARS_BYTE */ -#line 907 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 907 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindByte); } @@ -2411,7 +2411,7 @@ yyparse (void) break; case 92: /* type_no: TARS_UNSIGNED TARS_BYTE */ -#line 911 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 911 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort,true); } @@ -2419,7 +2419,7 @@ yyparse (void) break; case 93: /* type_no: TARS_SHORT */ -#line 915 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 915 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort); } @@ -2427,7 +2427,7 @@ yyparse (void) break; case 94: /* type_no: TARS_UNSIGNED TARS_SHORT */ -#line 919 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 919 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt,true); } @@ -2435,7 +2435,7 @@ yyparse (void) break; case 95: /* type_no: TARS_INT */ -#line 923 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 923 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt); } @@ -2443,7 +2443,7 @@ yyparse (void) break; case 96: /* type_no: TARS_UNSIGNED TARS_INT */ -#line 927 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 927 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong,true); } @@ -2451,7 +2451,7 @@ yyparse (void) break; case 97: /* type_no: TARS_LONG */ -#line 931 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 931 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong); } @@ -2459,7 +2459,7 @@ yyparse (void) break; case 98: /* type_no: TARS_FLOAT */ -#line 935 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 935 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindFloat); } @@ -2467,7 +2467,7 @@ yyparse (void) break; case 99: /* type_no: TARS_DOUBLE */ -#line 939 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 939 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindDouble); } @@ -2475,7 +2475,7 @@ yyparse (void) break; case 100: /* type_no: TARS_STRING */ -#line 943 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 943 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindString); } @@ -2483,7 +2483,7 @@ yyparse (void) break; case 101: /* type_no: vector */ -#line 947 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 947 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2491,7 +2491,7 @@ yyparse (void) break; case 102: /* type_no: map */ -#line 951 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 951 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2499,7 +2499,7 @@ yyparse (void) break; case 103: /* type_no: scoped_name */ -#line 955 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 955 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypePtr sp = g_parse->findUserType(ident->v); @@ -2516,7 +2516,7 @@ yyparse (void) break; case 104: /* vector: TARS_VECTOR '<' type '>' */ -#line 973 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 973 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createVector(TypePtr::dynamicCast(yyvsp[-1]))); } @@ -2524,7 +2524,7 @@ yyparse (void) break; case 105: /* vector: TARS_VECTOR '<' error */ -#line 977 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 977 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector error"); } @@ -2532,7 +2532,7 @@ yyparse (void) break; case 106: /* vector: TARS_VECTOR '<' type error */ -#line 981 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 981 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing '>'"); } @@ -2540,7 +2540,7 @@ yyparse (void) break; case 107: /* vector: TARS_VECTOR error */ -#line 985 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 985 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing type"); } @@ -2548,7 +2548,7 @@ yyparse (void) break; case 108: /* map: TARS_MAP '<' type ',' type '>' */ -#line 994 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 994 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createMap(TypePtr::dynamicCast(yyvsp[-3]), TypePtr::dynamicCast(yyvsp[-1]))); } @@ -2556,7 +2556,7 @@ yyparse (void) break; case 109: /* map: TARS_MAP '<' error */ -#line 998 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 998 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("map error"); } @@ -2564,14 +2564,14 @@ yyparse (void) break; case 110: /* scoped_name: TARS_IDENTIFIER */ -#line 1007 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1007 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2571 "tars.tab.cpp" break; case 111: /* scoped_name: TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1010 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1010 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ident->v = "::" + ident->v; @@ -2581,7 +2581,7 @@ yyparse (void) break; case 112: /* scoped_name: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1016 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1016 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2593,175 +2593,175 @@ yyparse (void) break; case 113: /* keyword: TARS_STRUCT */ -#line 1029 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1029 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2600 "tars.tab.cpp" break; case 114: /* keyword: TARS_VOID */ -#line 1032 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1032 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2607 "tars.tab.cpp" break; case 115: /* keyword: TARS_BOOL */ -#line 1035 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1035 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2614 "tars.tab.cpp" break; case 116: /* keyword: TARS_BYTE */ -#line 1038 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1038 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2621 "tars.tab.cpp" break; case 117: /* keyword: TARS_SHORT */ -#line 1041 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1041 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2628 "tars.tab.cpp" break; case 118: /* keyword: TARS_INT */ -#line 1044 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1044 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2635 "tars.tab.cpp" break; case 119: /* keyword: TARS_FLOAT */ -#line 1047 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1047 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2642 "tars.tab.cpp" break; case 120: /* keyword: TARS_DOUBLE */ -#line 1050 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1050 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2649 "tars.tab.cpp" break; case 121: /* keyword: TARS_STRING */ -#line 1053 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1053 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2656 "tars.tab.cpp" break; case 122: /* keyword: TARS_VECTOR */ -#line 1056 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1056 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2663 "tars.tab.cpp" break; case 123: /* keyword: TARS_KEY */ -#line 1059 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1059 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2670 "tars.tab.cpp" break; case 124: /* keyword: TARS_MAP */ -#line 1062 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1062 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2677 "tars.tab.cpp" break; case 125: /* keyword: TARS_NAMESPACE */ -#line 1065 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1065 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2684 "tars.tab.cpp" break; case 126: /* keyword: TARS_INTERFACE */ -#line 1068 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1068 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2691 "tars.tab.cpp" break; case 127: /* keyword: TARS_OUT */ -#line 1071 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1071 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2698 "tars.tab.cpp" break; case 128: /* keyword: TARS_REQUIRE */ -#line 1074 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1074 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2705 "tars.tab.cpp" break; case 129: /* keyword: TARS_OPTIONAL */ -#line 1077 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1077 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2712 "tars.tab.cpp" break; case 130: /* keyword: TARS_CONST_INTEGER */ -#line 1080 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1080 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2719 "tars.tab.cpp" break; case 131: /* keyword: TARS_CONST_FLOAT */ -#line 1083 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1083 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2726 "tars.tab.cpp" break; case 132: /* keyword: TARS_FALSE */ -#line 1086 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1086 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2733 "tars.tab.cpp" break; case 133: /* keyword: TARS_TRUE */ -#line 1089 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1089 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2740 "tars.tab.cpp" break; case 134: /* keyword: TARS_STRING_LITERAL */ -#line 1092 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1092 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2747 "tars.tab.cpp" break; case 135: /* keyword: TARS_CONST */ -#line 1095 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1095 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2754 "tars.tab.cpp" break; case 136: /* keyword: TARS_ENUM */ -#line 1098 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1098 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2761 "tars.tab.cpp" break; case 137: /* keyword: TARS_UNSIGNED */ -#line 1101 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1101 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" { } #line 2768 "tars.tab.cpp" @@ -2962,7 +2962,7 @@ yyparse (void) return yyresult; } -#line 1105 "/Users/jarod/windows-TarsCpp/tools/tarsgrammar/tars.y" +#line 1105 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" From 98dc06f2c86de0edf6c3379fa234fbc630eb312b Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Fri, 23 Feb 2024 12:21:58 +0800 Subject: [PATCH 57/81] use TARS_STD_SHARED_PTR --- cmake/Common.cmake | 10 +++++----- servant/libservant/EndpointManager.cpp | 10 +++++----- servant/libservant/ServantHelper.cpp | 2 +- servant/servant/Global.h | 2 +- tools/tars2cpp/tars2cpp.cpp | 8 ++++---- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cmake/Common.cmake b/cmake/Common.cmake index 073708c2..cffdcc40 100755 --- a/cmake/Common.cmake +++ b/cmake/Common.cmake @@ -11,10 +11,10 @@ IF (CMAKE_BUILD_TYPE STREQUAL "") ENDIF() -# 设置一个选项,用于控制是否定义 BUILD_STD_SHARED_PTR 宏 -option(USE_STD_SHARED_PTR "Use std::shared_ptr instead of tars::AutoPtr" OFF) -if(USE_STD_SHARED_PTR) - add_definitions(-DBUILD_STD_SHARED_PTR) +# 设置一个选项,用于控制是否定义 TARS_STD_SHARED_PTR 宏 +option(TARS_STD_SHARED_PTR "Use std::shared_ptr instead of tars::AutoPtr" OFF) +if(TARS_STD_SHARED_PTR) + add_definitions(-DTARS_STD_SHARED_PTR) endif() @@ -126,6 +126,6 @@ message("BIN: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") message("TARS2CPP: ${TARS2CPP}") #message("TARS_OPENTRACKING: ${TARS_OPENTRACKING}") message("ONLY_LIB: ${ONLY_LIB}" ) -message("USE_STD_SHARED_PTR: ${USE_STD_SHARED_PTR}" ) +message("TARS_STD_SHARED_PTR: ${TARS_STD_SHARED_PTR}" ) #------------------------------------------------------------- diff --git a/servant/libservant/EndpointManager.cpp b/servant/libservant/EndpointManager.cpp index 95ef5b18..caca5e24 100644 --- a/servant/libservant/EndpointManager.cpp +++ b/servant/libservant/EndpointManager.cpp @@ -429,7 +429,7 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) { case E_ALL: { -#if USE_STD_SHARED_PTR +#if TARS_STD_SHARED_PTR _queryFPrx->async_findObjectById4Any(shared_from_this(),_objName, _communicator->getClientConfig().Context); #else _queryFPrx->async_findObjectById4Any(this,_objName, _communicator->getClientConfig().Context); @@ -438,7 +438,7 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) } case E_STATION: { -#if USE_STD_SHARED_PTR +#if TARS_STD_SHARED_PTR _queryFPrx->async_findObjectByIdInSameStation(shared_from_this(),_objName,sName, _communicator->getClientConfig().Context); #else _queryFPrx->async_findObjectByIdInSameStation(this,_objName,sName, _communicator->getClientConfig().Context); @@ -447,7 +447,7 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) } case E_SET: { -#if USE_STD_SHARED_PTR +#if TARS_STD_SHARED_PTR _queryFPrx->async_findObjectByIdInSameSet(shared_from_this(),_objName,sName, _communicator->getClientConfig().Context); #else _queryFPrx->async_findObjectByIdInSameSet(this,_objName,sName, _communicator->getClientConfig().Context); @@ -461,7 +461,7 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) { //指定set调用时,指定set的优先级最高 string setId = _invokeSetId.empty()?_communicator->getClientConfig().SetDivision:_invokeSetId; -#if USE_STD_SHARED_PTR +#if TARS_STD_SHARED_PTR _queryFPrx->async_findObjectByIdInSameSet(shared_from_this(),_objName,setId, _communicator->getClientConfig().Context); #else _queryFPrx->async_findObjectByIdInSameSet(this,_objName,setId, _communicator->getClientConfig().Context); @@ -469,7 +469,7 @@ void QueryEpBase::refreshReg(GetEndpointType type, const string & sName) } else { -#if USE_STD_SHARED_PTR +#if TARS_STD_SHARED_PTR _queryFPrx->async_findObjectByIdInSameGroup(shared_from_this(),_objName, _communicator->getClientConfig().Context); #else _queryFPrx->async_findObjectByIdInSameGroup(this,_objName, _communicator->getClientConfig().Context); diff --git a/servant/libservant/ServantHelper.cpp b/servant/libservant/ServantHelper.cpp index 37d09e1a..5642a6ed 100644 --- a/servant/libservant/ServantHelper.cpp +++ b/servant/libservant/ServantHelper.cpp @@ -47,7 +47,7 @@ ServantPtr ServantHelperManager::create(const string &sAdapter) //根据adapter查找servant名称 string s = _adapter_servant[sAdapter]; -#ifdef BUILD_STD_SHARED_PTR +#ifdef TARS_STD_SHARED_PTR if(_servant_ptr.find(s) != _servant_ptr.end()) { ServantPtr ptr = _servant_ptr[s]; diff --git a/servant/servant/Global.h b/servant/servant/Global.h index 2a397437..4d483f2b 100755 --- a/servant/servant/Global.h +++ b/servant/servant/Global.h @@ -67,7 +67,7 @@ typedef TC_AutoPtr CommunicatorPtr; typedef TC_AutoPtr ServantPrx; typedef TC_AutoPtr StatFPrx; -#ifdef BUILD_STD_SHARED_PTR +#ifdef TARS_STD_SHARED_PTR typedef std::shared_ptr ServantProxyCallbackPtr; typedef std::shared_ptr ObjectPrx; diff --git a/tools/tars2cpp/tars2cpp.cpp b/tools/tars2cpp/tars2cpp.cpp index 84993bd2..5c714f67 100755 --- a/tools/tars2cpp/tars2cpp.cpp +++ b/tools/tars2cpp/tars2cpp.cpp @@ -2785,7 +2785,7 @@ string Tars2Cpp::generateHPromiseAsync(const InterfacePtr &pInter, const Operati DEL_TAB; s << TAB << "};" << endl; s << TAB << endl; -#ifdef BUILD_STD_SHARED_PTR +#ifdef TARS_STD_SHARED_PTR s << TAB << "typedef std::shared_ptr< " << pInter->getId() << "PrxCallbackPromise::Promise" << sStruct << " > Promise" << sStruct << "Ptr;" << endl; #else s << TAB << "typedef tars::TC_AutoPtr< " << pInter->getId() << "PrxCallbackPromise::Promise" << sStruct << " > Promise" << sStruct << "Ptr;" << endl; @@ -2996,7 +2996,7 @@ string Tars2Cpp::generateH(const InterfacePtr &pPtr, const NamespacePtr &nPtr) c DEL_TAB; s << TAB << "};" << endl; -#ifdef BUILD_STD_SHARED_PTR +#ifdef TARS_STD_SHARED_PTR s << TAB << "typedef std::shared_ptr<" << pPtr->getId() << "PrxCallback> " << pPtr->getId() << "PrxCallbackPtr;" << endl; #else s << TAB << "typedef tars::TC_AutoPtr<" << pPtr->getId() << "PrxCallback> " << pPtr->getId() << "PrxCallbackPtr;" << endl; @@ -3060,7 +3060,7 @@ string Tars2Cpp::generateH(const InterfacePtr &pPtr, const NamespacePtr &nPtr) c DEL_TAB; s << TAB << "};" << endl; -#ifdef BUILD_STD_SHARED_PTR +#ifdef TARS_STD_SHARED_PTR s << TAB << "typedef std::shared_ptr<" << pPtr->getId() << "PrxCallbackPromise> " << pPtr->getId() << "PrxCallbackPromisePtr;" << endl; #else s << TAB << "typedef tars::TC_AutoPtr<" << pPtr->getId() << "PrxCallbackPromise> " << pPtr->getId() << "PrxCallbackPromisePtr;" << endl; @@ -3151,7 +3151,7 @@ string Tars2Cpp::generateH(const InterfacePtr &pPtr, const NamespacePtr &nPtr) c DEL_TAB; s << TAB << "};" << endl; -#ifdef BUILD_STD_SHARED_PTR +#ifdef TARS_STD_SHARED_PTR s << TAB << "typedef std::shared_ptr<" << pPtr->getId() << "CoroPrxCallback> " << pPtr->getId() << "CoroPrxCallbackPtr;" << endl; #else s << TAB << "typedef tars::TC_AutoPtr<" << pPtr->getId() << "CoroPrxCallback> " << pPtr->getId() << "CoroPrxCallbackPtr;" << endl; From e0f1a47b84e3cc7bdcc53b0b98981f0f42cdb434 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Mon, 26 Feb 2024 16:17:10 +0800 Subject: [PATCH 58/81] unit-test support TARS_SHARED_PTR --- examples/AuthDemo/Client/main.cpp | 2 +- .../CoroutineDemo/BServer/BServantImp.cpp | 12 +++--- .../CoroutineDemo/testParallelCoro/main.cpp | 8 ++-- examples/CustomDemo/CustomClient/main.cpp | 2 +- examples/PushCallbackDemo/Client/main.cpp | 5 ++- .../PushDemo/PushClient/TestRecvThread.cpp | 4 +- .../HelloServer/Client/main.cpp | 4 +- .../ProxyServer/Server/ProxyImp.cpp | 2 +- examples/UdpDemo/Client/main.cpp | 2 +- unit-test/hello_test.cpp | 40 ++++++++++--------- unit-test/hello_test.h | 4 +- unit-test/rpc/test_async_rpc.cpp | 2 +- unit-test/rpc/test_push.cpp | 10 ++--- unit-test/rpc/test_win_server.cpp | 4 +- unit-test/server/HelloImp.cpp | 2 +- unit-test/server/TranImp.cpp | 2 +- 16 files changed, 56 insertions(+), 49 deletions(-) diff --git a/examples/AuthDemo/Client/main.cpp b/examples/AuthDemo/Client/main.cpp index 7dd8af15..7aa02564 100644 --- a/examples/AuthDemo/Client/main.cpp +++ b/examples/AuthDemo/Client/main.cpp @@ -106,7 +106,7 @@ void asyncCall(int c) //发起远程调用 for (int i = 0; i < c; ++i) { - HelloPrxCallbackPtr p = new HelloCallback(t, i, c); + HelloPrxCallbackPtr p(new HelloCallback(t, i, c)); try { diff --git a/examples/CoroutineDemo/BServer/BServantImp.cpp b/examples/CoroutineDemo/BServer/BServantImp.cpp index 0c13df20..830026e7 100644 --- a/examples/CoroutineDemo/BServer/BServantImp.cpp +++ b/examples/CoroutineDemo/BServer/BServantImp.cpp @@ -66,7 +66,7 @@ class AServantCoroCallback : public AServantCoroPrxCallback int _iOut; string _sOut; }; -typedef tars::TC_AutoPtr AServantCoroCallbackPtr; +// typedef tars::TC_AutoPtr AServantCoroCallbackPtr; int BServantImp::test(tars::TarsCurrentPtr current) { return 0;} @@ -111,21 +111,21 @@ tars::Int32 BServantImp::testCoroParallel(const std::string& sIn, std::string &s int iIn = 5; - CoroParallelBasePtr sharedPtr = new CoroParallelBase(2); + CoroParallelBasePtr sharedPtr(new CoroParallelBase(2)); - AServantCoroCallbackPtr cb1 = new AServantCoroCallback(); + AServantCoroPrxCallbackPtr cb1(new AServantCoroCallback()); cb1->setCoroParallelBasePtr(sharedPtr); _pPrx->coro_testInt(cb1, iIn); - AServantCoroCallbackPtr cb2 = new AServantCoroCallback(); + AServantCoroPrxCallbackPtr cb2(new AServantCoroCallback()); cb2->setCoroParallelBasePtr(sharedPtr); _pPrx->coro_testStr(cb2, sIn); coroWhenAll(sharedPtr); - if(cb1->_iRet == 0 && cb2->_iRet == 0) + if(((AServantCoroCallback*)(cb1.get()))->_iRet == 0 && ((AServantCoroCallback*)(cb2.get()))->_iRet == 0) { - sOut = cb2->_sOut; + sOut = ((AServantCoroCallback*)(cb2.get()))->_sOut; iRet = 0; } diff --git a/examples/CoroutineDemo/testParallelCoro/main.cpp b/examples/CoroutineDemo/testParallelCoro/main.cpp index 10faca07..5937cf23 100644 --- a/examples/CoroutineDemo/testParallelCoro/main.cpp +++ b/examples/CoroutineDemo/testParallelCoro/main.cpp @@ -55,7 +55,7 @@ class BServantCoroCallback : public BServantCoroPrxCallback int _iOut; string _sOut; }; -typedef tars::TC_AutoPtr BServantCoroCallbackPtr; +// typedef tars::TC_AutoPtr BServantCoroCallbackPtr; //////////////////////////////////////////// //继承框架的协程类 @@ -93,11 +93,11 @@ void TestCoroutine::handle() { CoroParallelBasePtr sharedPtr = new CoroParallelBase(2); - BServantCoroCallbackPtr cb1 = new BServantCoroCallback(); + BServantCoroPrxCallbackPtr cb1(new BServantCoroCallback()); cb1->setCoroParallelBasePtr(sharedPtr); _prx->coro_testCoroSerial(cb1, sIn); - BServantCoroCallbackPtr cb2 = new BServantCoroCallback(); + BServantCoroPrxCallbackPtr cb2(new BServantCoroCallback()); cb2->setCoroParallelBasePtr(sharedPtr); _prx->coro_testCoroParallel(cb2, sIn); @@ -105,7 +105,7 @@ void TestCoroutine::handle() // cout << "ret1:" << cb1->_sOut << "|ret2:" << cb2->_sOut << endl; - if(cb1->_iRet == 0 && cb2->_iRet == 0 && cb1->_iException == 0 && cb2->_iException == 0) + if(((BServantCoroCallback*)(cb1.get()))->_iRet == 0 && ((BServantCoroCallback*)(cb2.get()))->_iRet == 0 && ((BServantCoroCallback*)(cb1.get()))->_iException == 0 && ((BServantCoroCallback*)(cb2.get()))->_iException == 0) { ++sum; } diff --git a/examples/CustomDemo/CustomClient/main.cpp b/examples/CustomDemo/CustomClient/main.cpp index 5e5eb3fb..f5f4afdb 100644 --- a/examples/CustomDemo/CustomClient/main.cpp +++ b/examples/CustomDemo/CustomClient/main.cpp @@ -158,7 +158,7 @@ void asyncCall(int c) { try { - CustomCallBackPtr cb = new CustomCallBack(); + ServantProxyCallbackPtr cb(new CustomCallBack()); param.servantPrx->rpc_call_async(param.servantPrx->tars_gen_requestid(), "doCustomFunc", buffer.c_str(), buffer.length(), cb); } catch(exception& e) diff --git a/examples/PushCallbackDemo/Client/main.cpp b/examples/PushCallbackDemo/Client/main.cpp index 8b8d5f7b..8b19e3d4 100644 --- a/examples/PushCallbackDemo/Client/main.cpp +++ b/examples/PushCallbackDemo/Client/main.cpp @@ -61,7 +61,10 @@ int main(int argc, char *argv[]) _comm->setProperty(conf); HelloPrx pPrx = _comm->stringToProxy(helloObj); - pPrx->tars_set_push_callback(new PushCallbackImp()); + + ServantProxyCallbackPtr cbPush(new PushCallbackImp()); + + pPrx->tars_set_push_callback(cbPush); pPrx->registerPush(); while(g_count < 10) diff --git a/examples/PushDemo/PushClient/TestRecvThread.cpp b/examples/PushDemo/PushClient/TestRecvThread.cpp index 3a820d03..a3e30f02 100755 --- a/examples/PushDemo/PushClient/TestRecvThread.cpp +++ b/examples/PushDemo/PushClient/TestRecvThread.cpp @@ -127,7 +127,7 @@ RecvThread::RecvThread(int second):_second(second), _bTerminate(false) void RecvThread::run(void) { - TestPushCallBackPtr cbPush = new TestPushCallBack(); + ServantProxyCallbackPtr cbPush(new TestPushCallBack()); _prx->tars_set_push_callback(cbPush); string buf("heartbeat"); @@ -139,7 +139,7 @@ void RecvThread::run(void) { try { - TestPushCallBackPtr cb = new TestPushCallBack(); + ServantProxyCallbackPtr cb(new TestPushCallBack()); _prx->rpc_call_async(_prx->tars_gen_requestid(), "printResult", buf.c_str(), buf.length(), cb); } catch(TarsException& e) diff --git a/examples/QuickStartDemo/HelloServer/Client/main.cpp b/examples/QuickStartDemo/HelloServer/Client/main.cpp index bb25b8b6..ff868261 100644 --- a/examples/QuickStartDemo/HelloServer/Client/main.cpp +++ b/examples/QuickStartDemo/HelloServer/Client/main.cpp @@ -114,7 +114,7 @@ void asyncCall(int c) //发起远程调用 for (int i = 0; i < c; ++i) { - HelloPrxCallbackPtr p = new HelloCallback(t, i, c); + HelloPrxCallbackPtr p(new HelloCallback(t, i, c)); try { @@ -263,7 +263,7 @@ void asyncTupCall(int c) vector buff; req.encode(buff); - ServantProxyCallbackPtr p = new TupCallback(t, i, c); + ServantProxyCallbackPtr p(new TupCallback(t, i, c)); param.pPrx->rpc_call_async(req.getRequestId(), "testHello", buff.data(), buff.size(), p); } diff --git a/examples/QuickStartDemo/ProxyServer/Server/ProxyImp.cpp b/examples/QuickStartDemo/ProxyServer/Server/ProxyImp.cpp index 1cfc1905..ca18509e 100644 --- a/examples/QuickStartDemo/ProxyServer/Server/ProxyImp.cpp +++ b/examples/QuickStartDemo/ProxyServer/Server/ProxyImp.cpp @@ -68,7 +68,7 @@ tars::Int32 ProxyImp::testProxy(const std::string& sIn, std::string &sOut, tars: { current->setResponse(false); - TestApp::HelloPrxCallbackPtr cb = new HelloCallback(current); + TestApp::HelloPrxCallbackPtr cb(new HelloCallback(current)); _prx->tars_set_timeout(3000)->async_testHello(cb,sIn); } diff --git a/examples/UdpDemo/Client/main.cpp b/examples/UdpDemo/Client/main.cpp index 4d466b19..41da543b 100644 --- a/examples/UdpDemo/Client/main.cpp +++ b/examples/UdpDemo/Client/main.cpp @@ -111,7 +111,7 @@ void asyncCall(int c) if(request_count - callback_count < 100) { i++; request_count++; - HelloPrxCallbackPtr p = new HelloCallback(t, i, c); + HelloPrxCallbackPtr p(new HelloCallback(t, i, c)); try { param.pPrx->async_testHello(p, buffer); } diff --git a/unit-test/hello_test.cpp b/unit-test/hello_test.cpp index 32d684f1..f21e4161 100755 --- a/unit-test/hello_test.cpp +++ b/unit-test/hello_test.cpp @@ -278,7 +278,7 @@ void HelloTest::asyncCustom(Communicator *comm, const string &adapter) //发起远程调用 for (int j = 0; j < _count; ++j) { - CustomCallBackPtr cb = new CustomCallBack(callback_count); + ServantProxyCallbackPtr cb(new CustomCallBack(callback_count)); prx->rpc_call_async(prx->tars_gen_requestid(), "doCustomFunc", _buffer.c_str(), _buffer.length(), cb); } @@ -297,7 +297,8 @@ void HelloTest::testPush(Communicator *comm, const string &adapter) prx->tars_set_protocol(prot); - PushCallBackPtr cbPush = new PushCallBack(); + PushCallBack *c = new PushCallBack(); + ServantProxyCallbackPtr cbPush(c); prx->tars_set_push_callback(cbPush); string buf("heartbeat"); @@ -305,20 +306,22 @@ void HelloTest::testPush(Communicator *comm, const string &adapter) int count = 2; while(count-- > 0) { - cbPush->_onconnect = false; - cbPush->_onclose = false; + c->_onconnect = false; + c->_onclose = false; - PushCallBackPtr cb = new PushCallBack(); + PushCallBack *cNew = new PushCallBack(); + + ServantProxyCallbackPtr cb(cNew); prx->rpc_call_async(prx->tars_gen_requestid(), "printResult", buf.c_str(), buf.length(), cb); wait(1000); - ASSERT_TRUE(cbPush->_onconnect); - ASSERT_TRUE(cb->_onprintresult); + ASSERT_TRUE(cNew->_onconnect); + ASSERT_TRUE(cNew->_onprintresult); wait(10000); - ASSERT_TRUE(cbPush->_onclose); + ASSERT_TRUE(c->_onclose); } } @@ -333,24 +336,25 @@ void HelloTest::testReconnect(Communicator *comm, const string &adapter ) prx->tars_set_protocol(prot); prx->tars_reconnect(1); - PushCallBackPtr cbPush = new PushCallBack(); + PushCallBack *c = new PushCallBack(); + ServantProxyCallbackPtr cbPush(c); prx->tars_set_push_callback(cbPush); string buf("heartbeat"); - cbPush->_onconnect = false; - cbPush->_onclose = false; + c->_onconnect = false; + c->_onclose = false; ResponsePacket rsp; prx->rpc_call(prx->tars_gen_requestid(), "printResult", buf.c_str(), buf.length(), rsp); TC_Common::msleep(10500); - ASSERT_TRUE(cbPush->_onclose); + ASSERT_TRUE(c->_onclose); TC_Common::msleep(2000); - ASSERT_TRUE(cbPush->_onconnect); + ASSERT_TRUE(c->_onconnect); } @@ -493,7 +497,7 @@ void HelloTest::checkASyncOnce(HelloPrx prx) atomic callback_count{0}; - HelloPrxCallbackPtr p = new ClientHelloCallback(prx, callback_count); + HelloPrxCallbackPtr p(new ClientHelloCallback(prx, callback_count)); prx->async_testHello(p, 0, _buffer); @@ -548,7 +552,7 @@ void HelloTest::checkASync(Communicator *comm, const string &adapter) //发起远程调用 for (int j = 0; j < _count; ++j) { - HelloPrxCallbackPtr p = new ClientHelloCallback(TC_Common::now2us(), j, _count, _buffer, callback_count); + HelloPrxCallbackPtr p(new ClientHelloCallback(TC_Common::now2us(), j, _count, _buffer, callback_count)); prx->async_testHello(p, j, _buffer); } @@ -647,7 +651,7 @@ void HelloTest::checkTransASyncASync(Communicator *comm) //发起远程调用 for (int j = 0; j < _count; ++j) { - HelloPrxCallbackPtr p = new ClientHelloCallback(TC_Common::now2us(), j, _count, _buffer, callback_count); + HelloPrxCallbackPtr p(new ClientHelloCallback(TC_Common::now2us(), j, _count, _buffer, callback_count)); prx->async_testTrans(p, j, _buffer); } @@ -689,7 +693,7 @@ void HelloTest::checkTransASyncSync(Communicator *comm) //发起远程调用 for (int j = 0; j < _count; ++j) { - HelloPrxCallbackPtr p = new ClientHelloCallback(TC_Common::now2us(), j, _count, _buffer, callback_count); + HelloPrxCallbackPtr p(new ClientHelloCallback(TC_Common::now2us(), j, _count, _buffer, callback_count)); prx->async_testSyncTrans(p, j, _buffer); } @@ -806,7 +810,7 @@ void HelloTest::checkASyncTimeout(Communicator *comm) std::atomic callback_count; ClientHelloCallback *c = new ClientHelloCallback(TC_Common::now2us(), 0, _count, _buffer, callback_count); - HelloPrxCallbackPtr p = c; + HelloPrxCallbackPtr p(c); prx->async_testTimeout(p, 1); diff --git a/unit-test/hello_test.h b/unit-test/hello_test.h index 57d10c5b..683a174a 100755 --- a/unit-test/hello_test.h +++ b/unit-test/hello_test.h @@ -58,7 +58,7 @@ class PushCallBack : public ServantProxyCallback }; -typedef tars::TC_AutoPtr PushCallBackPtr; +// typedef tars::TC_AutoPtr PushCallBackPtr; struct ClientHelloCallback : public HelloPrxCallback { @@ -185,7 +185,7 @@ class CustomCallBack : public ServantProxyCallback std::atomic &callback_count; }; -typedef tars::TC_AutoPtr CustomCallBackPtr; +// typedef tars::TC_AutoPtr CustomCallBackPtr; class HelloTest : public testing::Test { diff --git a/unit-test/rpc/test_async_rpc.cpp b/unit-test/rpc/test_async_rpc.cpp index 0ddf7662..ace19ec2 100755 --- a/unit-test/rpc/test_async_rpc.cpp +++ b/unit-test/rpc/test_async_rpc.cpp @@ -126,7 +126,7 @@ TEST_F(HelloTest, rpcASyncThreadFinish) //发起远程调用 for (int j = 0; j < count; ++j) { - HelloPrxCallbackPtr p = new ClientHelloCallback(TC_Common::now2us(), j, count, _buffer, callback_count); + HelloPrxCallbackPtr p(new ClientHelloCallback(TC_Common::now2us(), j, count, _buffer, callback_count)); prx->async_testHello(p, j, _buffer); } diff --git a/unit-test/rpc/test_push.cpp b/unit-test/rpc/test_push.cpp index 62f7db0e..3b837c86 100755 --- a/unit-test/rpc/test_push.cpp +++ b/unit-test/rpc/test_push.cpp @@ -59,7 +59,7 @@ TEST_F(HelloTest, push) HelloPrx prx = comm->stringToProxy(obj); - RegisterPushCallBackPtr callback = new RegisterPushCallBack(); + ServantProxyCallbackPtr callback(new RegisterPushCallBack()); prx->tars_set_push_callback(callback); @@ -69,7 +69,7 @@ TEST_F(HelloTest, push) TC_Common::msleep(50); - ASSERT_TRUE(callback->_msg == msg); + ASSERT_TRUE(((RegisterPushCallBack*)callback.get())->_msg == msg); stopServer(ws); } @@ -86,7 +86,7 @@ TEST_F(HelloTest, pushClose) HelloPrx prx = comm->stringToProxy(obj); - RegisterPushCallBackPtr callback = new RegisterPushCallBack(); + ServantProxyCallbackPtr callback(new RegisterPushCallBack); prx->tars_set_push_callback(callback); @@ -96,13 +96,13 @@ TEST_F(HelloTest, pushClose) TC_Common::msleep(50); - ASSERT_TRUE(callback->_msg == msg); + ASSERT_TRUE(((RegisterPushCallBack*)callback.get())->_msg == msg); prx->tars_close(); TC_Common::msleep(50); - ASSERT_TRUE(callback->_close); + ASSERT_TRUE(((RegisterPushCallBack*)callback.get())->_close); stopServer(ws); } diff --git a/unit-test/rpc/test_win_server.cpp b/unit-test/rpc/test_win_server.cpp index ecbe99f6..fb85e6d5 100644 --- a/unit-test/rpc/test_win_server.cpp +++ b/unit-test/rpc/test_win_server.cpp @@ -109,8 +109,8 @@ TEST_F(HelloTest, winServerAsync) //发起远程调用 for (int j = 0; j < _count; ++j) { - HelloPrxCallbackPtr p = new ClientHelloCallback(TC_Common::now2us(), j, _count, _buffer, - callback_count); + HelloPrxCallbackPtr p(new ClientHelloCallback(TC_Common::now2us(), j, _count, _buffer, + callback_count)); prx->async_testHello(p, j, _buffer); } diff --git a/unit-test/server/HelloImp.cpp b/unit-test/server/HelloImp.cpp index cbd82829..8e17e0ad 100755 --- a/unit-test/server/HelloImp.cpp +++ b/unit-test/server/HelloImp.cpp @@ -61,7 +61,7 @@ int HelloImp::testTrans(int index, const string &s, string &r, CurrentPtr curren { current->setResponse(false); - HelloPrxCallbackPtr p = new HelloCallback(current, index, s); + HelloPrxCallbackPtr p(new HelloCallback(current, index, s)); _helloPrx->async_testHello(p, index, s); } diff --git a/unit-test/server/TranImp.cpp b/unit-test/server/TranImp.cpp index f36d7a0e..4fd56ab7 100755 --- a/unit-test/server/TranImp.cpp +++ b/unit-test/server/TranImp.cpp @@ -32,7 +32,7 @@ void TranImp::async_call(tars::CurrentPtr current, vector &response) TLOGDEBUG("async_call: begin remote call, req len:" << req.sBuffer.size() << endl); /*a-sync-call*/ - ServantProxyCallbackPtr cb = new ServantCallback("ServantCallback", this, current); + ServantProxyCallbackPtr cb(new ServantCallback("ServantCallback", this, current)); _servantPrx->rpc_call_async(req.iRequestId, req.sFuncName, request.data(), request.size(), cb); current->setResponse(false); } From 97b407d6d65320b49ee47c03fccf4ccb7870f3da Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Mon, 26 Feb 2024 21:21:20 +0800 Subject: [PATCH 59/81] fix tars-tools.cmake CMAKE_CXX_FLAGS_RELEASE&CMAKE_CXX_FLAGS_DEBUG --- servant/makefile/tars-tools.cmake.in | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/servant/makefile/tars-tools.cmake.in b/servant/makefile/tars-tools.cmake.in index eb0d0259..2d34cf7e 100755 --- a/servant/makefile/tars-tools.cmake.in +++ b/servant/makefile/tars-tools.cmake.in @@ -64,8 +64,8 @@ IF (UNIX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fsigned-char -std=c++11 -Wno-deprecated -fno-strict-aliasing -Wno-overloaded-virtual") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-builtin-macro-redefined") - set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -Wall -g") - set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -Wall -fno-strict-aliasing") + set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -Wall -g") + set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O2 -Wall -fno-strict-aliasing") set(PLATFORM "linux") IF (APPLE) @@ -78,7 +78,7 @@ IF (UNIX) ELSEIF (WIN32) set(PLATFORM "window") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 /wd4101 /wd4244 /wd4996 /wd4091 /wd4503 /wd4819 /wd4200 /wd4800 /wd4267 /wd4251 /wd4275") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 /wd4101 /wd4244 /wd4996 /wd4091 /wd4503 /wd4819 /wd4200 /wd4800 /wd4267 /wd4251 /wd4275 /bigobj") SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO") @@ -89,7 +89,8 @@ ELSEIF (WIN32) SET(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /DEBUG") SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /OPT:ICF /OPT:REF /DEBUG") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj") +# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj") +# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /bigobj") ELSE () MESSAGE(STATUS "================ ERROR: This platform is unsupported!!! ================") From e56623c4f8c584e5827f3ce31e52b022c7fb50b8 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 29 Feb 2024 14:31:23 +0800 Subject: [PATCH 60/81] feat: tc_socket: getLocalHosts support withLoopIp --- servant/libservant/Application.cpp | 11 +- servant/libservant/Communicator.cpp | 10 +- servant/libservant/EndpointInfo.cpp | 28 +-- tools/tarsgrammar/tars.tab.cpp | 266 +++++++++++++------------- tools/tarsparse/tars.lex.cpp | 36 ++-- tools/tarsparse/tars.tab.cpp | 266 +++++++++++++------------- util/include/util/tc_socket.h | 5 +- util/include/util/tc_uuid_generator.h | 4 +- util/src/tc_file.cpp | 1 + util/src/tc_socket.cpp | 52 +---- 10 files changed, 311 insertions(+), 368 deletions(-) diff --git a/servant/libservant/Application.cpp b/servant/libservant/Application.cpp index d1066611..e7e24578 100644 --- a/servant/libservant/Application.cpp +++ b/servant/libservant/Application.cpp @@ -1297,17 +1297,12 @@ void Application::initializeServer() if (ServerConfig::LocalIp.empty()) { // ServerConfig::LocalIp = "127.0.0.1"; - vector v = TC_Socket::getLocalHosts(); + vector v = TC_Socket::getLocalHosts(AF_INET, false); ServerConfig::LocalIp = "127.0.0.1"; - //获取第一个非127.0.0.1的IP - for(const auto & i : v) + if(!v.empty()) { - if(i != "127.0.0.1") - { - ServerConfig::LocalIp = i; - break; - } + ServerConfig::LocalIp = v[0]; } } diff --git a/servant/libservant/Communicator.cpp b/servant/libservant/Communicator.cpp index 0160ad32..bb0d5f65 100644 --- a/servant/libservant/Communicator.cpp +++ b/servant/libservant/Communicator.cpp @@ -267,13 +267,13 @@ void Communicator::initialize() if (_clientConfig.SetLocalIp.empty()) { - vector v = TC_Socket::getLocalHosts(); + vector v = TC_Socket::getLocalHosts(AF_INET, false); + if (_clientConfig.LocalIp.empty() && !v.empty()) + { + _clientConfig.LocalIp = v[0]; + } for (size_t i = 0; i < v.size(); i++) { - if (v[i] != "127.0.0.1" && _clientConfig.LocalIp.empty()) - { - _clientConfig.LocalIp = v[i]; - } _clientConfig.SetLocalIp.insert(v[i]); } } diff --git a/servant/libservant/EndpointInfo.cpp b/servant/libservant/EndpointInfo.cpp index 0804caa9..01f74962 100755 --- a/servant/libservant/EndpointInfo.cpp +++ b/servant/libservant/EndpointInfo.cpp @@ -98,15 +98,10 @@ vector EndpointInfo::toEndpointFs(const TC_Endpoint &ep, const string if (host == "0.0.0.0") { vector v; - vector ips = TC_Socket::getLocalHosts(AF_INET); + vector ips = TC_Socket::getLocalHosts(AF_INET, false); for(const auto &ip : ips) { - if(ip == "127.0.0.1") - { - continue; - } - TC_Endpoint theEp = ep; theEp.setHost(ip); @@ -118,15 +113,10 @@ vector EndpointInfo::toEndpointFs(const TC_Endpoint &ep, const string else if (host == "::1") { vector v; - vector ips = TC_Socket::getLocalHosts(AF_INET6); + vector ips = TC_Socket::getLocalHosts(AF_INET6, false); for(const auto &ip : ips) { - if(ip == "::1") - { - continue; - } - TC_Endpoint theEp = ep; theEp.setHost(ip); @@ -139,15 +129,10 @@ vector EndpointInfo::toEndpointFs(const TC_Endpoint &ep, const string { vector v; { - vector ips = TC_Socket::getLocalHosts(AF_INET); + vector ips = TC_Socket::getLocalHosts(AF_INET, false); for (const auto &ip: ips) { - if (ip == "127.0.0.1") - { - continue; - } - TC_Endpoint theEp = ep; theEp.setHost(ip); @@ -156,15 +141,10 @@ vector EndpointInfo::toEndpointFs(const TC_Endpoint &ep, const string } { - vector ips = TC_Socket::getLocalHosts(AF_INET6); + vector ips = TC_Socket::getLocalHosts(AF_INET6, false); for (const auto &ip: ips) { - if (ip == "::1") - { - continue; - } - TC_Endpoint theEp = ep; theEp.setHost(ip); diff --git a/tools/tarsgrammar/tars.tab.cpp b/tools/tarsgrammar/tars.tab.cpp index 83215380..869dd6a2 100644 --- a/tools/tarsgrammar/tars.tab.cpp +++ b/tools/tarsgrammar/tars.tab.cpp @@ -67,7 +67,7 @@ /* First part of user prologue. */ -#line 17 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 17 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" #include #include @@ -1384,14 +1384,14 @@ yyparse (void) switch (yyn) { case 3: /* $@1: %empty */ -#line 75 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 75 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1391 "tars.tab.cpp" break; case 5: /* $@2: %empty */ -#line 79 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 79 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyerrok; } @@ -1399,7 +1399,7 @@ yyparse (void) break; case 7: /* definitions: definition */ -#line 84 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 84 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } @@ -1407,14 +1407,14 @@ yyparse (void) break; case 8: /* definitions: %empty */ -#line 88 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 88 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1414 "tars.tab.cpp" break; case 9: /* definition: namespace_def */ -#line 96 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 96 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || NamespacePtr::dynamicCast(yyvsp[0])); } @@ -1422,7 +1422,7 @@ yyparse (void) break; case 10: /* definition: interface_def */ -#line 100 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 100 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || InterfacePtr::dynamicCast(yyvsp[0])); } @@ -1430,7 +1430,7 @@ yyparse (void) break; case 11: /* definition: struct_def */ -#line 104 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 104 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || StructPtr::dynamicCast(yyvsp[0])); } @@ -1438,14 +1438,14 @@ yyparse (void) break; case 12: /* definition: key_def */ -#line 108 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 108 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1445 "tars.tab.cpp" break; case 13: /* definition: enum_def */ -#line 111 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 111 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || EnumPtr::dynamicCast(yyvsp[0])); } @@ -1453,7 +1453,7 @@ yyparse (void) break; case 14: /* definition: const_def */ -#line 115 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 115 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || ConstPtr::dynamicCast(yyvsp[0])); } @@ -1461,7 +1461,7 @@ yyparse (void) break; case 15: /* @3: %empty */ -#line 124 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 124 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1469,7 +1469,7 @@ yyparse (void) break; case 16: /* enum_def: enum_id @3 '{' enumerator_list '}' */ -#line 128 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 128 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1487,7 +1487,7 @@ yyparse (void) break; case 17: /* enum_id: TARS_ENUM TARS_IDENTIFIER */ -#line 147 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 147 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { NamespacePtr c = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!c) @@ -1504,7 +1504,7 @@ yyparse (void) break; case 18: /* enum_id: TARS_ENUM keyword */ -#line 160 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 160 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumeration name"); @@ -1514,7 +1514,7 @@ yyparse (void) break; case 19: /* enumerator_list: enumerator ',' enumerator_list */ -#line 171 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 171 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[-1]; } @@ -1522,14 +1522,14 @@ yyparse (void) break; case 20: /* enumerator_list: enumerator */ -#line 175 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 175 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1529 "tars.tab.cpp" break; case 21: /* enumerator: TARS_IDENTIFIER */ -#line 183 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 183 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1544,7 +1544,7 @@ yyparse (void) break; case 22: /* enumerator: keyword */ -#line 194 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 194 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumerator"); @@ -1553,7 +1553,7 @@ yyparse (void) break; case 23: /* enumerator: TARS_IDENTIFIER '=' const_initializer */ -#line 199 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 199 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -1570,14 +1570,14 @@ yyparse (void) break; case 24: /* enumerator: %empty */ -#line 212 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 212 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1577 "tars.tab.cpp" break; case 25: /* @4: %empty */ -#line 220 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 220 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ContainerPtr c = g_parse->currentContainer(); @@ -1596,7 +1596,7 @@ yyparse (void) break; case 26: /* namespace_def: TARS_NAMESPACE TARS_IDENTIFIER @4 '{' definitions '}' */ -#line 235 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 235 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1612,7 +1612,7 @@ yyparse (void) break; case 27: /* $@5: %empty */ -#line 253 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 253 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-1]); StructPtr sp = StructPtr::dynamicCast(g_parse->findUserType(ident->v)); @@ -1627,14 +1627,14 @@ yyparse (void) break; case 28: /* key_def: TARS_KEY '[' scoped_name ',' $@5 key_members ']' */ -#line 264 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 264 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1634 "tars.tab.cpp" break; case 29: /* key_members: TARS_IDENTIFIER */ -#line 272 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 272 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1651,7 +1651,7 @@ yyparse (void) break; case 30: /* key_members: key_members ',' TARS_IDENTIFIER */ -#line 285 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 285 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1668,7 +1668,7 @@ yyparse (void) break; case 31: /* @6: %empty */ -#line 304 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 304 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1689,7 +1689,7 @@ yyparse (void) break; case 32: /* interface_def: interface_id @6 '{' interface_exports '}' */ -#line 321 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 321 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1705,7 +1705,7 @@ yyparse (void) break; case 33: /* interface_id: TARS_INTERFACE TARS_IDENTIFIER */ -#line 338 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 338 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1713,7 +1713,7 @@ yyparse (void) break; case 34: /* interface_id: TARS_INTERFACE keyword */ -#line 342 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 342 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as interface name"); @@ -1723,21 +1723,21 @@ yyparse (void) break; case 35: /* interface_exports: interface_export ';' interface_exports */ -#line 353 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 353 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1730 "tars.tab.cpp" break; case 36: /* interface_exports: error ';' interface_exports */ -#line 356 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 356 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1737 "tars.tab.cpp" break; case 37: /* interface_exports: interface_export */ -#line 359 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 359 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } @@ -1745,14 +1745,14 @@ yyparse (void) break; case 38: /* interface_exports: %empty */ -#line 363 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 363 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1752 "tars.tab.cpp" break; case 40: /* operation: operation_preamble parameters ')' */ -#line 377 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 377 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1768,7 +1768,7 @@ yyparse (void) break; case 41: /* operation_preamble: return_type TARS_OP */ -#line 394 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 394 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1796,7 +1796,7 @@ yyparse (void) break; case 43: /* return_type: TARS_VOID */ -#line 424 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 424 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = 0; } @@ -1804,14 +1804,14 @@ yyparse (void) break; case 44: /* parameters: %empty */ -#line 434 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 434 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1811 "tars.tab.cpp" break; case 45: /* parameters: type_id */ -#line 437 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 437 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1826,7 +1826,7 @@ yyparse (void) break; case 46: /* parameters: parameters ',' type_id */ -#line 448 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 448 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1841,7 +1841,7 @@ yyparse (void) break; case 47: /* parameters: out_qualifier type_id */ -#line 459 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 459 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1857,7 +1857,7 @@ yyparse (void) break; case 48: /* parameters: parameters ',' out_qualifier type_id */ -#line 471 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 471 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1873,7 +1873,7 @@ yyparse (void) break; case 49: /* parameters: routekey_qualifier type_id */ -#line 483 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 483 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1889,7 +1889,7 @@ yyparse (void) break; case 50: /* parameters: parameters ',' routekey_qualifier type_id */ -#line 495 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 495 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1905,7 +1905,7 @@ yyparse (void) break; case 51: /* parameters: out_qualifier */ -#line 507 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 507 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("'out' must be defined with a type"); } @@ -1913,7 +1913,7 @@ yyparse (void) break; case 52: /* parameters: routekey_qualifier */ -#line 511 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 511 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("'routekey' must be defined with a type"); } @@ -1921,7 +1921,7 @@ yyparse (void) break; case 53: /* routekey_qualifier: TARS_ROUTE_KEY */ -#line 520 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 520 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr routekey = new BoolGrammar; routekey->v = true; @@ -1931,7 +1931,7 @@ yyparse (void) break; case 54: /* out_qualifier: TARS_OUT */ -#line 531 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 531 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr out = new BoolGrammar; out->v = true; @@ -1941,7 +1941,7 @@ yyparse (void) break; case 55: /* @7: %empty */ -#line 542 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 542 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); @@ -1967,7 +1967,7 @@ yyparse (void) break; case 56: /* struct_def: struct_id @7 '{' struct_exports '}' */ -#line 564 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 564 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1986,7 +1986,7 @@ yyparse (void) break; case 57: /* struct_id: TARS_STRUCT TARS_IDENTIFIER */ -#line 584 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 584 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1994,7 +1994,7 @@ yyparse (void) break; case 58: /* struct_id: TARS_STRUCT keyword */ -#line 588 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 588 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2004,7 +2004,7 @@ yyparse (void) break; case 59: /* struct_id: TARS_STRUCT error */ -#line 594 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 594 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("abstract declarator '' used as declaration"); } @@ -2012,7 +2012,7 @@ yyparse (void) break; case 60: /* struct_exports: data_member ';' struct_exports */ -#line 603 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 603 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } @@ -2020,7 +2020,7 @@ yyparse (void) break; case 61: /* struct_exports: data_member */ -#line 607 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 607 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("';' missing after definition"); } @@ -2028,14 +2028,14 @@ yyparse (void) break; case 62: /* struct_exports: %empty */ -#line 611 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 611 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2035 "tars.tab.cpp" break; case 63: /* data_member: struct_type_id */ -#line 621 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 621 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2043,7 +2043,7 @@ yyparse (void) break; case 64: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id */ -#line 630 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 630 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2065,7 +2065,7 @@ yyparse (void) break; case 65: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id '=' const_initializer */ -#line 648 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 648 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2091,7 +2091,7 @@ yyparse (void) break; case 66: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id '=' const_initializer */ -#line 670 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 670 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2117,7 +2117,7 @@ yyparse (void) break; case 67: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id */ -#line 692 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 692 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2138,7 +2138,7 @@ yyparse (void) break; case 68: /* struct_type_id: TARS_REQUIRE type_id */ -#line 709 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 709 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } @@ -2146,7 +2146,7 @@ yyparse (void) break; case 69: /* struct_type_id: TARS_OPTIONAL type_id */ -#line 713 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 713 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } @@ -2154,7 +2154,7 @@ yyparse (void) break; case 70: /* struct_type_id: TARS_CONST_INTEGER type_id */ -#line 717 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 717 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'require' or 'optional'"); } @@ -2162,7 +2162,7 @@ yyparse (void) break; case 71: /* struct_type_id: type_id */ -#line 721 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 721 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag' or 'require' or 'optional'"); } @@ -2170,7 +2170,7 @@ yyparse (void) break; case 72: /* const_initializer: TARS_CONST_INTEGER */ -#line 730 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 730 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { IntergerGrammarPtr intVal = IntergerGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2184,7 +2184,7 @@ yyparse (void) break; case 73: /* const_initializer: TARS_CONST_FLOAT */ -#line 740 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 740 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { FloatGrammarPtr floatVal = FloatGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2198,7 +2198,7 @@ yyparse (void) break; case 74: /* const_initializer: TARS_STRING_LITERAL */ -#line 750 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 750 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2210,7 +2210,7 @@ yyparse (void) break; case 75: /* const_initializer: TARS_FALSE */ -#line 758 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 758 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2222,7 +2222,7 @@ yyparse (void) break; case 76: /* const_initializer: TARS_TRUE */ -#line 766 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 766 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2234,7 +2234,7 @@ yyparse (void) break; case 77: /* const_initializer: TARS_IDENTIFIER */ -#line 774 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 774 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2251,7 +2251,7 @@ yyparse (void) break; case 78: /* const_initializer: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 787 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 787 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2270,7 +2270,7 @@ yyparse (void) break; case 79: /* const_def: TARS_CONST type_id '=' const_initializer */ -#line 807 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 807 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!np) @@ -2287,7 +2287,7 @@ yyparse (void) break; case 80: /* type_id: type TARS_IDENTIFIER */ -#line 825 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 825 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2300,7 +2300,7 @@ yyparse (void) break; case 81: /* type_id: type TARS_IDENTIFIER '[' TARS_CONST_INTEGER ']' */ -#line 834 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 834 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-4])); IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast(yyvsp[-1]); @@ -2314,7 +2314,7 @@ yyparse (void) break; case 82: /* type_id: type '*' TARS_IDENTIFIER */ -#line 844 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 844 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-2])); //IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast($4); @@ -2328,7 +2328,7 @@ yyparse (void) break; case 83: /* type_id: type TARS_IDENTIFIER ':' TARS_CONST_INTEGER */ -#line 854 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 854 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-3]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2341,7 +2341,7 @@ yyparse (void) break; case 84: /* type_id: type keyword */ -#line 863 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 863 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as data member name"); @@ -2350,7 +2350,7 @@ yyparse (void) break; case 85: /* type_id: type */ -#line 868 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 868 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("missing data member name"); } @@ -2358,7 +2358,7 @@ yyparse (void) break; case 86: /* type_id: error */ -#line 872 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 872 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("unkown type"); } @@ -2366,7 +2366,7 @@ yyparse (void) break; case 87: /* type: type_no ':' TARS_CONST_INTEGER */ -#line 881 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 881 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-2]); @@ -2379,7 +2379,7 @@ yyparse (void) break; case 88: /* type: type_no */ -#line 890 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 890 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -2387,7 +2387,7 @@ yyparse (void) break; case 89: /* type: type_no ':' error */ -#line 894 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 894 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("array missing size"); } @@ -2395,7 +2395,7 @@ yyparse (void) break; case 90: /* type_no: TARS_BOOL */ -#line 903 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 903 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindBool); } @@ -2403,7 +2403,7 @@ yyparse (void) break; case 91: /* type_no: TARS_BYTE */ -#line 907 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 907 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindByte); } @@ -2411,7 +2411,7 @@ yyparse (void) break; case 92: /* type_no: TARS_UNSIGNED TARS_BYTE */ -#line 911 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 911 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort,true); } @@ -2419,7 +2419,7 @@ yyparse (void) break; case 93: /* type_no: TARS_SHORT */ -#line 915 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 915 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort); } @@ -2427,7 +2427,7 @@ yyparse (void) break; case 94: /* type_no: TARS_UNSIGNED TARS_SHORT */ -#line 919 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 919 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt,true); } @@ -2435,7 +2435,7 @@ yyparse (void) break; case 95: /* type_no: TARS_INT */ -#line 923 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 923 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt); } @@ -2443,7 +2443,7 @@ yyparse (void) break; case 96: /* type_no: TARS_UNSIGNED TARS_INT */ -#line 927 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 927 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong,true); } @@ -2451,7 +2451,7 @@ yyparse (void) break; case 97: /* type_no: TARS_LONG */ -#line 931 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 931 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong); } @@ -2459,7 +2459,7 @@ yyparse (void) break; case 98: /* type_no: TARS_FLOAT */ -#line 935 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 935 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindFloat); } @@ -2467,7 +2467,7 @@ yyparse (void) break; case 99: /* type_no: TARS_DOUBLE */ -#line 939 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 939 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindDouble); } @@ -2475,7 +2475,7 @@ yyparse (void) break; case 100: /* type_no: TARS_STRING */ -#line 943 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 943 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindString); } @@ -2483,7 +2483,7 @@ yyparse (void) break; case 101: /* type_no: vector */ -#line 947 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 947 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2491,7 +2491,7 @@ yyparse (void) break; case 102: /* type_no: map */ -#line 951 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 951 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2499,7 +2499,7 @@ yyparse (void) break; case 103: /* type_no: scoped_name */ -#line 955 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 955 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypePtr sp = g_parse->findUserType(ident->v); @@ -2516,7 +2516,7 @@ yyparse (void) break; case 104: /* vector: TARS_VECTOR '<' type '>' */ -#line 973 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 973 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createVector(TypePtr::dynamicCast(yyvsp[-1]))); } @@ -2524,7 +2524,7 @@ yyparse (void) break; case 105: /* vector: TARS_VECTOR '<' error */ -#line 977 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 977 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector error"); } @@ -2532,7 +2532,7 @@ yyparse (void) break; case 106: /* vector: TARS_VECTOR '<' type error */ -#line 981 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 981 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing '>'"); } @@ -2540,7 +2540,7 @@ yyparse (void) break; case 107: /* vector: TARS_VECTOR error */ -#line 985 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 985 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing type"); } @@ -2548,7 +2548,7 @@ yyparse (void) break; case 108: /* map: TARS_MAP '<' type ',' type '>' */ -#line 994 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 994 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createMap(TypePtr::dynamicCast(yyvsp[-3]), TypePtr::dynamicCast(yyvsp[-1]))); } @@ -2556,7 +2556,7 @@ yyparse (void) break; case 109: /* map: TARS_MAP '<' error */ -#line 998 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 998 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("map error"); } @@ -2564,14 +2564,14 @@ yyparse (void) break; case 110: /* scoped_name: TARS_IDENTIFIER */ -#line 1007 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1007 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2571 "tars.tab.cpp" break; case 111: /* scoped_name: TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1010 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1010 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ident->v = "::" + ident->v; @@ -2581,7 +2581,7 @@ yyparse (void) break; case 112: /* scoped_name: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1016 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1016 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2593,175 +2593,175 @@ yyparse (void) break; case 113: /* keyword: TARS_STRUCT */ -#line 1029 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1029 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2600 "tars.tab.cpp" break; case 114: /* keyword: TARS_VOID */ -#line 1032 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1032 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2607 "tars.tab.cpp" break; case 115: /* keyword: TARS_BOOL */ -#line 1035 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1035 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2614 "tars.tab.cpp" break; case 116: /* keyword: TARS_BYTE */ -#line 1038 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1038 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2621 "tars.tab.cpp" break; case 117: /* keyword: TARS_SHORT */ -#line 1041 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1041 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2628 "tars.tab.cpp" break; case 118: /* keyword: TARS_INT */ -#line 1044 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1044 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2635 "tars.tab.cpp" break; case 119: /* keyword: TARS_FLOAT */ -#line 1047 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1047 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2642 "tars.tab.cpp" break; case 120: /* keyword: TARS_DOUBLE */ -#line 1050 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1050 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2649 "tars.tab.cpp" break; case 121: /* keyword: TARS_STRING */ -#line 1053 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1053 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2656 "tars.tab.cpp" break; case 122: /* keyword: TARS_VECTOR */ -#line 1056 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1056 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2663 "tars.tab.cpp" break; case 123: /* keyword: TARS_KEY */ -#line 1059 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1059 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2670 "tars.tab.cpp" break; case 124: /* keyword: TARS_MAP */ -#line 1062 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1062 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2677 "tars.tab.cpp" break; case 125: /* keyword: TARS_NAMESPACE */ -#line 1065 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1065 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2684 "tars.tab.cpp" break; case 126: /* keyword: TARS_INTERFACE */ -#line 1068 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1068 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2691 "tars.tab.cpp" break; case 127: /* keyword: TARS_OUT */ -#line 1071 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1071 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2698 "tars.tab.cpp" break; case 128: /* keyword: TARS_REQUIRE */ -#line 1074 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1074 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2705 "tars.tab.cpp" break; case 129: /* keyword: TARS_OPTIONAL */ -#line 1077 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1077 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2712 "tars.tab.cpp" break; case 130: /* keyword: TARS_CONST_INTEGER */ -#line 1080 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1080 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2719 "tars.tab.cpp" break; case 131: /* keyword: TARS_CONST_FLOAT */ -#line 1083 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1083 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2726 "tars.tab.cpp" break; case 132: /* keyword: TARS_FALSE */ -#line 1086 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1086 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2733 "tars.tab.cpp" break; case 133: /* keyword: TARS_TRUE */ -#line 1089 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1089 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2740 "tars.tab.cpp" break; case 134: /* keyword: TARS_STRING_LITERAL */ -#line 1092 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1092 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2747 "tars.tab.cpp" break; case 135: /* keyword: TARS_CONST */ -#line 1095 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1095 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2754 "tars.tab.cpp" break; case 136: /* keyword: TARS_ENUM */ -#line 1098 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1098 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2761 "tars.tab.cpp" break; case 137: /* keyword: TARS_UNSIGNED */ -#line 1101 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1101 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2768 "tars.tab.cpp" @@ -2962,7 +2962,7 @@ yyparse (void) return yyresult; } -#line 1105 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1105 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" diff --git a/tools/tarsparse/tars.lex.cpp b/tools/tarsparse/tars.lex.cpp index ab0f0635..9a51e112 100644 --- a/tools/tarsparse/tars.lex.cpp +++ b/tools/tarsparse/tars.lex.cpp @@ -511,7 +511,7 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 1 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" /** * Tencent is pleased to support the open source community by making Tars available. * @@ -527,7 +527,7 @@ char *yytext; * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -#line 20 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 20 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" #include #include #include @@ -776,7 +776,7 @@ YY_DECL } { -#line 67 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 67 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" #line 782 "tars.lex.cpp" @@ -848,12 +848,12 @@ YY_DECL case 1: YY_RULE_SETUP -#line 69 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 69 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { BEGIN(INCL); } YY_BREAK case 2: YY_RULE_SETUP -#line 71 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 71 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { if ( include_file_stack_ptr >= MAX_INCLUDE_DEPTH ) { @@ -886,7 +886,7 @@ YY_RULE_SETUP YY_BREAK case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INCL): -#line 101 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 101 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { --include_file_stack_ptr; if ( include_file_stack_ptr < 0 ) @@ -905,14 +905,14 @@ case YY_STATE_EOF(INCL): YY_BREAK case 3: YY_RULE_SETUP -#line 117 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 117 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { return TARS_SCOPE_DELIMITER; } YY_BREAK case 4: YY_RULE_SETUP -#line 121 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 121 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { // C++ comment bool e = false; @@ -933,7 +933,7 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 139 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 139 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { // C comment bool e = false; @@ -984,7 +984,7 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 187 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 187 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { StringGrammarPtr ident = new StringGrammar; ident->v = yytext; @@ -995,7 +995,7 @@ YY_RULE_SETUP case 7: /* rule 7 can match eol */ YY_RULE_SETUP -#line 194 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 194 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { StringGrammarPtr ident = new StringGrammar; ident->v = yytext; @@ -1008,7 +1008,7 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 204 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 204 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { StringGrammarPtr str = new StringGrammar; bool e = false; @@ -1123,7 +1123,7 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 316 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 316 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { errno = 0; IntergerGrammarPtr ptr = new IntergerGrammar; @@ -1148,7 +1148,7 @@ YY_RULE_SETUP YY_BREAK case 10: YY_RULE_SETUP -#line 338 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 338 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { errno = 0; FloatGrammarPtr ptr = new FloatGrammar; @@ -1183,7 +1183,7 @@ YY_RULE_SETUP case 11: /* rule 11 can match eol */ YY_RULE_SETUP -#line 369 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 369 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { if(yytext[0] == '\n') { @@ -1193,7 +1193,7 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 376 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 376 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { if(yytext[0] < 32 || yytext[0] > 126) { @@ -1212,7 +1212,7 @@ YY_RULE_SETUP YY_BREAK case 13: YY_RULE_SETUP -#line 392 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 392 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" ECHO; YY_BREAK #line 1218 "tars.lex.cpp" @@ -2230,7 +2230,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 392 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.l" +#line 392 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" diff --git a/tools/tarsparse/tars.tab.cpp b/tools/tarsparse/tars.tab.cpp index 83215380..869dd6a2 100644 --- a/tools/tarsparse/tars.tab.cpp +++ b/tools/tarsparse/tars.tab.cpp @@ -67,7 +67,7 @@ /* First part of user prologue. */ -#line 17 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 17 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" #include #include @@ -1384,14 +1384,14 @@ yyparse (void) switch (yyn) { case 3: /* $@1: %empty */ -#line 75 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 75 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1391 "tars.tab.cpp" break; case 5: /* $@2: %empty */ -#line 79 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 79 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyerrok; } @@ -1399,7 +1399,7 @@ yyparse (void) break; case 7: /* definitions: definition */ -#line 84 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 84 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } @@ -1407,14 +1407,14 @@ yyparse (void) break; case 8: /* definitions: %empty */ -#line 88 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 88 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1414 "tars.tab.cpp" break; case 9: /* definition: namespace_def */ -#line 96 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 96 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || NamespacePtr::dynamicCast(yyvsp[0])); } @@ -1422,7 +1422,7 @@ yyparse (void) break; case 10: /* definition: interface_def */ -#line 100 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 100 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || InterfacePtr::dynamicCast(yyvsp[0])); } @@ -1430,7 +1430,7 @@ yyparse (void) break; case 11: /* definition: struct_def */ -#line 104 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 104 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || StructPtr::dynamicCast(yyvsp[0])); } @@ -1438,14 +1438,14 @@ yyparse (void) break; case 12: /* definition: key_def */ -#line 108 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 108 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1445 "tars.tab.cpp" break; case 13: /* definition: enum_def */ -#line 111 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 111 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || EnumPtr::dynamicCast(yyvsp[0])); } @@ -1453,7 +1453,7 @@ yyparse (void) break; case 14: /* definition: const_def */ -#line 115 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 115 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || ConstPtr::dynamicCast(yyvsp[0])); } @@ -1461,7 +1461,7 @@ yyparse (void) break; case 15: /* @3: %empty */ -#line 124 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 124 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1469,7 +1469,7 @@ yyparse (void) break; case 16: /* enum_def: enum_id @3 '{' enumerator_list '}' */ -#line 128 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 128 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1487,7 +1487,7 @@ yyparse (void) break; case 17: /* enum_id: TARS_ENUM TARS_IDENTIFIER */ -#line 147 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 147 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { NamespacePtr c = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!c) @@ -1504,7 +1504,7 @@ yyparse (void) break; case 18: /* enum_id: TARS_ENUM keyword */ -#line 160 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 160 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumeration name"); @@ -1514,7 +1514,7 @@ yyparse (void) break; case 19: /* enumerator_list: enumerator ',' enumerator_list */ -#line 171 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 171 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[-1]; } @@ -1522,14 +1522,14 @@ yyparse (void) break; case 20: /* enumerator_list: enumerator */ -#line 175 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 175 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1529 "tars.tab.cpp" break; case 21: /* enumerator: TARS_IDENTIFIER */ -#line 183 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 183 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1544,7 +1544,7 @@ yyparse (void) break; case 22: /* enumerator: keyword */ -#line 194 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 194 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumerator"); @@ -1553,7 +1553,7 @@ yyparse (void) break; case 23: /* enumerator: TARS_IDENTIFIER '=' const_initializer */ -#line 199 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 199 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -1570,14 +1570,14 @@ yyparse (void) break; case 24: /* enumerator: %empty */ -#line 212 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 212 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1577 "tars.tab.cpp" break; case 25: /* @4: %empty */ -#line 220 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 220 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ContainerPtr c = g_parse->currentContainer(); @@ -1596,7 +1596,7 @@ yyparse (void) break; case 26: /* namespace_def: TARS_NAMESPACE TARS_IDENTIFIER @4 '{' definitions '}' */ -#line 235 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 235 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1612,7 +1612,7 @@ yyparse (void) break; case 27: /* $@5: %empty */ -#line 253 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 253 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-1]); StructPtr sp = StructPtr::dynamicCast(g_parse->findUserType(ident->v)); @@ -1627,14 +1627,14 @@ yyparse (void) break; case 28: /* key_def: TARS_KEY '[' scoped_name ',' $@5 key_members ']' */ -#line 264 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 264 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1634 "tars.tab.cpp" break; case 29: /* key_members: TARS_IDENTIFIER */ -#line 272 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 272 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1651,7 +1651,7 @@ yyparse (void) break; case 30: /* key_members: key_members ',' TARS_IDENTIFIER */ -#line 285 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 285 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1668,7 +1668,7 @@ yyparse (void) break; case 31: /* @6: %empty */ -#line 304 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 304 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1689,7 +1689,7 @@ yyparse (void) break; case 32: /* interface_def: interface_id @6 '{' interface_exports '}' */ -#line 321 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 321 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1705,7 +1705,7 @@ yyparse (void) break; case 33: /* interface_id: TARS_INTERFACE TARS_IDENTIFIER */ -#line 338 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 338 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1713,7 +1713,7 @@ yyparse (void) break; case 34: /* interface_id: TARS_INTERFACE keyword */ -#line 342 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 342 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as interface name"); @@ -1723,21 +1723,21 @@ yyparse (void) break; case 35: /* interface_exports: interface_export ';' interface_exports */ -#line 353 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 353 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1730 "tars.tab.cpp" break; case 36: /* interface_exports: error ';' interface_exports */ -#line 356 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 356 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1737 "tars.tab.cpp" break; case 37: /* interface_exports: interface_export */ -#line 359 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 359 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } @@ -1745,14 +1745,14 @@ yyparse (void) break; case 38: /* interface_exports: %empty */ -#line 363 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 363 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1752 "tars.tab.cpp" break; case 40: /* operation: operation_preamble parameters ')' */ -#line 377 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 377 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1768,7 +1768,7 @@ yyparse (void) break; case 41: /* operation_preamble: return_type TARS_OP */ -#line 394 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 394 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1796,7 +1796,7 @@ yyparse (void) break; case 43: /* return_type: TARS_VOID */ -#line 424 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 424 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = 0; } @@ -1804,14 +1804,14 @@ yyparse (void) break; case 44: /* parameters: %empty */ -#line 434 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 434 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 1811 "tars.tab.cpp" break; case 45: /* parameters: type_id */ -#line 437 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 437 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1826,7 +1826,7 @@ yyparse (void) break; case 46: /* parameters: parameters ',' type_id */ -#line 448 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 448 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1841,7 +1841,7 @@ yyparse (void) break; case 47: /* parameters: out_qualifier type_id */ -#line 459 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 459 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1857,7 +1857,7 @@ yyparse (void) break; case 48: /* parameters: parameters ',' out_qualifier type_id */ -#line 471 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 471 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1873,7 +1873,7 @@ yyparse (void) break; case 49: /* parameters: routekey_qualifier type_id */ -#line 483 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 483 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1889,7 +1889,7 @@ yyparse (void) break; case 50: /* parameters: parameters ',' routekey_qualifier type_id */ -#line 495 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 495 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1905,7 +1905,7 @@ yyparse (void) break; case 51: /* parameters: out_qualifier */ -#line 507 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 507 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("'out' must be defined with a type"); } @@ -1913,7 +1913,7 @@ yyparse (void) break; case 52: /* parameters: routekey_qualifier */ -#line 511 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 511 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("'routekey' must be defined with a type"); } @@ -1921,7 +1921,7 @@ yyparse (void) break; case 53: /* routekey_qualifier: TARS_ROUTE_KEY */ -#line 520 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 520 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr routekey = new BoolGrammar; routekey->v = true; @@ -1931,7 +1931,7 @@ yyparse (void) break; case 54: /* out_qualifier: TARS_OUT */ -#line 531 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 531 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr out = new BoolGrammar; out->v = true; @@ -1941,7 +1941,7 @@ yyparse (void) break; case 55: /* @7: %empty */ -#line 542 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 542 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); @@ -1967,7 +1967,7 @@ yyparse (void) break; case 56: /* struct_def: struct_id @7 '{' struct_exports '}' */ -#line 564 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 564 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1986,7 +1986,7 @@ yyparse (void) break; case 57: /* struct_id: TARS_STRUCT TARS_IDENTIFIER */ -#line 584 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 584 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1994,7 +1994,7 @@ yyparse (void) break; case 58: /* struct_id: TARS_STRUCT keyword */ -#line 588 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 588 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2004,7 +2004,7 @@ yyparse (void) break; case 59: /* struct_id: TARS_STRUCT error */ -#line 594 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 594 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("abstract declarator '' used as declaration"); } @@ -2012,7 +2012,7 @@ yyparse (void) break; case 60: /* struct_exports: data_member ';' struct_exports */ -#line 603 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 603 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } @@ -2020,7 +2020,7 @@ yyparse (void) break; case 61: /* struct_exports: data_member */ -#line 607 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 607 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("';' missing after definition"); } @@ -2028,14 +2028,14 @@ yyparse (void) break; case 62: /* struct_exports: %empty */ -#line 611 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 611 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2035 "tars.tab.cpp" break; case 63: /* data_member: struct_type_id */ -#line 621 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 621 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2043,7 +2043,7 @@ yyparse (void) break; case 64: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id */ -#line 630 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 630 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2065,7 +2065,7 @@ yyparse (void) break; case 65: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id '=' const_initializer */ -#line 648 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 648 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2091,7 +2091,7 @@ yyparse (void) break; case 66: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id '=' const_initializer */ -#line 670 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 670 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2117,7 +2117,7 @@ yyparse (void) break; case 67: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id */ -#line 692 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 692 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2138,7 +2138,7 @@ yyparse (void) break; case 68: /* struct_type_id: TARS_REQUIRE type_id */ -#line 709 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 709 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } @@ -2146,7 +2146,7 @@ yyparse (void) break; case 69: /* struct_type_id: TARS_OPTIONAL type_id */ -#line 713 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 713 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } @@ -2154,7 +2154,7 @@ yyparse (void) break; case 70: /* struct_type_id: TARS_CONST_INTEGER type_id */ -#line 717 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 717 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'require' or 'optional'"); } @@ -2162,7 +2162,7 @@ yyparse (void) break; case 71: /* struct_type_id: type_id */ -#line 721 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 721 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag' or 'require' or 'optional'"); } @@ -2170,7 +2170,7 @@ yyparse (void) break; case 72: /* const_initializer: TARS_CONST_INTEGER */ -#line 730 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 730 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { IntergerGrammarPtr intVal = IntergerGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2184,7 +2184,7 @@ yyparse (void) break; case 73: /* const_initializer: TARS_CONST_FLOAT */ -#line 740 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 740 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { FloatGrammarPtr floatVal = FloatGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2198,7 +2198,7 @@ yyparse (void) break; case 74: /* const_initializer: TARS_STRING_LITERAL */ -#line 750 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 750 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2210,7 +2210,7 @@ yyparse (void) break; case 75: /* const_initializer: TARS_FALSE */ -#line 758 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 758 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2222,7 +2222,7 @@ yyparse (void) break; case 76: /* const_initializer: TARS_TRUE */ -#line 766 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 766 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2234,7 +2234,7 @@ yyparse (void) break; case 77: /* const_initializer: TARS_IDENTIFIER */ -#line 774 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 774 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2251,7 +2251,7 @@ yyparse (void) break; case 78: /* const_initializer: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 787 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 787 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2270,7 +2270,7 @@ yyparse (void) break; case 79: /* const_def: TARS_CONST type_id '=' const_initializer */ -#line 807 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 807 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!np) @@ -2287,7 +2287,7 @@ yyparse (void) break; case 80: /* type_id: type TARS_IDENTIFIER */ -#line 825 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 825 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2300,7 +2300,7 @@ yyparse (void) break; case 81: /* type_id: type TARS_IDENTIFIER '[' TARS_CONST_INTEGER ']' */ -#line 834 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 834 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-4])); IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast(yyvsp[-1]); @@ -2314,7 +2314,7 @@ yyparse (void) break; case 82: /* type_id: type '*' TARS_IDENTIFIER */ -#line 844 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 844 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-2])); //IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast($4); @@ -2328,7 +2328,7 @@ yyparse (void) break; case 83: /* type_id: type TARS_IDENTIFIER ':' TARS_CONST_INTEGER */ -#line 854 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 854 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-3]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2341,7 +2341,7 @@ yyparse (void) break; case 84: /* type_id: type keyword */ -#line 863 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 863 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as data member name"); @@ -2350,7 +2350,7 @@ yyparse (void) break; case 85: /* type_id: type */ -#line 868 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 868 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("missing data member name"); } @@ -2358,7 +2358,7 @@ yyparse (void) break; case 86: /* type_id: error */ -#line 872 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 872 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("unkown type"); } @@ -2366,7 +2366,7 @@ yyparse (void) break; case 87: /* type: type_no ':' TARS_CONST_INTEGER */ -#line 881 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 881 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-2]); @@ -2379,7 +2379,7 @@ yyparse (void) break; case 88: /* type: type_no */ -#line 890 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 890 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -2387,7 +2387,7 @@ yyparse (void) break; case 89: /* type: type_no ':' error */ -#line 894 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 894 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("array missing size"); } @@ -2395,7 +2395,7 @@ yyparse (void) break; case 90: /* type_no: TARS_BOOL */ -#line 903 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 903 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindBool); } @@ -2403,7 +2403,7 @@ yyparse (void) break; case 91: /* type_no: TARS_BYTE */ -#line 907 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 907 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindByte); } @@ -2411,7 +2411,7 @@ yyparse (void) break; case 92: /* type_no: TARS_UNSIGNED TARS_BYTE */ -#line 911 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 911 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort,true); } @@ -2419,7 +2419,7 @@ yyparse (void) break; case 93: /* type_no: TARS_SHORT */ -#line 915 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 915 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort); } @@ -2427,7 +2427,7 @@ yyparse (void) break; case 94: /* type_no: TARS_UNSIGNED TARS_SHORT */ -#line 919 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 919 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt,true); } @@ -2435,7 +2435,7 @@ yyparse (void) break; case 95: /* type_no: TARS_INT */ -#line 923 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 923 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt); } @@ -2443,7 +2443,7 @@ yyparse (void) break; case 96: /* type_no: TARS_UNSIGNED TARS_INT */ -#line 927 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 927 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong,true); } @@ -2451,7 +2451,7 @@ yyparse (void) break; case 97: /* type_no: TARS_LONG */ -#line 931 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 931 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong); } @@ -2459,7 +2459,7 @@ yyparse (void) break; case 98: /* type_no: TARS_FLOAT */ -#line 935 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 935 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindFloat); } @@ -2467,7 +2467,7 @@ yyparse (void) break; case 99: /* type_no: TARS_DOUBLE */ -#line 939 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 939 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindDouble); } @@ -2475,7 +2475,7 @@ yyparse (void) break; case 100: /* type_no: TARS_STRING */ -#line 943 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 943 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindString); } @@ -2483,7 +2483,7 @@ yyparse (void) break; case 101: /* type_no: vector */ -#line 947 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 947 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2491,7 +2491,7 @@ yyparse (void) break; case 102: /* type_no: map */ -#line 951 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 951 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2499,7 +2499,7 @@ yyparse (void) break; case 103: /* type_no: scoped_name */ -#line 955 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 955 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypePtr sp = g_parse->findUserType(ident->v); @@ -2516,7 +2516,7 @@ yyparse (void) break; case 104: /* vector: TARS_VECTOR '<' type '>' */ -#line 973 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 973 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createVector(TypePtr::dynamicCast(yyvsp[-1]))); } @@ -2524,7 +2524,7 @@ yyparse (void) break; case 105: /* vector: TARS_VECTOR '<' error */ -#line 977 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 977 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector error"); } @@ -2532,7 +2532,7 @@ yyparse (void) break; case 106: /* vector: TARS_VECTOR '<' type error */ -#line 981 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 981 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing '>'"); } @@ -2540,7 +2540,7 @@ yyparse (void) break; case 107: /* vector: TARS_VECTOR error */ -#line 985 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 985 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing type"); } @@ -2548,7 +2548,7 @@ yyparse (void) break; case 108: /* map: TARS_MAP '<' type ',' type '>' */ -#line 994 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 994 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createMap(TypePtr::dynamicCast(yyvsp[-3]), TypePtr::dynamicCast(yyvsp[-1]))); } @@ -2556,7 +2556,7 @@ yyparse (void) break; case 109: /* map: TARS_MAP '<' error */ -#line 998 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 998 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("map error"); } @@ -2564,14 +2564,14 @@ yyparse (void) break; case 110: /* scoped_name: TARS_IDENTIFIER */ -#line 1007 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1007 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2571 "tars.tab.cpp" break; case 111: /* scoped_name: TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1010 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1010 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ident->v = "::" + ident->v; @@ -2581,7 +2581,7 @@ yyparse (void) break; case 112: /* scoped_name: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1016 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1016 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2593,175 +2593,175 @@ yyparse (void) break; case 113: /* keyword: TARS_STRUCT */ -#line 1029 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1029 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2600 "tars.tab.cpp" break; case 114: /* keyword: TARS_VOID */ -#line 1032 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1032 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2607 "tars.tab.cpp" break; case 115: /* keyword: TARS_BOOL */ -#line 1035 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1035 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2614 "tars.tab.cpp" break; case 116: /* keyword: TARS_BYTE */ -#line 1038 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1038 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2621 "tars.tab.cpp" break; case 117: /* keyword: TARS_SHORT */ -#line 1041 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1041 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2628 "tars.tab.cpp" break; case 118: /* keyword: TARS_INT */ -#line 1044 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1044 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2635 "tars.tab.cpp" break; case 119: /* keyword: TARS_FLOAT */ -#line 1047 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1047 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2642 "tars.tab.cpp" break; case 120: /* keyword: TARS_DOUBLE */ -#line 1050 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1050 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2649 "tars.tab.cpp" break; case 121: /* keyword: TARS_STRING */ -#line 1053 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1053 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2656 "tars.tab.cpp" break; case 122: /* keyword: TARS_VECTOR */ -#line 1056 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1056 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2663 "tars.tab.cpp" break; case 123: /* keyword: TARS_KEY */ -#line 1059 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1059 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2670 "tars.tab.cpp" break; case 124: /* keyword: TARS_MAP */ -#line 1062 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1062 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2677 "tars.tab.cpp" break; case 125: /* keyword: TARS_NAMESPACE */ -#line 1065 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1065 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2684 "tars.tab.cpp" break; case 126: /* keyword: TARS_INTERFACE */ -#line 1068 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1068 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2691 "tars.tab.cpp" break; case 127: /* keyword: TARS_OUT */ -#line 1071 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1071 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2698 "tars.tab.cpp" break; case 128: /* keyword: TARS_REQUIRE */ -#line 1074 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1074 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2705 "tars.tab.cpp" break; case 129: /* keyword: TARS_OPTIONAL */ -#line 1077 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1077 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2712 "tars.tab.cpp" break; case 130: /* keyword: TARS_CONST_INTEGER */ -#line 1080 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1080 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2719 "tars.tab.cpp" break; case 131: /* keyword: TARS_CONST_FLOAT */ -#line 1083 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1083 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2726 "tars.tab.cpp" break; case 132: /* keyword: TARS_FALSE */ -#line 1086 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1086 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2733 "tars.tab.cpp" break; case 133: /* keyword: TARS_TRUE */ -#line 1089 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1089 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2740 "tars.tab.cpp" break; case 134: /* keyword: TARS_STRING_LITERAL */ -#line 1092 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1092 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2747 "tars.tab.cpp" break; case 135: /* keyword: TARS_CONST */ -#line 1095 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1095 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2754 "tars.tab.cpp" break; case 136: /* keyword: TARS_ENUM */ -#line 1098 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1098 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2761 "tars.tab.cpp" break; case 137: /* keyword: TARS_UNSIGNED */ -#line 1101 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1101 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } #line 2768 "tars.tab.cpp" @@ -2962,7 +2962,7 @@ yyparse (void) return yyresult; } -#line 1105 "/Volumes/MyData/centos/CloudMarket/TarsPython/tarscpp/tools/tarsgrammar/tars.y" +#line 1105 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" diff --git a/util/include/util/tc_socket.h b/util/include/util/tc_socket.h index 884a7244..7e91b5a2 100644 --- a/util/include/util/tc_socket.h +++ b/util/include/util/tc_socket.h @@ -498,11 +498,12 @@ class TC_Socket /** * @brief 获取本地所有ip. - * + * @param domain, AF_INET: ipv4, AF_INET6: ipv6 + * @param withLoopIp: 是否获取127.0.0.1 or ::1 地址 * @throws TC_Socket_Exception * @return 本地所有ip */ - static vector getLocalHosts(int domain = AF_INET); + static vector getLocalHosts(int domain = AF_INET, bool withLoopIp = true); /** * @brief 生成管道,抛出异常时会关闭fd. diff --git a/util/include/util/tc_uuid_generator.h b/util/include/util/tc_uuid_generator.h index a72655f5..7d7449ce 100644 --- a/util/include/util/tc_uuid_generator.h +++ b/util/include/util/tc_uuid_generator.h @@ -109,11 +109,11 @@ class TC_UUIDGenerator : public TC_Singleton string getLocalIP() { - vector vs = TC_Socket::getLocalHosts(); + vector vs = TC_Socket::getLocalHosts(AF_INET, false); for (size_t i = 0; i < vs.size(); i++) { - if (vs[i] != "127.0.0.1" && (!TC_Socket::addressIsIPv6(vs[i]))) + if (!TC_Socket::addressIsIPv6(vs[i])) { return vs[i]; } diff --git a/util/src/tc_file.cpp b/util/src/tc_file.cpp index 5c6efe0f..aac88b13 100644 --- a/util/src/tc_file.cpp +++ b/util/src/tc_file.cpp @@ -696,6 +696,7 @@ void TC_File::copyFile(const string &sExistFile, const string &sNewFile,bool bRe { THROW_EXCEPTION_SYSCODE(TC_File_Exception, "[TC_File::copyFile] error: "+sExistFile); } + //强制覆盖 std::ofstream fout(sNewFile.c_str(), ios::binary); if(!fout ) { diff --git a/util/src/tc_socket.cpp b/util/src/tc_socket.cpp index 45513cc8..10725d8b 100755 --- a/util/src/tc_socket.cpp +++ b/util/src/tc_socket.cpp @@ -889,14 +889,11 @@ void TC_Socket::createPipe(int fds[2], bool bBlock) if (tcp1 != -1) { TC_Port::closeSocket(tcp1); } -// #if TARGET_PLATFORM_LINUX||TARGET_PLATFORM_IOS -// #undef closesocket -// #endif + THROW_EXCEPTION_SYSCODE(TC_Socket_Exception, "[TC_Socket::createPipe] error"); } -//#if TARGET_PLATFORM_LINUX || TARGET_PLATFORM_IOS -vector TC_Socket::getLocalHosts(int domain) +vector TC_Socket::getLocalHosts(int domain, bool withLoopIp) { vector hosts; char local[255] = { 0 }; @@ -904,7 +901,7 @@ vector TC_Socket::getLocalHosts(int domain) struct addrinfo hints, *res, *p; int status; - char ipstr[INET6_ADDRSTRLEN]; + char ipstr[INET6_ADDRSTRLEN] = {0}; memset(&hints, 0, sizeof hints); hints.ai_family = domain; // AF_UNSPEC means any: AF_INET, AF_INET6, etc. @@ -925,48 +922,17 @@ vector TC_Socket::getLocalHosts(int domain) } // convert IP to a string and add it to the list - inet_ntop(p->ai_family, addr, ipstr, sizeof ipstr); - hosts.emplace_back(ipstr); + inet_ntop(p->ai_family, addr, ipstr, sizeof(ipstr)); + if(withLoopIp || (TC_Port::strcasecmp(ipstr,"127.0.0.1") != 0 && TC_Port::strcasecmp(ipstr, "::1") != 0)) + { + hosts.emplace_back(ipstr); + } } - freeaddrinfo(res); // free the linked list + freeaddrinfo(res); return hosts; } -//#endif -// -//#if TARGET_PLATFORM_WINDOWS -//vector TC_Socket::getLocalHosts(int domain) -//{ -// vector hosts; -// -// char local[255] = { 0 }; -// gethostname(local, sizeof(local)); -// hostent* ph = gethostbyname(local); -// if (ph == NULL) -// { -// return hosts; -// } -// -// in_addr addr; -// if (ph->h_addrtype == AF_INET) -// { -// int i = 0; -// while (ph->h_addr_list[i] != 0) -// { -// addr.s_addr = *(u_long*)ph->h_addr_list[i++]; -// hosts.emplace_back(inet_ntoa(addr)); -// } -// } -// else -// { -// // unsupport AF_INET6 ... -// return hosts; -// } -// return hosts; -//} -// -//#endif bool TC_Socket::isPending() { From c7adb8b28b268f14df78d6d67b7b1da18be614ea Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 29 Feb 2024 16:53:31 +0800 Subject: [PATCH 61/81] feat: tc_port add getCommandLine/getPidsByCmdline --- unit-test/util/test_tc_port.cpp | 79 ++++++++ util/include/util/tc_port.h | 18 ++ util/src/tc_file.cpp | 14 +- util/src/tc_port.cpp | 349 ++++++++++++++++++++++++++++++++ 4 files changed, 447 insertions(+), 13 deletions(-) diff --git a/unit-test/util/test_tc_port.cpp b/unit-test/util/test_tc_port.cpp index f47bfddd..b6833919 100755 --- a/unit-test/util/test_tc_port.cpp +++ b/unit-test/util/test_tc_port.cpp @@ -126,3 +126,82 @@ TEST_F(UtilPortTest, testGetDisk) } #endif +// +//#if TARGET_PLATFORM_IOS +//#include +//#include +//#include +//#include +//#include +//#endif +// +// +//vector getPidsByCmdline(const string &cmdLine, bool accurateMatch) +//{ +// vector pids; +// +//#if TARGET_PLATFORM_IOS +// int mib[4]; +// mib[0] = CTL_KERN; +// mib[1] = KERN_PROC; +// mib[2] = KERN_PROC_ALL; +// mib[3] = 0; +// +// size_t size; +// if (sysctl(mib, 4, NULL, &size, NULL, 0) == -1) { +// return {}; +// } +// +// struct kinfo_proc* proc_list = (struct kinfo_proc*)malloc(size); +// if (proc_list == NULL) { +// return {}; +// } +// +// if (sysctl(mib, 4, proc_list, &size, NULL, 0) == -1) { +// free(proc_list); +// return {}; +// } +// +// int num_procs = size / sizeof(struct kinfo_proc); +// for (int i = 0; i < num_procs; i++) +// { +// vector args = getArgs(proc_list[i].kp_proc.p_pid); +// string path = TC_Common::tostr(args.begin(), args.end(), " "); +// +// if(accurateMatch) +// { +// if(cmdLine == path) +// { +// pids.push_back(proc_list[i].kp_proc.p_pid); +// } +// } +// else +// { +// if(std::string(path).find(cmdLine) != std::string::npos) +// { +// pids.push_back(proc_list[i].kp_proc.p_pid); +// } +// } +// } +// +// free(proc_list); +// return pids; +//#elif TARGET_PLATFORM_LINUX +// return {}; +//#elif TARGET_PLATFORM_WINDOWS +// return {}; +//#else +// return {}; +//#endif +//} + +TEST_F(UtilPortTest, testGetPidsByCmdline) +{ + vector pids = TC_Port::getPidsByCmdline("unit-test", false); + + cout << TC_Common::tostr(pids.begin(), pids.end(), ", ") << endl; + + int64_t pid = TC_Port::getpid(); + + ASSERT_TRUE(std::find(pids.begin(), pids.end(), pid) != pids.end()); +} \ No newline at end of file diff --git a/util/include/util/tc_port.h b/util/include/util/tc_port.h index 632c0c4f..02f4017f 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -46,6 +46,9 @@ struct TC_Port_Exception : public TC_Exception ~TC_Port_Exception() throw() {}; }; +/** + * 跨平台相关函数封装 + */ class TC_Port { public: @@ -150,6 +153,21 @@ class TC_Port static void closeAllFileDescriptors(); #endif + /** + * 返回完整命令行参数, 如果pid不存在, 则返回为空 + * @param pid + * @return, 命令行参数, argv[0], argv[1] .... + */ + static std::vector getCommandLine(int pid); + + /** + * 根据程序执行的命令行, 获取对应的进程pid + * @param cmdLine: 程序的启动完整命令行 + * @param accurateMatch: 匹配方式, true: 精确匹配, false: 模糊匹配(启动命令行能find到cmdLine) + * @return + */ + static vector getPidsByCmdline(const string &cmdLine, bool accurateMatch = false); + /** * 注册ctrl+c回调事件(SIGINT/CTRL_C_EVENT) * @param callback diff --git a/util/src/tc_file.cpp b/util/src/tc_file.cpp index aac88b13..a5e78586 100644 --- a/util/src/tc_file.cpp +++ b/util/src/tc_file.cpp @@ -155,21 +155,9 @@ string TC_File::getExePath() #elif TARGET_PLATFORM_IOS string TC_File::getExePath() { - int numberOfProcesses = proc_listpids(PROC_ALL_PIDS, 0, NULL, 0); - pid_t pids[numberOfProcesses]; - bzero(pids, sizeof(pids)); - proc_listpids(PROC_ALL_PIDS, 0, pids, sizeof(pids)); char pathBuffer[PROC_PIDPATHINFO_MAXSIZE]; bzero(pathBuffer, PROC_PIDPATHINFO_MAXSIZE); - for (int i = 0; i < numberOfProcesses; ++i) { - if (pids[i] == 0) { continue; } - - if(pids[i] == getpid()) - { - proc_pidpath(pids[i], pathBuffer, sizeof(pathBuffer)); - break; - } - } + proc_pidpath(getpid(), pathBuffer, sizeof(pathBuffer)); return pathBuffer; } diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index 64c482af..e2bcb05d 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -366,6 +366,355 @@ void TC_Port::closeAllFileDescriptors() #endif +#if TARGET_PLATFORM_LINUX +std::vector getCommandLine(int64_t pid) { + std::vector commandLineArgs; + + std::string procPath = "/proc/" + std::to_string(pid) + "/cmdline"; + std::ifstream cmdlineFile(procPath); + if (!cmdlineFile.is_open()) { + return {}; + } + + std::stringstream buffer; + buffer << cmdlineFile.rdbuf(); + std::string cmdline = buffer.str(); + + size_t pos = 0; + while (pos < cmdline.size()) { + std::string arg; + size_t nextPos = cmdline.find('\0', pos); + if (nextPos == std::string::npos) { + arg = cmdline.substr(pos); + pos = cmdline.size(); + } else { + arg = cmdline.substr(pos, nextPos - pos); + pos = nextPos + 1; + } + commandLineArgs.push_back(arg); + } + + return commandLineArgs; +} +#endif + +#if TARGET_PLATFORM_WINDOWS + +std::vector TC_Port::getCommandLine(int64_t pid) +{ + HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, static_cast(pid)); + if (hProcess == NULL) { + return {}; + } + + std::vector commandLineArgs; + + LPWSTR cmdLine = GetCommandLineW(); + + int argc; + LPWSTR* argv = CommandLineToArgvW(cmdLine, &argc); + + if (argv != NULL) { + for (int i = 0; i < argc; i++) { + wchar_t buffer[MAX_PATH]; + WideCharToMultiByte(CP_ACP, 0, argv[i], -1, buffer, MAX_PATH, NULL, NULL); + commandLineArgs.push_back(buffer); + } + + LocalFree(argv); + } + + CloseHandle(hProcess); + + return commandLineArgs; +} +#endif +#if TARGET_PLATFORM_IOS + +std::vector TC_Port::getCommandLine(int64_t pid) +{ + vector args; + + int mib[3], argmax, nargs, c = 0; + size_t size; + char *procargs, *sp, *np, *cp; + int show_args = 1; + + mib[0] = CTL_KERN; + mib[1] = KERN_ARGMAX; + + size = sizeof(argmax); + if (sysctl(mib, 2, &argmax, &size, NULL, 0) == -1) { + goto ERROR_A; + } + + /* Allocate space for the arguments. */ + procargs = (char *)malloc(argmax); + if (procargs == NULL) { + goto ERROR_A; + } + + /* + * Make a sysctl() call to get the raw argument space of the process. + * The layout is documented in start.s, which is part of the Csu + * project. In summary, it looks like: + * + * /---------------\ 0x00000000 + * : : + * : : + * |---------------| + * | argc | + * |---------------| + * | arg[0] | + * |---------------| + * : : + * : : + * |---------------| + * | arg[argc - 1] | + * |---------------| + * | 0 | + * |---------------| + * | env[0] | + * |---------------| + * : : + * : : + * |---------------| + * | env[n] | + * |---------------| + * | 0 | + * |---------------| <-- Beginning of data returned by sysctl() is here. + * | argc | + * |---------------| + * | exec_path | + * |:::::::::::::::| + * | | + * | String area. | + * | | + * |---------------| <-- Top of stack. + * : : + * : : + * \---------------/ 0xffffffff + */ + mib[0] = CTL_KERN; + mib[1] = KERN_PROCARGS2; + mib[2] = pid; + + size = (size_t)argmax; + if (sysctl(mib, 3, procargs, &size, NULL, 0) == -1) { + goto ERROR_B; + } + + memcpy(&nargs, procargs, sizeof(nargs)); + cp = procargs + sizeof(nargs); + + /* Skip the saved exec_path. */ + for (; cp < &procargs[size]; cp++) { + if (*cp == '\0') { + /* End of exec_path reached. */ + break; + } + } + if (cp == &procargs[size]) { + goto ERROR_B; + } + + /* Skip trailing '\0' characters. */ + for (; cp < &procargs[size]; cp++) { + if (*cp != '\0') { + /* Beginning of first argument reached. */ + break; + } + } + if (cp == &procargs[size]) { + goto ERROR_B; + } + /* Save where the argv[0] string starts. */ + sp = cp; + + /* + * Iterate through the '\0'-terminated strings and convert '\0' to ' ' + * until a string is found that has a '=' character in it (or there are + * no more strings in procargs). There is no way to deterministically + * know where the command arguments end and the environment strings + * start, which is why the '=' character is searched for as a heuristic. + */ + for (np = NULL; c < nargs && cp < &procargs[size]; cp++) { + if (*cp == '\0') { + c++; + if (np != NULL) { + /* Convert previous '\0'. */ + *np = ' '; + } else { + /* *argv0len = cp - sp; */ + } + /* Note location of current '\0'. */ + np = cp; + + if (!show_args) { + /* + * Don't convert '\0' characters to ' '. + * However, we needed to know that the + * command name was terminated, which we + * now know. + */ + break; + } + } + } + + /* + * sp points to the beginning of the arguments/environment string, and + * np should point to the '\0' terminator for the string. + */ + if (np == NULL || np == sp) { + /* Empty or unterminated string. */ + goto ERROR_B; + } + + /* Make a copy of the string. */ +// printf("%s\n", sp); + + args.push_back(sp); + + /* Clean up. */ + free(procargs); + return args; + + ERROR_B: + free(procargs); + ERROR_A: + + return args; +} +#endif +vector TC_Port::getPidsByCmdline(const string &cmdLine, bool accurateMatch) +{ + vector pids; + +#if TARGET_PLATFORM_IOS + int mib[4]; + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_ALL; + mib[3] = 0; + + size_t size; + if (sysctl(mib, 4, NULL, &size, NULL, 0) == -1) { + return {}; + } + + struct kinfo_proc* proc_list = (struct kinfo_proc*)malloc(size); + if (proc_list == NULL) { + return {}; + } + + if (sysctl(mib, 4, proc_list, &size, NULL, 0) == -1) { + free(proc_list); + return {}; + } + + int num_procs = size / sizeof(struct kinfo_proc); + for (int i = 0; i < num_procs; i++) + { + vector args = getCommandLine(proc_list[i].kp_proc.p_pid); + string path = TC_Common::tostr(args.begin(), args.end(), " "); + + if(accurateMatch) + { + if(cmdLine == path) + { + pids.push_back(proc_list[i].kp_proc.p_pid); + } + } + else + { + if(std::string(path).find(cmdLine) != std::string::npos) + { + pids.push_back(proc_list[i].kp_proc.p_pid); + } + } + } + + free(proc_list); + + return pids; +#elif TARGET_PLATFORM_LINUX + std::vector pids; + DIR* dir = opendir("/proc"); + if (!dir) { + return pids; + } + + struct dirent* entry; + while ((entry = readdir(dir)) != nullptr) + { + if(TC_Common::isdigit(entry->d_name)) + { + int64_t pid = TC_Common::strto(entry->d_name); + vector args = getCommandLine(pid); + string path = TC_Common::tostr(args.begin(), args.end(), " "); + + if(accurateMatch) + { + if(cmdLine == path) + { + pids.push_back(pid); + } + } + else + { + if(path.find(cmdLine) != std::string::npos) + { + pids.push_back(pid); + } + } + } + } + + closedir(dir); + return pids; +#elif TTARGET_PLATFORM_WINDOWS + + HANDLE hProcessSnap; + PROCESSENTRY32 pe32; + + hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + if (hProcessSnap == INVALID_HANDLE_VALUE) { + return pids; + } + + pe32.dwSize = sizeof(PROCESSENTRY32); + + if (!Process32First(hProcessSnap, &pe32)) { + CloseHandle(hProcessSnap); + return pids; + } + + do { + if(accurateMatch) + { + if(cmdLine == pe32.szExeFile) + { + pids.push_back(pe32.th32ProcessID); + } + } + else + { + if(std::string(pe32.szExeFile).find(cmdLine) != std::string::npos) + { + pids.push_back( pe32.th32ProcessID); + } + } + + } while (Process32Next(hProcessSnap, &pe32)); + + CloseHandle(hProcessSnap); + + return pids; +#else + return {}; +#endif +} int64_t TC_Port::forkExec(const string& sExePath, const string& sPwdPath, const string& sRollLogPath, const vector& vOptions) { From 5ed7bbd7e07767df43d25dfcf9fa217804fcab98 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 29 Feb 2024 19:40:16 +0800 Subject: [PATCH 62/81] widdows support getCommandLine --- cmake/Common.cmake | 7 +++++-- unit-test/util/test_tc_mysql.cpp | 2 ++ unit-test/util/test_tc_port.cpp | 11 +++++++++++ util/include/util/tc_port.h | 2 +- util/src/tc_port.cpp | 27 +++++++++++++++++++-------- 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/cmake/Common.cmake b/cmake/Common.cmake index cffdcc40..d6c3c9ae 100755 --- a/cmake/Common.cmake +++ b/cmake/Common.cmake @@ -90,8 +90,7 @@ IF (UNIX) ELSEIF (WIN32) set(PLATFORM "window") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 /wd4101 /wd4244 /wd4996 /wd4091 /wd4503 /wd4819 /wd4200 /wd4800 /wd4267 /wd4251 /wd4275") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj" ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 /wd4101 /wd4244 /wd4996 /wd4091 /wd4503 /wd4819 /wd4200 /wd4800 /wd4267 /wd4251 /wd4275 /bigobj") SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO") @@ -102,6 +101,10 @@ ELSEIF (WIN32) SET(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /DEBUG") SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /OPT:ICF /OPT:REF /DEBUG") + add_compile_options("$<$:/utf-8>") + add_compile_options("$<$:/utf-8>") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /ZI") + ELSE () MESSAGE(STATUS "================ ERROR: This platform is unsupported!!! ================") ENDIF (UNIX) diff --git a/unit-test/util/test_tc_mysql.cpp b/unit-test/util/test_tc_mysql.cpp index fca1dbbf..4e1abfc0 100755 --- a/unit-test/util/test_tc_mysql.cpp +++ b/unit-test/util/test_tc_mysql.cpp @@ -1,5 +1,7 @@ #include "util/tc_common.h" +#ifdef TARS_MYSQL #include "util/tc_mysql.h" +#endif #include "gtest/gtest.h" #include diff --git a/unit-test/util/test_tc_port.cpp b/unit-test/util/test_tc_port.cpp index b6833919..355743ec 100755 --- a/unit-test/util/test_tc_port.cpp +++ b/unit-test/util/test_tc_port.cpp @@ -195,6 +195,17 @@ TEST_F(UtilPortTest, testGetDisk) //#endif //} +TEST_F(UtilPortTest, testGetCommandline) +{ + vector cmdLine = TC_Port::getCommandLine(TC_Port::getpid()); + + cout << cmdLine.size() << endl; + + string cmdStr = TC_Common::tostr(cmdLine.begin(), cmdLine.end(), " "); + cout << cmdStr << endl; + ASSERT_TRUE(cmdStr.find("unit-test") != string::npos); +} + TEST_F(UtilPortTest, testGetPidsByCmdline) { vector pids = TC_Port::getPidsByCmdline("unit-test", false); diff --git a/util/include/util/tc_port.h b/util/include/util/tc_port.h index 02f4017f..f2cbd937 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -158,7 +158,7 @@ class TC_Port * @param pid * @return, 命令行参数, argv[0], argv[1] .... */ - static std::vector getCommandLine(int pid); + static std::vector getCommandLine(int64_t pid); /** * 根据程序执行的命令行, 获取对应的进程pid diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index e2bcb05d..99242605 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -42,8 +42,11 @@ #include #include #include +#include #include #include +#include + #include "util/tc_strptime.h" #endif @@ -367,7 +370,8 @@ void TC_Port::closeAllFileDescriptors() #endif #if TARGET_PLATFORM_LINUX -std::vector getCommandLine(int64_t pid) { +std::vector getCommandLine(int64_t pid) +{ std::vector commandLineArgs; std::string procPath = "/proc/" + std::to_string(pid) + "/cmdline"; @@ -416,7 +420,7 @@ std::vector TC_Port::getCommandLine(int64_t pid) if (argv != NULL) { for (int i = 0; i < argc; i++) { - wchar_t buffer[MAX_PATH]; + char buffer[MAX_PATH]; WideCharToMultiByte(CP_ACP, 0, argv[i], -1, buffer, MAX_PATH, NULL, NULL); commandLineArgs.push_back(buffer); } @@ -673,7 +677,7 @@ vector TC_Port::getPidsByCmdline(const string &cmdLine, bool accurateMa closedir(dir); return pids; -#elif TTARGET_PLATFORM_WINDOWS +#elif TARGET_PLATFORM_WINDOWS HANDLE hProcessSnap; PROCESSENTRY32 pe32; @@ -690,6 +694,8 @@ vector TC_Port::getPidsByCmdline(const string &cmdLine, bool accurateMa return pids; } + // std::wstring wcmdLine(cmdLine.begin(), cmdLine.end()); + do { if(accurateMatch) { @@ -749,11 +755,14 @@ int64_t TC_Port::forkExec(const string& sExePath, const string& sPwdPath, const } string command = sExePath + " " + path; - + // std::wstring wcommand(command.begin(), command.end()); + TCHAR p[1024]; - strncpy_s(p, sizeof(p) / sizeof(TCHAR), command.c_str(), command.length()); - - STARTUPINFO si; + strncpy_s(p, sizeof(p)/sizeof(TCHAR), command.c_str(), command.size()); + + // std::wstring wsPwdPath(sPwdPath.begin(), sPwdPath.end()); + + STARTUPINFOA si; memset(&si, 0, sizeof(si)); PROCESS_INFORMATION pi; memset(&pi, 0, sizeof(pi)); @@ -768,7 +777,7 @@ int64_t TC_Port::forkExec(const string& sExePath, const string& sPwdPath, const false, // 指示新进程是否从调用进程处继承了句柄。 CREATE_NEW_CONSOLE|CREATE_DEFAULT_ERROR_MODE | NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW, // 指定附加的、用来控制优先类和进程的创建的标 NULL, // 指向一个新进程的环境块。如果此参数为空,新进程使用调用进程的环境 - pwdCStr, // 指定子进程的工作路径 + sPwdPath.c_str(), // 指定子进程的工作路径 &si, // 决定新进程的主窗体如何显示的STARTUPINFO结构体 &pi // 接收新进程的识别信息的PROCESS_INFORMATION结构体 )) @@ -1409,6 +1418,8 @@ bool TC_Port::getDiskInfo(int64_t &totalSize, int64_t& availableSize, float& use ULARGE_INTEGER totalNumberOfBytes; ULARGE_INTEGER totalNumberOfFreeBytes; + // std::wstring wpath(path.begin(), path.end()); + if (!GetDiskFreeSpaceEx(path.c_str(), &freeBytesAvailableToCaller, &totalNumberOfBytes, &totalNumberOfFreeBytes)) { return false; } From 3f85df13003e81b25b8d33232b0f6bf07114b68d Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 29 Feb 2024 21:28:44 +0800 Subject: [PATCH 63/81] fix getCommandLine in linux --- unit-test/util/test_tc_endpoint.cpp | 12 ++++++------ util/src/tc_port.cpp | 3 +-- util/src/tc_socket.cpp | 10 +++++++--- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/unit-test/util/test_tc_endpoint.cpp b/unit-test/util/test_tc_endpoint.cpp index 37064218..a5c8e7cd 100644 --- a/unit-test/util/test_tc_endpoint.cpp +++ b/unit-test/util/test_tc_endpoint.cpp @@ -35,7 +35,7 @@ TEST_F(UtilEndpointTest, sep) vector eps = TC_Endpoint::sepEndpoint(str); - EXPECT_EQ(eps.size(), 1); + EXPECT_EQ(eps.size(), (size_t)1); EXPECT_EQ(eps[0], str); @@ -43,7 +43,7 @@ TEST_F(UtilEndpointTest, sep) eps = TC_Endpoint::sepEndpoint(str); - EXPECT_EQ(eps.size(), 1); + EXPECT_EQ(eps.size(), (size_t)1); EXPECT_EQ(eps[0], str); @@ -51,7 +51,7 @@ TEST_F(UtilEndpointTest, sep) eps = TC_Endpoint::sepEndpoint(str); - EXPECT_EQ(eps.size(), 1); + EXPECT_EQ(eps.size(), (size_t)1); EXPECT_EQ(eps[0], str); @@ -59,7 +59,7 @@ TEST_F(UtilEndpointTest, sep) eps = TC_Endpoint::sepEndpoint(str); - EXPECT_EQ(eps.size(), 1); + EXPECT_EQ(eps.size(), (size_t)1); EXPECT_EQ(eps[0], TC_Common::trim(str)); @@ -67,7 +67,7 @@ TEST_F(UtilEndpointTest, sep) eps = TC_Endpoint::sepEndpoint(str); - EXPECT_EQ(eps.size(), 1); + EXPECT_EQ(eps.size(), (size_t)1); EXPECT_EQ(eps[0], TC_Common::trim("tcp -h ::1 -p 25460 -t 60000")); } @@ -79,7 +79,7 @@ TEST_F(UtilEndpointTest, seps) vector eps = TC_Endpoint::sepEndpoint(str); - EXPECT_EQ(eps.size(), 3); + EXPECT_EQ(eps.size(), (size_t)3); EXPECT_EQ(eps[0], "udp -h ::1 -p 25460 -t 60000"); EXPECT_EQ(eps[1], "tcp -h 127.0.0.1 -p 25460 -t 60000"); diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index 99242605..c348d881 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -370,7 +370,7 @@ void TC_Port::closeAllFileDescriptors() #endif #if TARGET_PLATFORM_LINUX -std::vector getCommandLine(int64_t pid) +std::vector TC_Port::getCommandLine(int64_t pid) { std::vector commandLineArgs; @@ -643,7 +643,6 @@ vector TC_Port::getPidsByCmdline(const string &cmdLine, bool accurateMa return pids; #elif TARGET_PLATFORM_LINUX - std::vector pids; DIR* dir = opendir("/proc"); if (!dir) { return pids; diff --git a/util/src/tc_socket.cpp b/util/src/tc_socket.cpp index 10725d8b..79fe975b 100755 --- a/util/src/tc_socket.cpp +++ b/util/src/tc_socket.cpp @@ -141,7 +141,7 @@ void TC_Socket::bind(const char *sPathName) struct sockaddr_un stBindAddr; memset(&stBindAddr, 0x00, sizeof(stBindAddr)); stBindAddr.sun_family = _iDomain; - strncpy(stBindAddr.sun_path, sPathName, sizeof(stBindAddr.sun_path)); + strncpy(stBindAddr.sun_path, sPathName, sizeof(stBindAddr.sun_path)-1); try { @@ -171,7 +171,7 @@ int TC_Socket::connectNoThrow(const char *sPathName) struct sockaddr_un stServerAddr; memset(&stServerAddr, 0x00, sizeof(stServerAddr)); stServerAddr.sun_family = _iDomain; - strncpy(stServerAddr.sun_path, sPathName, sizeof(stServerAddr.sun_path)); + strncpy(stServerAddr.sun_path, sPathName, sizeof(stServerAddr.sun_path)-1); return connect((struct sockaddr *)&stServerAddr, sizeof(stServerAddr)); } @@ -417,7 +417,7 @@ void TC_Socket::parseUnixLocalAddr(const char* sPathName, struct sockaddr_un& ad { memset(&addr, 0x00, sizeof(addr)); addr.sun_family = AF_LOCAL; - strncpy(addr.sun_path, sPathName, sizeof(addr.sun_path)); + strncpy(addr.sun_path, sPathName, sizeof(addr.sun_path)-1); } #endif @@ -920,6 +920,10 @@ vector TC_Socket::getLocalHosts(int domain, bool withLoopIp) struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)p->ai_addr; addr = &(ipv6->sin6_addr); } + else + { + continue; + } // convert IP to a string and add it to the list inet_ntop(p->ai_family, addr, ipstr, sizeof(ipstr)); From b1dde86aa79cf568a0f67ee51b31ae2115f14aa4 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Fri, 1 Mar 2024 17:21:05 +0800 Subject: [PATCH 64/81] fix tc_port forExec exception info --- util/src/tc_port.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index c348d881..0a69b31e 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -781,9 +781,7 @@ int64_t TC_Port::forkExec(const string& sExePath, const string& sPwdPath, const &pi // 接收新进程的识别信息的PROCESS_INFORMATION结构体 )) { - string err = TC_Exception::parseError(TC_Exception::getSystemCode()); - - throw TC_Port_Exception("[TC_Port::forkExec] CreateProcessA exception:" + err); + throw TC_Port_Exception("[TC_Port::forkExec] CreateProcessA exception:" + TC_Exception::getSystemError()); } CloseHandle(pi.hThread); @@ -796,10 +794,7 @@ int64_t TC_Port::forkExec(const string& sExePath, const string& sPwdPath, const string bin = sExePath; if(!TC_File::isAbsolute(bin)) { - char current_directory[FILENAME_MAX] = {0x00}; - getcwd(current_directory, sizeof(current_directory)); - - bin = TC_File::simplifyDirectory(string(current_directory) + FILE_SEP + bin); + bin = TC_File::simplifyDirectory(TC_Port::getCwd() + FILE_SEP + bin); } vector vArgs; @@ -820,7 +815,7 @@ int64_t TC_Port::forkExec(const string& sExePath, const string& sPwdPath, const pid_t pid = fork(); if (pid == -1) { - throw TC_Port_Exception("[TC_Port::forkExec] fork exception"); + throw TC_Port_Exception("[TC_Port::forkExec] fork error:" + TC_Exception::getSystemError()); } if (pid == 0) From ed7527f0ab8fff4aa69e8027ef0efc237a45ce3d Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 6 Mar 2024 10:37:47 +0800 Subject: [PATCH 65/81] feat: add libtarsmock used for framework, used in unittest normally --- CMakeLists.txt | 1 + mock/CMakeLists.txt | 10 + mock/DbHandle.cpp | 667 +++++++++++++++++++++++++++++++++ mock/DbHandle.h | 212 +++++++++++ mock/FrameworkServer.cpp | 25 ++ mock/FrameworkServer.h | 33 ++ mock/QueryImp.cpp | 196 ++++++++++ mock/QueryImp.h | 119 ++++++ mock/TarsMockUtil.cpp | 46 +++ mock/TarsMockUtil.h | 39 ++ mock/framework.h | 39 ++ tools/tarsgrammar/tars.tab.cpp | 266 ++++++------- tools/tarsparse/tars.lex.cpp | 36 +- tools/tarsparse/tars.tab.cpp | 266 ++++++------- 14 files changed, 1671 insertions(+), 284 deletions(-) create mode 100755 mock/CMakeLists.txt create mode 100755 mock/DbHandle.cpp create mode 100755 mock/DbHandle.h create mode 100755 mock/FrameworkServer.cpp create mode 100755 mock/FrameworkServer.h create mode 100755 mock/QueryImp.cpp create mode 100755 mock/QueryImp.h create mode 100644 mock/TarsMockUtil.cpp create mode 100644 mock/TarsMockUtil.h create mode 100644 mock/framework.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 03531a40..b51f1715 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,7 @@ ENDIF() add_subdirectory(util) add_subdirectory(tools) add_subdirectory(servant) +add_subdirectory(mock) IF (NOT ${ONLY_LIB}) add_subdirectory(examples) diff --git a/mock/CMakeLists.txt b/mock/CMakeLists.txt new file mode 100755 index 00000000..a29ebdbf --- /dev/null +++ b/mock/CMakeLists.txt @@ -0,0 +1,10 @@ + +include_directories(../) +file(GLOB_RECURSE SRC_FILES *.cpp) +add_library(tarsmock ${SRC_FILES}) + +add_dependencies(tarsmock tarsservant) +install(DIRECTORY . DESTINATION include/mock FILES_MATCHING PATTERN "*.h") + +install(TARGETS tarsmock RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + diff --git a/mock/DbHandle.cpp b/mock/DbHandle.cpp new file mode 100755 index 00000000..fd68b90e --- /dev/null +++ b/mock/DbHandle.cpp @@ -0,0 +1,667 @@ + +#include +#include +#include "mock/DbHandle.h" + + +////////////////////////////////////////////////////// +// +//typedef map ObjectsCache; + +static ObjectsCache _objectsCache; + +//ObjectsCache CDbHandle::_objectsCache; +CDbHandle::SetDivisionCache CDbHandle::_setDivisionCache; +std::map CDbHandle::_mapGroupPriority; +std::mutex CDbHandle::_mutex; + +//key-ip, value-组编号 +map CDbHandle::_groupIdMap; +//key-group_name, value-组编号 +//map CDbHandle::_groupNameMap; + +int CDbHandle::init(TC_Config *pconf) +{ + return 0; +} + +vector CDbHandle::findObjectById(const string& id) +{ + std::lock_guard lock(_mutex); + + ObjectsCache::iterator it; + ObjectsCache& usingCache = _objectsCache; + + if ((it = usingCache.find(id)) != usingCache.end()) + { + return it->second.vActiveEndpoints; + } + else + { + vector activeEp; + return activeEp; + } +} + + +int CDbHandle::findObjectById4All(const string& id, vector& activeEp, vector& inactiveEp) +{ + + std::lock_guard lock(_mutex); + TLOGDEBUG(__FUNCTION__ << " id: " << id << endl); + + ObjectsCache::iterator it; + ObjectsCache& usingCache = _objectsCache; + + if ((it = usingCache.find(id)) != usingCache.end()) + { + activeEp = it->second.vActiveEndpoints; + inactiveEp = it->second.vInactiveEndpoints; + } + else + { + activeEp.clear(); + inactiveEp.clear(); + } + + return 0; +} + +vector CDbHandle::getEpsByGroupId(const vector& vecEps, const GroupUseSelect GroupSelect, int iGroupId, ostringstream& os) +{ + os << "|"; + vector vResult; + + for (unsigned i = 0; i < vecEps.size(); i++) + { + os << vecEps[i].host << ":" << vecEps[i].port << "(" << vecEps[i].groupworkid << ");"; + if (GroupSelect == ENUM_USE_WORK_GROUPID && vecEps[i].groupworkid == iGroupId) + { + vResult.push_back(vecEps[i]); + } + if (GroupSelect == ENUM_USE_REAL_GROUPID && vecEps[i].grouprealid == iGroupId) + { + vResult.push_back(vecEps[i]); + } + } + + return vResult; +} + +vector CDbHandle::getEpsByGroupId(const vector& vecEps, const GroupUseSelect GroupSelect, const set& setGroupID, ostringstream& os) +{ + os << "|"; + std::vector vecResult; + + for (std::vector::size_type i = 0; i < vecEps.size(); i++) + { + os << vecEps[i].host << ":" << vecEps[i].port << "(" << vecEps[i].groupworkid << ")"; + if (GroupSelect == ENUM_USE_WORK_GROUPID && setGroupID.count(vecEps[i].groupworkid) == 1) + { + vecResult.push_back(vecEps[i]); + } + if (GroupSelect == ENUM_USE_REAL_GROUPID && setGroupID.count(vecEps[i].grouprealid) == 1) + { + vecResult.push_back(vecEps[i]); + } + } + + return vecResult; +} + +int CDbHandle::findObjectByIdInSameGroup(const string& id, const string& ip, vector& activeEp, vector& inactiveEp, ostringstream& os) +{ + activeEp.clear(); + inactiveEp.clear(); + + int iClientGroupId = getGroupId(ip); + + os << "|(" << iClientGroupId << ")"; + + if (iClientGroupId == -1) + { + return findObjectById4All(id, activeEp, inactiveEp); + } + + std::lock_guard lock(_mutex); + ObjectsCache::iterator it; + ObjectsCache& usingCache = _objectsCache; + + if ((it = usingCache.find(id)) != usingCache.end()) + { + activeEp = getEpsByGroupId(it->second.vActiveEndpoints, ENUM_USE_WORK_GROUPID, iClientGroupId, os); + inactiveEp = getEpsByGroupId(it->second.vInactiveEndpoints, ENUM_USE_WORK_GROUPID, iClientGroupId, os); + + if (activeEp.size() == 0) //没有同组的endpoit,匹配未启用分组的服务 + { + activeEp = getEpsByGroupId(it->second.vActiveEndpoints, ENUM_USE_WORK_GROUPID, -1, os); + inactiveEp = getEpsByGroupId(it->second.vInactiveEndpoints, ENUM_USE_WORK_GROUPID, -1, os); + } + if (activeEp.size() == 0) //没有同组的endpoit + { + activeEp = it->second.vActiveEndpoints; + inactiveEp = it->second.vInactiveEndpoints; + } + } + + return 0; +} + +int CDbHandle::findObjectByIdInGroupPriority(const std::string& sID, const std::string& sIP, std::vector& vecActive, std::vector& vecInactive, std::ostringstream& os) +{ + vecActive.clear(); + vecInactive.clear(); + + int iClientGroupID = getGroupId(sIP); + os << "|(" << iClientGroupID << ")"; + if (iClientGroupID == -1) + { + return findObjectById4All(sID, vecActive, vecInactive); + } + + std::lock_guard lock(_mutex); + ObjectsCache& usingCache = _objectsCache; + ObjectsCache::iterator itObject = usingCache.find(sID); + if (itObject == usingCache.end()) return 0; + + //首先在同组中查找 + { + vecActive = getEpsByGroupId(itObject->second.vActiveEndpoints, ENUM_USE_WORK_GROUPID, iClientGroupID, os); + vecInactive = getEpsByGroupId(itObject->second.vInactiveEndpoints, ENUM_USE_WORK_GROUPID, iClientGroupID, os); + os << "|(In Same Group: " << iClientGroupID << " Active=" << vecActive.size() << " Inactive=" << vecInactive.size() << ")"; + } + + //启用分组,但同组中没有找到,在优先级序列中查找 + std::map & mapPriority = _mapGroupPriority; + for (std::map::iterator it = mapPriority.begin(); it != mapPriority.end() && vecActive.empty(); it++) + { + if (it->second.setGroupID.count(iClientGroupID) == 0) + { + os << "|(Not In Priority " << it->second.sGroupID << ")"; + continue; + } + vecActive = getEpsByGroupId(itObject->second.vActiveEndpoints, ENUM_USE_WORK_GROUPID, it->second.setGroupID, os); + vecInactive = getEpsByGroupId(itObject->second.vInactiveEndpoints, ENUM_USE_WORK_GROUPID, it->second.setGroupID, os); + os << "|(In Priority: " << it->second.sGroupID << " Active=" << vecActive.size() << " Inactive=" << vecInactive.size() << ")"; + } + + //没有同组的endpoit,匹配未启用分组的服务 + if (vecActive.empty()) + { + vecActive = getEpsByGroupId(itObject->second.vActiveEndpoints, ENUM_USE_WORK_GROUPID, -1, os); + vecInactive = getEpsByGroupId(itObject->second.vInactiveEndpoints, ENUM_USE_WORK_GROUPID, -1, os); + os << "|(In No Grouop: Active=" << vecActive.size() << " Inactive=" << vecInactive.size() << ")"; + } + + //在未分组的情况下也没有找到,返回全部地址(此时基本上所有的服务都已挂掉) + if (vecActive.empty()) + { + vecActive = itObject->second.vActiveEndpoints; + vecInactive = itObject->second.vInactiveEndpoints; + os << "|(In All: Active=" << vecActive.size() << " Inactive=" << vecInactive.size() << ")"; + } + + return 0; +} + +int CDbHandle::findObjectByIdInSameStation(const std::string& sID, const std::string& sStation, std::vector& vecActive, std::vector& vecInactive, std::ostringstream& os) +{ + vecActive.clear(); + vecInactive.clear(); + + std::lock_guard lock(_mutex); + //获得station所有组 + std::map & mapPriority = _mapGroupPriority; + std::map::iterator itGroup = mapPriority.end(); + for (itGroup = mapPriority.begin(); itGroup != mapPriority.end(); itGroup++) + { + if (itGroup->second.sStation != sStation) continue; + + break; + } + + if (itGroup == mapPriority.end()) + { + os << "|not found station:" << sStation; + return -1; + } + + ObjectsCache& usingCache = _objectsCache; + ObjectsCache::iterator itObject = usingCache.find(sID); + if (itObject == usingCache.end()) return 0; + + //查找对应所有组下的IP地址 + vecActive = getEpsByGroupId(itObject->second.vActiveEndpoints, ENUM_USE_REAL_GROUPID, itGroup->second.setGroupID, os); + vecInactive = getEpsByGroupId(itObject->second.vInactiveEndpoints, ENUM_USE_REAL_GROUPID, itGroup->second.setGroupID, os); + + return 0; +} + +int CDbHandle::findObjectByIdInSameSet(const string& sID, const vector& vtSetInfo, std::vector& vecActive, std::vector& vecInactive, std::ostringstream& os) +{ + string sSetName = vtSetInfo[0]; + string sSetArea = vtSetInfo[0] + "." + vtSetInfo[1]; + string sSetId = vtSetInfo[0] + "." + vtSetInfo[1] + "." + vtSetInfo[2]; + + std::lock_guard lock(_mutex); + SetDivisionCache& usingSetDivisionCache = _setDivisionCache; + SetDivisionCache::iterator it = usingSetDivisionCache.find(sID); + if (it == usingSetDivisionCache.end()) + { + //此情况下没启动set + TLOGINFO("CDbHandle::findObjectByIdInSameSet:" << __LINE__ << "|" << sID << " haven't start set|" << sSetId << endl); + return -1; + } + + map >::iterator setNameIt = it->second.find(sSetName); + if (setNameIt == (it->second).end()) + { + //此情况下没启动set + TLOGINFO("CDbHandle::findObjectByIdInSameSet:" << __LINE__ << "|" << sID << " haven't start set|" << sSetId << endl); + return -1; + } + + if (vtSetInfo[2] == "*") + { + //检索通配组和set组中的所有服务 + vector vServerInfo = setNameIt->second; + for (size_t i = 0; i < vServerInfo.size(); i++) + { + if (vServerInfo[i].sSetArea == sSetArea) + { + if (vServerInfo[i].bActive) + { + vecActive.push_back(vServerInfo[i].epf); + } + else + { + vecInactive.push_back(vServerInfo[i].epf); + } + } + } + + return (vecActive.empty() && vecInactive.empty()) ? -2 : 0; + } + else + { + + // 1.从指定set组中查找 + int iRet = findObjectByIdInSameSet(sSetId, setNameIt->second, vecActive, vecInactive, os); + if (iRet != 0 && vtSetInfo[2] != "*") + { + // 2. 步骤1中没找到,在通配组里找 + string sWildSetId = vtSetInfo[0] + "." + vtSetInfo[1] + ".*"; + iRet = findObjectByIdInSameSet(sWildSetId, setNameIt->second, vecActive, vecInactive, os); + } + + return iRet; + } +} + +int CDbHandle::findObjectByIdInSameSet(const string& sSetId, const vector& vSetServerInfo, std::vector& vecActive, std::vector& vecInactive, std::ostringstream& os) +{ + for (size_t i = 0; i < vSetServerInfo.size(); ++i) + { + if (vSetServerInfo[i].sSetId == sSetId) + { + if (vSetServerInfo[i].bActive) + { + vecActive.push_back(vSetServerInfo[i].epf); + } + else + { + vecInactive.push_back(vSetServerInfo[i].epf); + } + } + } + + int iRet = (vecActive.empty() && vecInactive.empty()) ? -2 : 0; + return iRet; +} + +void CDbHandle::updateObjectsCache(const ObjectsCache& objCache, bool updateAll) +{ + std::lock_guard lock(_mutex); + //全量更新 + if (updateAll) + { + _objectsCache = objCache; + } + else + { + //用查询数据覆盖一下 +// _objectsCache.getWriterData() = _objectsCache.getReaderData(); + ObjectsCache& tmpObjCache = _objectsCache; + + ObjectsCache::const_iterator it = objCache.begin(); + for (; it != objCache.end(); it++) + { + //增量的时候加载的是服务的所有节点,因此这里直接替换 + tmpObjCache[it->first] = it->second; + } +// _objectsCache.swap(); + } +} + +void CDbHandle::updateInactiveObjectsCache(const ObjectsCache& objCache, bool updateAll) +{ + std::lock_guard lock(_mutex); + //全量更新 + if (updateAll) + { + _objectsCache = objCache; +// _objectsCache.swap(); + } + else + { + //用查询数据覆盖一下 +// _objectsCache.getWriterData() = _objectsCache.getReaderData(); + ObjectsCache& tmpObjCache = _objectsCache; + + ObjectsCache::const_iterator it = objCache.begin(); + for (; it != objCache.end(); it++) + { + //增量的时候加载的是服务的所有节点,因此这里直接替换 + tmpObjCache[it->first].vInactiveEndpoints.push_back((it->second).vInactiveEndpoints[0]); + } +// _objectsCache.swap(); + } +} + + +void CDbHandle::updateActiveObjectsCache(const ObjectsCache& objCache, bool updateAll) +{ + std::lock_guard lock(_mutex); + //全量更新 + if (updateAll) + { + _objectsCache = objCache; +// _objectsCache.swap(); + } + else + { + //用查询数据覆盖一下 +// _objectsCache.getWriterData() = _objectsCache.getReaderData(); + ObjectsCache& tmpObjCache = _objectsCache; + + ObjectsCache::const_iterator it = objCache.begin(); + for (; it != objCache.end(); it++) + { + //增量的时候加载的是服务的所有节点,因此这里直接替换 + tmpObjCache[it->first].vActiveEndpoints.push_back((it->second).vActiveEndpoints[0]); + } +// _objectsCache.swap(); + } +} + +void CDbHandle::printActiveEndPoint(const string& objName) +{ + std::lock_guard lock(_mutex); + { + LOG_CONSOLE_DEBUG << "reader data" << endl; + for (auto e : _objectsCache[objName].vActiveEndpoints) + { + LOG_CONSOLE_DEBUG << e.port << endl; + } + } + + { + LOG_CONSOLE_DEBUG << "write data" << endl; + for (auto e : _objectsCache[objName].vActiveEndpoints) + { + LOG_CONSOLE_DEBUG << e.port << endl; + } + } +} + +void CDbHandle::addActiveEndPoint(const string& objName, const Int32 port, const Int32 istcp, const string &nodeName) +{ +#define LOCAL_HOST "127.0.0.1" + ObjectsCache objectsCache; + EndpointF endPoint; + endPoint.host = LOCAL_HOST; + endPoint.port = port; + endPoint.timeout = 30000; + endPoint.istcp = istcp; + endPoint.nodeName = nodeName; + //endPoint.setId = setName + "." + setArea + "." + setGroup; + objectsCache[objName].vActiveEndpoints.push_back(endPoint); + updateActiveObjectsCache(objectsCache, false); +} + +void CDbHandle::addEndPointbySet(const string& objName, const Int32 port, const Int32 istcp, const string& setName, const string& setArea, const string& setGroup) +{ +#define LOCAL_HOST "127.0.0.1" + ObjectsCache objectsCache; + EndpointF endPoint; + endPoint.host = LOCAL_HOST; + endPoint.port = port; + endPoint.timeout = 30000; + endPoint.istcp = istcp; + endPoint.setId = setName + "." + setArea + "." + setGroup; + objectsCache[objName].vActiveEndpoints.push_back(endPoint); + updateActiveObjectsCache(objectsCache, false); + + if (setName.size()) + { + InsertSetRecord(objName, setName, setArea, setGroup, endPoint); + } +} + +void CDbHandle::addActiveWeight1EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName) +{ +#define LOCAL_HOST "127.0.0.1" + ObjectsCache objectsCache; + EndpointF endPoint; + endPoint.host = LOCAL_HOST; + endPoint.port = port; + endPoint.timeout = 30000; + endPoint.istcp = istcp; + endPoint.setId = setName; + endPoint.weight = 2; + endPoint.weightType = 1; + objectsCache[objName].vActiveEndpoints.push_back(endPoint); + updateActiveObjectsCache(objectsCache, false); +} + +void CDbHandle::addInActiveWeight1EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName) +{ +#define LOCAL_HOST "127.0.0.1" + ObjectsCache objectsCache; + EndpointF endPoint; + endPoint.host = LOCAL_HOST; + endPoint.port = port; + endPoint.timeout = 30000; + endPoint.istcp = istcp; + endPoint.setId = setName; + endPoint.weight = 2; + endPoint.weightType = 1; + objectsCache[objName].vInactiveEndpoints.push_back(endPoint); + updateInactiveObjectsCache(objectsCache, false); +} + + +void CDbHandle::addActiveWeight2EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName) +{ +#define LOCAL_HOST "127.0.0.1" + ObjectsCache objectsCache; + EndpointF endPoint; + endPoint.host = LOCAL_HOST; + endPoint.port = port; + endPoint.timeout = 30000; + endPoint.istcp = istcp; + endPoint.setId = setName; + endPoint.weight = 2; + endPoint.weightType = 2; + objectsCache[objName].vActiveEndpoints.push_back(endPoint); + updateActiveObjectsCache(objectsCache, false); +} + + +void CDbHandle::addInactiveEndPoint(const string& objName, const Int32 port, const Int32 istcp, const string &nodeName) +{ +#define LOCAL_HOST "127.0.0.1" + ObjectsCache objectsCache; + EndpointF endPoint; + endPoint.host = LOCAL_HOST; + endPoint.port = port; + endPoint.timeout = 30000; + endPoint.istcp = istcp; + endPoint.nodeName = nodeName; + //endPoint.setId = setName; + objectsCache[objName].vInactiveEndpoints.push_back(endPoint); + updateInactiveObjectsCache(objectsCache, false); + +} + +void CDbHandle::cleanEndPoint() +{ + ObjectsCache objectsCache; + updateObjectsCache(objectsCache, true); +} + +int CDbHandle::getGroupId(const string& ip) +{ + + std::lock_guard lock(_mutex); + map& groupIdMap = _groupIdMap; + map::iterator it = groupIdMap.find(ip); + if (it != groupIdMap.end()) + { + return it->second; + } + + uint32_t uip = stringIpToInt(ip); + string ipStar = Ip2StarStr(uip); + it = groupIdMap.find(ipStar); + if (it != groupIdMap.end()) + { + return it->second; + } + + return -1; +} + +uint32_t CDbHandle::stringIpToInt(const std::string& sip) +{ + string ip1, ip2, ip3, ip4; + uint32_t dip, p1, p2, p3; + dip = 0; + p1 = sip.find('.'); + p2 = sip.find('.', p1 + 1); + p3 = sip.find('.', p2 + 1); + ip1 = sip.substr(0, p1); + ip2 = sip.substr(p1 + 1, p2 - p1 - 1); + ip3 = sip.substr(p2 + 1, p3 - p2 - 1); + ip4 = sip.substr(p3 + 1, sip.size() - p3 - 1); + (((unsigned char *)&dip)[0]) = TC_Common::strto(ip1); + (((unsigned char *)&dip)[1]) = TC_Common::strto(ip2); + (((unsigned char *)&dip)[2]) = TC_Common::strto(ip3); + (((unsigned char *)&dip)[3]) = TC_Common::strto(ip4); + return htonl(dip); +} + +string CDbHandle::Ip2Str(uint32_t ip) +{ + char str[50]; + unsigned char *p = (unsigned char *)&ip; + sprintf(str, "%u.%u.%u.%u", p[3], p[2], p[1], p[0]); + return string(str); +} + +string CDbHandle::Ip2StarStr(uint32_t ip) +{ + char str[50]; + unsigned char *p = (unsigned char *)&ip; + sprintf(str, "%u.%u.%u.*", p[3], p[2], p[1]); + return string(str); +} + + +void CDbHandle::InsertSetRecord(const string& objName, const string& setName, const string& setArea, const string& setGroup, EndpointF epf) +{ + SetDivisionCache setDivisionCache; + + string setId = setName + "." + setArea + "." + setGroup; + SetServerInfo setServerInfo; + setServerInfo.bActive = true; + setServerInfo.epf = epf; + + setServerInfo.sSetId = setId; + setServerInfo.sSetArea = setArea; + + setDivisionCache[objName][setName].push_back(setServerInfo); + + setServerInfo.bActive = false; + setServerInfo.epf.port = 10204; + + setDivisionCache[objName][setName].push_back(setServerInfo); + + updateDivisionCache(setDivisionCache, true); +} + + +void CDbHandle::InsertSetRecord4Inactive(const string& objName, const string& setName, const string& setArea, const string& setGroup, EndpointF epf) +{ + SetDivisionCache setDivisionCache; + + string setId = setName + "." + setArea + "." + setGroup; + SetServerInfo setServerInfo; + setServerInfo.bActive = false; + setServerInfo.epf = epf; + + setServerInfo.sSetId = setId; + setServerInfo.sSetArea = setArea; + + setDivisionCache[objName][setName].push_back(setServerInfo); + + updateDivisionCache(setDivisionCache, false); +} + + +void CDbHandle::updateDivisionCache(SetDivisionCache& setDivisionCache,bool updateAll) +{ + std::lock_guard lock(_mutex); + if(updateAll) + { + if (setDivisionCache.size() == 0) + { + return; + } + SetDivisionCache::iterator it = setDivisionCache.begin(); + for(;it != setDivisionCache.end();it++) + { + if(it->second.size() > 0) + { + map >::iterator it_inner = it->second.begin(); + for(;it_inner != it->second.end();it_inner++) + { + //updateCpuLoadInfo(it_inner->second); + } + } + } + _setDivisionCache = setDivisionCache; +// _setDivisionCache.swap(); + } + else + { +// _setDivisionCache.getWriterData() = _setDivisionCache.getReaderData(); + SetDivisionCache& tmpsetCache = _setDivisionCache; + SetDivisionCache::const_iterator it = setDivisionCache.begin(); + for(;it != setDivisionCache.end();it++) + { + //��set��Ϣ�Ÿ��� + if(it->second.size() > 0) + { + tmpsetCache[it->first] = it->second; + } + else if(tmpsetCache.count(it->first)) + { + tmpsetCache.erase(it->first); + } + + } + +// _setDivisionCache.swap(); + } +} diff --git a/mock/DbHandle.h b/mock/DbHandle.h new file mode 100755 index 00000000..9c815636 --- /dev/null +++ b/mock/DbHandle.h @@ -0,0 +1,212 @@ + + +#pragma once + +#include "util/tc_common.h" +#include "util/tc_config.h" +#include "util/tc_monitor.h" +#include "util/tc_file.h" +#include "jmem/jmem_hashmap.h" +#include "util/tc_readers_writer_data.h" +#include +#include "servant/RemoteLogger.h" +#include "servant/EndpointF.h" + +using namespace tars; + +namespace tars +{ + struct ObjectItem; +} +typedef map ObjectsCache; + +////////////////////////////////////////////////////// +/** + * 数据库操作类 + */ +class CDbHandle +{ +private: + struct GroupPriorityEntry + { + std::string sGroupID; + std::string sStation; + std::set setGroupID; + }; + + enum GroupUseSelect + { + ENUM_USE_WORK_GROUPID, + ENUM_USE_REAL_GROUPID + }; + //set中服务的信息 + struct SetServerInfo + { + string sSetId; + string sSetArea; + bool bActive; + EndpointF epf; + }; + // + typedef map > > SetDivisionCache; + +public: + /** + * 构造函数 + */ + CDbHandle() + { + } + + /** + * 初始化 + * @param pconf 配置文件 + * @return 0-成功 others-失败 + */ + int init(TC_Config *pconf); + + /** 根据id获取对象 + * + * @param id 对象名称 + * + * @return 返回所有该对象的活动endpoint列表 + */ + vector findObjectById(const string & id); + + /** 根据id获取对象 + * + * @param id 对象名称 + * @out param activeEp 存活的列表 + * @out param inactiveEp 非存活的列表 + * + * @return 0-成功 others-失败 + */ + int findObjectById4All(const string & id, vector& activeEp, vector& inactiveEp); + + /** 根据id获取同组对象 + * + * @param id 对象名称 + * @param ip + * @out param activeEp 存活的列表 + * @out param inactiveEp 非存活的列表 + * @out param os 打印日志使用 + * + * @return 0-成功 others-失败 + */ + int findObjectByIdInSameGroup(const string & id, const string & ip, vector& activeEp, vector& inactiveEp, ostringstream &os); + + /** 根据id获取优先级序列中的对象 + * + * @param id 对象名称 + * @param ip + * @out param vecActive 存活的列表 + * @out param vecInactive 非存活的列表 + * @out param os 打印日志使用 + * + * @return 0-成功 others-失败 + */ + int findObjectByIdInGroupPriority(const std::string &sID, const std::string &sIP, std::vector & vecActive, std::vector & vecInactive, std::ostringstream & os); + + /** 根据id和归属地获取全部对象 + * + * @param id 对象名称 + * @param sStation 归属地 + * @out param vecActive 存活的列表 + * @out param vecInactive 非存活的列表 + * @out param os 打印日志使用 + * + * @return 0-成功 others-失败 + */ + int findObjectByIdInSameStation(const std::string &sID, const std::string & sStation, std::vector & vecActive, std::vector & vecInactive, std::ostringstream & os); + + /** 根据id和set信息获取全部对象 + * + * @param sID 对象名称 + * @param vtSetInfo set信息 + * @out param vecActive 存活的列表 + * @out param vecInactive 非存活的列表 + * @out param os 打印日志使用 + * + * @return 0-成功 others-失败 + */ + int findObjectByIdInSameSet(const string &sID, const vector &vtSetInfo, std::vector & vecActive, std::vector & vecInactive, std::ostringstream & os); + + /** 根据setId获取全部对象 + * + * @param sSetId set名称 + * @param vSetServerInfo SetName下部署的服务信息 + * @out param vecActive 存活的列表 + * @out param vecInactive 非存活的列表 + * @out param os 打印日志使用 + * + * @return 0-成功 others-失败 + */ + int findObjectByIdInSameSet(const string &sSetId, const vector& vSetServerInfo, std::vector & vecActive, std::vector & vecInactive, std::ostringstream & os); + /** + * 根据ip获取组id + * @return int <0 失败 其它正常 + */ + int getGroupId(const string& ip); + /** + * ip转换 + */ + static uint32_t stringIpToInt(const std::string& sip); + + /** + * ip转换 + */ + static string Ip2Str(uint32_t ip); + + /** + * ip转换 + */ + static string Ip2StarStr(uint32_t ip); + + static void InsertSetRecord(const string& objName, const string& setName, const string& setArea, const string& setGroup, EndpointF epf); + + static void InsertSetRecord4Inactive(const string& objName, const string& setName, const string& setArea, const string& setGroup, EndpointF epf); + + static void addActiveEndPoint(const string& objName, const Int32 port, const Int32 istcp, const string &nodeName = ""); + + static void addInactiveEndPoint(const string& objName, const Int32 port, const Int32 istcp, const string &nodeName = ""); + + static void addEndPointbySet(const string& objName, const Int32 port, const Int32 istcp, const string& setName, const string& setArea, const string& setGroup); + + static void addActiveWeight1EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName = ""); + + static void addInActiveWeight1EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName = ""); + + static void addActiveWeight2EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName = ""); + + static void cleanEndPoint(); + + static void printActiveEndPoint(const string& objName); + +protected: + + static void updateObjectsCache(const ObjectsCache& objCache, bool updateAll); + + static void updateActiveObjectsCache(const ObjectsCache& objCache, bool updateAll); + + static void updateInactiveObjectsCache(const ObjectsCache& objCache, bool updateAll); + + static void updateDivisionCache(SetDivisionCache& setDivisionCache,bool updateAll); + + /** + * 根据group id获取Endpoint + */ + vector getEpsByGroupId(const vector & vecEps, const GroupUseSelect GroupSelect, int iGroupId, ostringstream &os); + + vector getEpsByGroupId(const vector & vecEps, const GroupUseSelect GroupSelect, const set & setGroupID, ostringstream & os); + +protected: + + static std::mutex _mutex; + //set划分缓存 + static SetDivisionCache _setDivisionCache; + //优先级的序列 + static std::map _mapGroupPriority; + //分组信息 + static map _groupIdMap; +}; + diff --git a/mock/FrameworkServer.cpp b/mock/FrameworkServer.cpp new file mode 100755 index 00000000..2996fd1d --- /dev/null +++ b/mock/FrameworkServer.cpp @@ -0,0 +1,25 @@ +#include "mock/FrameworkServer.h" +#include "mock/QueryImp.h" + +using namespace std; + +FrameworkServer::~FrameworkServer() +{ + +} + + +void +FrameworkServer::initialize() +{ + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".QueryObj"); +} + +void FrameworkServer::destroyApp() +{ +} + +void FrameworkServer::run() +{ + waitForShutdown(); +} diff --git a/mock/FrameworkServer.h b/mock/FrameworkServer.h new file mode 100755 index 00000000..da264df4 --- /dev/null +++ b/mock/FrameworkServer.h @@ -0,0 +1,33 @@ +#pragma once + +#include +#include "servant/Application.h" + +using namespace tars; + +extern vector> _clientStatData; +extern vector> _serverStatData; + +class FrameworkServer : public Application, public TC_Thread +{ +public: + /** + * 析构函数 + **/ + virtual ~FrameworkServer(); + + /** + * 服务初始化 + **/ + virtual void initialize(); + + /** + * 服务销毁 + **/ + virtual void destroyApp(); + +protected: + virtual void run(); +}; + + diff --git a/mock/QueryImp.cpp b/mock/QueryImp.cpp new file mode 100755 index 00000000..c66e3e4c --- /dev/null +++ b/mock/QueryImp.cpp @@ -0,0 +1,196 @@ + + +#include "mock/QueryImp.h" +#include "util/tc_clientsocket.h" + +void QueryImp::initialize() +{ + TLOGDEBUG("begin QueryImp init"< QueryImp::findObjectById(const string & id, tars::CurrentPtr current) +{ + LOG_CONSOLE_DEBUG << endl; + vector eps = _db.findObjectById(id); + + ostringstream os; + doDaylog(FUNID_findObjectById,id,eps,vector(),current,os); + + return eps; +} + +tars::Int32 QueryImp::findObjectById4Any(const std::string & id,vector &activeEp,vector &inactiveEp,tars::CurrentPtr current) +{ + LOG_CONSOLE_DEBUG << endl; + int iRet = _db.findObjectById4All(id, activeEp, inactiveEp); + + ostringstream os; + doDaylog(FUNID_findObjectById4Any,id,activeEp,inactiveEp,current,os); + + return iRet; +} + +int QueryImp::findObjectById4All(const std::string & id, vector &activeEp,vector &inactiveEp,tars::CurrentPtr current) +{ +// LOG_CONSOLE_DEBUG << endl; + ostringstream os; + + int iRet = _db.findObjectByIdInGroupPriority(id,current->getIp(),activeEp, inactiveEp,os); + +// LOG_CONSOLE_DEBUG << id << ", " << activeEp.size() << endl; + + doDaylog(FUNID_findObjectById4All,id,activeEp,inactiveEp,current,os); + + return iRet; +} + +int QueryImp::findObjectByIdInSameGroup(const std::string & id, vector &activeEp,vector &inactiveEp, tars::CurrentPtr current) +{ +// LOG_CONSOLE_DEBUG << endl; + ostringstream os; + TLOGINFO(__FUNCTION__ << ":" << __LINE__ << "|" << id << "|" << current->getIp() << endl); + + int iRet = _db.findObjectByIdInGroupPriority(id, current->getIp(), activeEp, inactiveEp, os); + + doDaylog(FUNID_findObjectByIdInSameGroup,id,activeEp,inactiveEp,current,os); + + return iRet; +} + +Int32 QueryImp::findObjectByIdInSameStation(const std::string & id, const std::string & sStation, vector &activeEp, vector &inactiveEp, tars::CurrentPtr current) +{ + LOG_CONSOLE_DEBUG << endl; + ostringstream os; + + int iRet = _db.findObjectByIdInSameStation(id, sStation, activeEp, inactiveEp, os); + + doDaylog(FUNID_findObjectByIdInSameStation,id,activeEp,inactiveEp,current,os); + + return iRet; +} + +Int32 QueryImp::findObjectByIdInSameSet(const std::string & id,const std::string & setId,vector &activeEp,vector &inactiveEp, tars::CurrentPtr current) +{ + LOG_CONSOLE_DEBUG << endl; + vector vtSetInfo = TC_Common::sepstr(setId,"."); + + if (vtSetInfo.size()!=3 ||(vtSetInfo.size()==3&&(vtSetInfo[0]=="*"||vtSetInfo[1]=="*"))) + { + TLOGERROR("QueryImp::findObjectByIdInSameSet:|set full name error[" << id << "_" << setId <<"]|" << current->getIp() << endl); + return -1; + } + + ostringstream os; + int iRet = _db.findObjectByIdInSameSet(id, vtSetInfo, activeEp, inactiveEp, os); + if (-1 == iRet) + { + //未启动set,启动ip分组策略 + return findObjectByIdInSameGroup(id, activeEp, inactiveEp, current); + } + else if (-2 == iRet) + { + //启动了set,但未找到任何服务节点 + TLOGERROR("QueryImp::findObjectByIdInSameSet |no one server found for [" << id << "_" << setId <<"]|" << current->getIp() << endl); + return -1; + } + else if (-3 == iRet) + { + //启动了set,但未找到任何地区set,严格上不应该出现此类情形,配置错误或主调设置错误会引起此类错误 + TLOGERROR("QueryImp::findObjectByIdInSameSet |no set area found [" << id << "_" << setId <<"]|" << current->getIp() << endl); + return -1; + } + + doDaylog(FUNID_findObjectByIdInSameSet,id,activeEp,inactiveEp,current,os,setId); + + return iRet; +} + +void QueryImp::doDaylog(const FUNID eFnId,const string& id,const vector &activeEp, const vector &inactiveEp, const tars::CurrentPtr& current,const ostringstream& os,const string& sSetid) +{ + string sEpList; + for(size_t i = 0; i < activeEp.size(); i++) + { + if(0 != i) + { + sEpList += ";"; + } + sEpList += activeEp[i].host + ":" + TC_Common::tostr(activeEp[i].port); + } + + sEpList += "|"; + + for(size_t i = 0; i < inactiveEp.size(); i++) + { + if(0 != i) + { + sEpList += ";"; + } + sEpList += inactiveEp[i].host + ":" + TC_Common::tostr(inactiveEp[i].port); + } + + switch(eFnId) + { + case FUNID_findObjectById4All: + case FUNID_findObjectByIdInSameGroup: + { + FDLOG("query_idc") << eFunTostr(eFnId)<<"|"<getIp() << "|"<< current->getPort() << "|" << id << "|" <getIp() << "|"<< current->getPort() << "|" << id << "|" <getIp() << "|"<< current->getPort() << "|" << id << "|" < &nodeName,tars::TarsCurrentPtr current) { return -1; } + + /** + * 根据id获取所有该对象的活动endpoint列表 + */ + virtual vector findObjectById(const string & id, tars::CurrentPtr current); + + /** + * 根据id获取所有对象,包括活动和非活动对象 + */ + virtual tars::Int32 findObjectById4Any(const std::string & id, vector &activeEp, vector &inactiveEp, tars::CurrentPtr current); + + /** + * 根据id获取对象所有endpoint列表 + */ + Int32 findObjectById4All(const std::string & id, vector &activeEp, vector &inactiveEp, tars::CurrentPtr current); + + /** + * 根据id获取对象同组endpoint列表 + */ + Int32 findObjectByIdInSameGroup(const std::string & id, vector &activeEp, vector &inactiveEp, tars::CurrentPtr current); + + /** + * 根据id获取对象指定归属地的endpoint列表 + */ + Int32 findObjectByIdInSameStation(const std::string & id, const std::string & sStation, vector &activeEp, vector &inactiveEp, tars::CurrentPtr current); + + /** + * 根据id获取对象同set endpoint列表 + */ + Int32 findObjectByIdInSameSet(const std::string & id,const std::string & setId,vector &activeEp,vector &inactiveEp, tars::CurrentPtr current); + + /** 注册id变化的通知, 通知时会通知所有的变化内容(企业版功能) + * + * @param ids 对象名称 + * @param name 当前模块名称 + * @return: 0-成功 others-失败 + */ + Int32 registerChange(const map & heartbeat, const string &name, CurrentPtr current) { return -1; }; + + /** 注册id变化的通知, 通知时后需要自己主动find(企业版功能) + * + * @param id 对象名称 + * @param name 当前模块名称 + * @return: 0-成功 others-失败 + */ + Int32 registerQuery(const string &id, const string &name, CurrentPtr current) { return -1; }; + + /** + * 获取锁, 实现业务服务一主多备的模式(企业版功能) + * @return 0: 获取锁成功; 1:获取锁失败; 2: 数据异常, -1:其他异常 + */ + Int32 getLocker(const tars::GetMasterSlaveLock &req, CurrentPtr current) { return -1;}; + +private: + /** + * 打印按天日志 + */ + void doDaylog(const FUNID eFnId,const string& id,const vector &activeEp, const vector &inactiveEp, const tars::CurrentPtr& current,const std::ostringstream& os,const string& sSetid=""); + + /** + * 转化成字符串 + */ + string eFunTostr(const FUNID eFnId); +protected: + //数据库操作 + CDbHandle _db; +}; + diff --git a/mock/TarsMockUtil.cpp b/mock/TarsMockUtil.cpp new file mode 100644 index 00000000..d065b925 --- /dev/null +++ b/mock/TarsMockUtil.cpp @@ -0,0 +1,46 @@ +// +// Created by jarod on 2024/3/6. +// + +#include "mock/TarsMockUtil.h" +#include "mock/FrameworkServer.h" +#include "mock/framework.h" + +TarsMockUtil::TarsMockUtil() +{ + _fs = std::make_shared(); +} + +void TarsMockUtil::startFramework() +{ + _fs->main(FRAMEWORK_CONFIG); + _fs->start(); + _fs->waitForReady(); +} + +void TarsMockUtil::stopFramework() +{ + _fs->terminate(); +} + +void TarsMockUtil::refreshRegistry(const string &obj, size_t count) +{ + do + { + TC_Common::sleep(1); + + vector activeEp; + vector inactiveEp; + + _fs->getApplicationCommunicator()->getLocatorPrx()->findObjectById4All(obj, activeEp, inactiveEp); + + auto eps1 = EndpointInfo::toNodeEndpointF(activeEp); + + if(eps1.size() == count) + { + break; + } + + }while(true); +} + diff --git a/mock/TarsMockUtil.h b/mock/TarsMockUtil.h new file mode 100644 index 00000000..2eaad1fd --- /dev/null +++ b/mock/TarsMockUtil.h @@ -0,0 +1,39 @@ +// +// Created by jarod on 2024/3/6. +// + +#pragma once + +#include +#include + +class FrameworkServer; + +class TarsMockUtil +{ +public: + TarsMockUtil(); + + /** + * 启动framework + * @param fs + */ + void startFramework(); + + /** + * 停止framework + * @param fs + */ + void stopFramework(); + + /** + * 等待主控返回count个服务 + * @param obj + * @param count + */ + void refreshRegistry(const std::string &obj, size_t count); + +protected: + std::shared_ptr _fs; +}; + diff --git a/mock/framework.h b/mock/framework.h new file mode 100644 index 00000000..1dd2e77f --- /dev/null +++ b/mock/framework.h @@ -0,0 +1,39 @@ +#pragma once + +#define FRAMEWORK_CONFIG " \n\ + \n\ + \n\ + locator = raft.FrameworkServer.QueryObj@tcp -h 127.0.0.1 -p 13004 \n \ + sync-invoke-timeout = 5000 \n \ + async-invoke-timeout = 60000 \n \ + refresh-endpoint-interval = 5000 \n \ + sendqueuelimit = 1000000 \n \ + asyncqueuecap = 1000000 \n \ + asyncthread = 3 \n \ + netthread = 2 \n \ + mergenetasync = 0 \n \ + modulename = raft.FrameworkServer \n \ + \n \ + \n \ + start_output = ERROR \n \ + closecout = 0 \n \ + app = raft \n \ + server = FrameworkServer \n \ + basepath = . \n \ + datapath = . \n \ + logpath = . \n \ + netthread = 1 \n \ + mergenetimp = 0 \n \ + opencoroutine = 0 \n \ + loglevel=TARS \n \ + \n \ + endpoint = tcp -h 127.0.0.1 -p 13004 -t 60000 \n \ + allow = \n \ + maxconns = 4096 \n \ + threads = 5 \n \ + servant = raft.FrameworkServer.QueryObj \n \ + queuecap = 1000000 \n \ + \n \ + \n \ + \n\ +" diff --git a/tools/tarsgrammar/tars.tab.cpp b/tools/tarsgrammar/tars.tab.cpp index 869dd6a2..4647924b 100644 --- a/tools/tarsgrammar/tars.tab.cpp +++ b/tools/tarsgrammar/tars.tab.cpp @@ -67,7 +67,7 @@ /* First part of user prologue. */ -#line 17 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 17 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" #include #include @@ -1384,14 +1384,14 @@ yyparse (void) switch (yyn) { case 3: /* $@1: %empty */ -#line 75 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 75 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1391 "tars.tab.cpp" break; case 5: /* $@2: %empty */ -#line 79 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 79 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyerrok; } @@ -1399,7 +1399,7 @@ yyparse (void) break; case 7: /* definitions: definition */ -#line 84 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 84 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } @@ -1407,14 +1407,14 @@ yyparse (void) break; case 8: /* definitions: %empty */ -#line 88 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 88 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1414 "tars.tab.cpp" break; case 9: /* definition: namespace_def */ -#line 96 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 96 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || NamespacePtr::dynamicCast(yyvsp[0])); } @@ -1422,7 +1422,7 @@ yyparse (void) break; case 10: /* definition: interface_def */ -#line 100 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 100 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || InterfacePtr::dynamicCast(yyvsp[0])); } @@ -1430,7 +1430,7 @@ yyparse (void) break; case 11: /* definition: struct_def */ -#line 104 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 104 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || StructPtr::dynamicCast(yyvsp[0])); } @@ -1438,14 +1438,14 @@ yyparse (void) break; case 12: /* definition: key_def */ -#line 108 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 108 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1445 "tars.tab.cpp" break; case 13: /* definition: enum_def */ -#line 111 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 111 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || EnumPtr::dynamicCast(yyvsp[0])); } @@ -1453,7 +1453,7 @@ yyparse (void) break; case 14: /* definition: const_def */ -#line 115 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 115 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || ConstPtr::dynamicCast(yyvsp[0])); } @@ -1461,7 +1461,7 @@ yyparse (void) break; case 15: /* @3: %empty */ -#line 124 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 124 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1469,7 +1469,7 @@ yyparse (void) break; case 16: /* enum_def: enum_id @3 '{' enumerator_list '}' */ -#line 128 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 128 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1487,7 +1487,7 @@ yyparse (void) break; case 17: /* enum_id: TARS_ENUM TARS_IDENTIFIER */ -#line 147 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 147 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { NamespacePtr c = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!c) @@ -1504,7 +1504,7 @@ yyparse (void) break; case 18: /* enum_id: TARS_ENUM keyword */ -#line 160 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 160 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumeration name"); @@ -1514,7 +1514,7 @@ yyparse (void) break; case 19: /* enumerator_list: enumerator ',' enumerator_list */ -#line 171 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 171 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[-1]; } @@ -1522,14 +1522,14 @@ yyparse (void) break; case 20: /* enumerator_list: enumerator */ -#line 175 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 175 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1529 "tars.tab.cpp" break; case 21: /* enumerator: TARS_IDENTIFIER */ -#line 183 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 183 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1544,7 +1544,7 @@ yyparse (void) break; case 22: /* enumerator: keyword */ -#line 194 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 194 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumerator"); @@ -1553,7 +1553,7 @@ yyparse (void) break; case 23: /* enumerator: TARS_IDENTIFIER '=' const_initializer */ -#line 199 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 199 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -1570,14 +1570,14 @@ yyparse (void) break; case 24: /* enumerator: %empty */ -#line 212 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 212 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1577 "tars.tab.cpp" break; case 25: /* @4: %empty */ -#line 220 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 220 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ContainerPtr c = g_parse->currentContainer(); @@ -1596,7 +1596,7 @@ yyparse (void) break; case 26: /* namespace_def: TARS_NAMESPACE TARS_IDENTIFIER @4 '{' definitions '}' */ -#line 235 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 235 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1612,7 +1612,7 @@ yyparse (void) break; case 27: /* $@5: %empty */ -#line 253 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 253 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-1]); StructPtr sp = StructPtr::dynamicCast(g_parse->findUserType(ident->v)); @@ -1627,14 +1627,14 @@ yyparse (void) break; case 28: /* key_def: TARS_KEY '[' scoped_name ',' $@5 key_members ']' */ -#line 264 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 264 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1634 "tars.tab.cpp" break; case 29: /* key_members: TARS_IDENTIFIER */ -#line 272 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 272 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1651,7 +1651,7 @@ yyparse (void) break; case 30: /* key_members: key_members ',' TARS_IDENTIFIER */ -#line 285 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 285 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1668,7 +1668,7 @@ yyparse (void) break; case 31: /* @6: %empty */ -#line 304 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 304 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1689,7 +1689,7 @@ yyparse (void) break; case 32: /* interface_def: interface_id @6 '{' interface_exports '}' */ -#line 321 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 321 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1705,7 +1705,7 @@ yyparse (void) break; case 33: /* interface_id: TARS_INTERFACE TARS_IDENTIFIER */ -#line 338 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 338 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1713,7 +1713,7 @@ yyparse (void) break; case 34: /* interface_id: TARS_INTERFACE keyword */ -#line 342 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 342 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as interface name"); @@ -1723,21 +1723,21 @@ yyparse (void) break; case 35: /* interface_exports: interface_export ';' interface_exports */ -#line 353 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 353 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1730 "tars.tab.cpp" break; case 36: /* interface_exports: error ';' interface_exports */ -#line 356 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 356 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1737 "tars.tab.cpp" break; case 37: /* interface_exports: interface_export */ -#line 359 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 359 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } @@ -1745,14 +1745,14 @@ yyparse (void) break; case 38: /* interface_exports: %empty */ -#line 363 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 363 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1752 "tars.tab.cpp" break; case 40: /* operation: operation_preamble parameters ')' */ -#line 377 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 377 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1768,7 +1768,7 @@ yyparse (void) break; case 41: /* operation_preamble: return_type TARS_OP */ -#line 394 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 394 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1796,7 +1796,7 @@ yyparse (void) break; case 43: /* return_type: TARS_VOID */ -#line 424 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 424 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = 0; } @@ -1804,14 +1804,14 @@ yyparse (void) break; case 44: /* parameters: %empty */ -#line 434 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 434 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1811 "tars.tab.cpp" break; case 45: /* parameters: type_id */ -#line 437 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 437 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1826,7 +1826,7 @@ yyparse (void) break; case 46: /* parameters: parameters ',' type_id */ -#line 448 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 448 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1841,7 +1841,7 @@ yyparse (void) break; case 47: /* parameters: out_qualifier type_id */ -#line 459 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 459 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1857,7 +1857,7 @@ yyparse (void) break; case 48: /* parameters: parameters ',' out_qualifier type_id */ -#line 471 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 471 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1873,7 +1873,7 @@ yyparse (void) break; case 49: /* parameters: routekey_qualifier type_id */ -#line 483 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 483 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1889,7 +1889,7 @@ yyparse (void) break; case 50: /* parameters: parameters ',' routekey_qualifier type_id */ -#line 495 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 495 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1905,7 +1905,7 @@ yyparse (void) break; case 51: /* parameters: out_qualifier */ -#line 507 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 507 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("'out' must be defined with a type"); } @@ -1913,7 +1913,7 @@ yyparse (void) break; case 52: /* parameters: routekey_qualifier */ -#line 511 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 511 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("'routekey' must be defined with a type"); } @@ -1921,7 +1921,7 @@ yyparse (void) break; case 53: /* routekey_qualifier: TARS_ROUTE_KEY */ -#line 520 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 520 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr routekey = new BoolGrammar; routekey->v = true; @@ -1931,7 +1931,7 @@ yyparse (void) break; case 54: /* out_qualifier: TARS_OUT */ -#line 531 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 531 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr out = new BoolGrammar; out->v = true; @@ -1941,7 +1941,7 @@ yyparse (void) break; case 55: /* @7: %empty */ -#line 542 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 542 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); @@ -1967,7 +1967,7 @@ yyparse (void) break; case 56: /* struct_def: struct_id @7 '{' struct_exports '}' */ -#line 564 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 564 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1986,7 +1986,7 @@ yyparse (void) break; case 57: /* struct_id: TARS_STRUCT TARS_IDENTIFIER */ -#line 584 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 584 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1994,7 +1994,7 @@ yyparse (void) break; case 58: /* struct_id: TARS_STRUCT keyword */ -#line 588 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 588 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2004,7 +2004,7 @@ yyparse (void) break; case 59: /* struct_id: TARS_STRUCT error */ -#line 594 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 594 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("abstract declarator '' used as declaration"); } @@ -2012,7 +2012,7 @@ yyparse (void) break; case 60: /* struct_exports: data_member ';' struct_exports */ -#line 603 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 603 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } @@ -2020,7 +2020,7 @@ yyparse (void) break; case 61: /* struct_exports: data_member */ -#line 607 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 607 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("';' missing after definition"); } @@ -2028,14 +2028,14 @@ yyparse (void) break; case 62: /* struct_exports: %empty */ -#line 611 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 611 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2035 "tars.tab.cpp" break; case 63: /* data_member: struct_type_id */ -#line 621 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 621 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2043,7 +2043,7 @@ yyparse (void) break; case 64: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id */ -#line 630 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 630 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2065,7 +2065,7 @@ yyparse (void) break; case 65: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id '=' const_initializer */ -#line 648 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 648 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2091,7 +2091,7 @@ yyparse (void) break; case 66: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id '=' const_initializer */ -#line 670 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 670 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2117,7 +2117,7 @@ yyparse (void) break; case 67: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id */ -#line 692 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 692 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2138,7 +2138,7 @@ yyparse (void) break; case 68: /* struct_type_id: TARS_REQUIRE type_id */ -#line 709 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 709 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } @@ -2146,7 +2146,7 @@ yyparse (void) break; case 69: /* struct_type_id: TARS_OPTIONAL type_id */ -#line 713 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 713 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } @@ -2154,7 +2154,7 @@ yyparse (void) break; case 70: /* struct_type_id: TARS_CONST_INTEGER type_id */ -#line 717 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 717 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'require' or 'optional'"); } @@ -2162,7 +2162,7 @@ yyparse (void) break; case 71: /* struct_type_id: type_id */ -#line 721 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 721 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag' or 'require' or 'optional'"); } @@ -2170,7 +2170,7 @@ yyparse (void) break; case 72: /* const_initializer: TARS_CONST_INTEGER */ -#line 730 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 730 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { IntergerGrammarPtr intVal = IntergerGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2184,7 +2184,7 @@ yyparse (void) break; case 73: /* const_initializer: TARS_CONST_FLOAT */ -#line 740 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 740 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { FloatGrammarPtr floatVal = FloatGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2198,7 +2198,7 @@ yyparse (void) break; case 74: /* const_initializer: TARS_STRING_LITERAL */ -#line 750 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 750 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2210,7 +2210,7 @@ yyparse (void) break; case 75: /* const_initializer: TARS_FALSE */ -#line 758 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 758 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2222,7 +2222,7 @@ yyparse (void) break; case 76: /* const_initializer: TARS_TRUE */ -#line 766 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 766 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2234,7 +2234,7 @@ yyparse (void) break; case 77: /* const_initializer: TARS_IDENTIFIER */ -#line 774 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 774 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2251,7 +2251,7 @@ yyparse (void) break; case 78: /* const_initializer: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 787 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 787 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2270,7 +2270,7 @@ yyparse (void) break; case 79: /* const_def: TARS_CONST type_id '=' const_initializer */ -#line 807 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 807 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!np) @@ -2287,7 +2287,7 @@ yyparse (void) break; case 80: /* type_id: type TARS_IDENTIFIER */ -#line 825 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 825 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2300,7 +2300,7 @@ yyparse (void) break; case 81: /* type_id: type TARS_IDENTIFIER '[' TARS_CONST_INTEGER ']' */ -#line 834 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 834 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-4])); IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast(yyvsp[-1]); @@ -2314,7 +2314,7 @@ yyparse (void) break; case 82: /* type_id: type '*' TARS_IDENTIFIER */ -#line 844 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 844 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-2])); //IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast($4); @@ -2328,7 +2328,7 @@ yyparse (void) break; case 83: /* type_id: type TARS_IDENTIFIER ':' TARS_CONST_INTEGER */ -#line 854 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 854 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-3]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2341,7 +2341,7 @@ yyparse (void) break; case 84: /* type_id: type keyword */ -#line 863 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 863 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as data member name"); @@ -2350,7 +2350,7 @@ yyparse (void) break; case 85: /* type_id: type */ -#line 868 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 868 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("missing data member name"); } @@ -2358,7 +2358,7 @@ yyparse (void) break; case 86: /* type_id: error */ -#line 872 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 872 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("unkown type"); } @@ -2366,7 +2366,7 @@ yyparse (void) break; case 87: /* type: type_no ':' TARS_CONST_INTEGER */ -#line 881 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 881 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-2]); @@ -2379,7 +2379,7 @@ yyparse (void) break; case 88: /* type: type_no */ -#line 890 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 890 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -2387,7 +2387,7 @@ yyparse (void) break; case 89: /* type: type_no ':' error */ -#line 894 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 894 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("array missing size"); } @@ -2395,7 +2395,7 @@ yyparse (void) break; case 90: /* type_no: TARS_BOOL */ -#line 903 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 903 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindBool); } @@ -2403,7 +2403,7 @@ yyparse (void) break; case 91: /* type_no: TARS_BYTE */ -#line 907 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 907 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindByte); } @@ -2411,7 +2411,7 @@ yyparse (void) break; case 92: /* type_no: TARS_UNSIGNED TARS_BYTE */ -#line 911 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 911 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort,true); } @@ -2419,7 +2419,7 @@ yyparse (void) break; case 93: /* type_no: TARS_SHORT */ -#line 915 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 915 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort); } @@ -2427,7 +2427,7 @@ yyparse (void) break; case 94: /* type_no: TARS_UNSIGNED TARS_SHORT */ -#line 919 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 919 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt,true); } @@ -2435,7 +2435,7 @@ yyparse (void) break; case 95: /* type_no: TARS_INT */ -#line 923 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 923 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt); } @@ -2443,7 +2443,7 @@ yyparse (void) break; case 96: /* type_no: TARS_UNSIGNED TARS_INT */ -#line 927 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 927 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong,true); } @@ -2451,7 +2451,7 @@ yyparse (void) break; case 97: /* type_no: TARS_LONG */ -#line 931 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 931 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong); } @@ -2459,7 +2459,7 @@ yyparse (void) break; case 98: /* type_no: TARS_FLOAT */ -#line 935 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 935 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindFloat); } @@ -2467,7 +2467,7 @@ yyparse (void) break; case 99: /* type_no: TARS_DOUBLE */ -#line 939 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 939 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindDouble); } @@ -2475,7 +2475,7 @@ yyparse (void) break; case 100: /* type_no: TARS_STRING */ -#line 943 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 943 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindString); } @@ -2483,7 +2483,7 @@ yyparse (void) break; case 101: /* type_no: vector */ -#line 947 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 947 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2491,7 +2491,7 @@ yyparse (void) break; case 102: /* type_no: map */ -#line 951 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 951 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2499,7 +2499,7 @@ yyparse (void) break; case 103: /* type_no: scoped_name */ -#line 955 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 955 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypePtr sp = g_parse->findUserType(ident->v); @@ -2516,7 +2516,7 @@ yyparse (void) break; case 104: /* vector: TARS_VECTOR '<' type '>' */ -#line 973 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 973 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createVector(TypePtr::dynamicCast(yyvsp[-1]))); } @@ -2524,7 +2524,7 @@ yyparse (void) break; case 105: /* vector: TARS_VECTOR '<' error */ -#line 977 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 977 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector error"); } @@ -2532,7 +2532,7 @@ yyparse (void) break; case 106: /* vector: TARS_VECTOR '<' type error */ -#line 981 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 981 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing '>'"); } @@ -2540,7 +2540,7 @@ yyparse (void) break; case 107: /* vector: TARS_VECTOR error */ -#line 985 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 985 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing type"); } @@ -2548,7 +2548,7 @@ yyparse (void) break; case 108: /* map: TARS_MAP '<' type ',' type '>' */ -#line 994 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 994 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createMap(TypePtr::dynamicCast(yyvsp[-3]), TypePtr::dynamicCast(yyvsp[-1]))); } @@ -2556,7 +2556,7 @@ yyparse (void) break; case 109: /* map: TARS_MAP '<' error */ -#line 998 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 998 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("map error"); } @@ -2564,14 +2564,14 @@ yyparse (void) break; case 110: /* scoped_name: TARS_IDENTIFIER */ -#line 1007 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1007 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2571 "tars.tab.cpp" break; case 111: /* scoped_name: TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1010 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1010 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ident->v = "::" + ident->v; @@ -2581,7 +2581,7 @@ yyparse (void) break; case 112: /* scoped_name: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1016 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1016 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2593,175 +2593,175 @@ yyparse (void) break; case 113: /* keyword: TARS_STRUCT */ -#line 1029 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1029 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2600 "tars.tab.cpp" break; case 114: /* keyword: TARS_VOID */ -#line 1032 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1032 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2607 "tars.tab.cpp" break; case 115: /* keyword: TARS_BOOL */ -#line 1035 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1035 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2614 "tars.tab.cpp" break; case 116: /* keyword: TARS_BYTE */ -#line 1038 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1038 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2621 "tars.tab.cpp" break; case 117: /* keyword: TARS_SHORT */ -#line 1041 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1041 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2628 "tars.tab.cpp" break; case 118: /* keyword: TARS_INT */ -#line 1044 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1044 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2635 "tars.tab.cpp" break; case 119: /* keyword: TARS_FLOAT */ -#line 1047 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1047 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2642 "tars.tab.cpp" break; case 120: /* keyword: TARS_DOUBLE */ -#line 1050 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1050 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2649 "tars.tab.cpp" break; case 121: /* keyword: TARS_STRING */ -#line 1053 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1053 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2656 "tars.tab.cpp" break; case 122: /* keyword: TARS_VECTOR */ -#line 1056 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1056 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2663 "tars.tab.cpp" break; case 123: /* keyword: TARS_KEY */ -#line 1059 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1059 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2670 "tars.tab.cpp" break; case 124: /* keyword: TARS_MAP */ -#line 1062 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1062 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2677 "tars.tab.cpp" break; case 125: /* keyword: TARS_NAMESPACE */ -#line 1065 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1065 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2684 "tars.tab.cpp" break; case 126: /* keyword: TARS_INTERFACE */ -#line 1068 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1068 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2691 "tars.tab.cpp" break; case 127: /* keyword: TARS_OUT */ -#line 1071 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1071 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2698 "tars.tab.cpp" break; case 128: /* keyword: TARS_REQUIRE */ -#line 1074 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1074 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2705 "tars.tab.cpp" break; case 129: /* keyword: TARS_OPTIONAL */ -#line 1077 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1077 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2712 "tars.tab.cpp" break; case 130: /* keyword: TARS_CONST_INTEGER */ -#line 1080 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1080 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2719 "tars.tab.cpp" break; case 131: /* keyword: TARS_CONST_FLOAT */ -#line 1083 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1083 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2726 "tars.tab.cpp" break; case 132: /* keyword: TARS_FALSE */ -#line 1086 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1086 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2733 "tars.tab.cpp" break; case 133: /* keyword: TARS_TRUE */ -#line 1089 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1089 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2740 "tars.tab.cpp" break; case 134: /* keyword: TARS_STRING_LITERAL */ -#line 1092 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1092 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2747 "tars.tab.cpp" break; case 135: /* keyword: TARS_CONST */ -#line 1095 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1095 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2754 "tars.tab.cpp" break; case 136: /* keyword: TARS_ENUM */ -#line 1098 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1098 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2761 "tars.tab.cpp" break; case 137: /* keyword: TARS_UNSIGNED */ -#line 1101 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1101 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2768 "tars.tab.cpp" @@ -2962,7 +2962,7 @@ yyparse (void) return yyresult; } -#line 1105 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1105 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" diff --git a/tools/tarsparse/tars.lex.cpp b/tools/tarsparse/tars.lex.cpp index 9a51e112..e7cd6524 100644 --- a/tools/tarsparse/tars.lex.cpp +++ b/tools/tarsparse/tars.lex.cpp @@ -511,7 +511,7 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 1 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" /** * Tencent is pleased to support the open source community by making Tars available. * @@ -527,7 +527,7 @@ char *yytext; * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -#line 20 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 20 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" #include #include #include @@ -776,7 +776,7 @@ YY_DECL } { -#line 67 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 67 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" #line 782 "tars.lex.cpp" @@ -848,12 +848,12 @@ YY_DECL case 1: YY_RULE_SETUP -#line 69 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 69 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" { BEGIN(INCL); } YY_BREAK case 2: YY_RULE_SETUP -#line 71 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 71 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" { if ( include_file_stack_ptr >= MAX_INCLUDE_DEPTH ) { @@ -886,7 +886,7 @@ YY_RULE_SETUP YY_BREAK case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INCL): -#line 101 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 101 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" { --include_file_stack_ptr; if ( include_file_stack_ptr < 0 ) @@ -905,14 +905,14 @@ case YY_STATE_EOF(INCL): YY_BREAK case 3: YY_RULE_SETUP -#line 117 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 117 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" { return TARS_SCOPE_DELIMITER; } YY_BREAK case 4: YY_RULE_SETUP -#line 121 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 121 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" { // C++ comment bool e = false; @@ -933,7 +933,7 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 139 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 139 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" { // C comment bool e = false; @@ -984,7 +984,7 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 187 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 187 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" { StringGrammarPtr ident = new StringGrammar; ident->v = yytext; @@ -995,7 +995,7 @@ YY_RULE_SETUP case 7: /* rule 7 can match eol */ YY_RULE_SETUP -#line 194 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 194 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" { StringGrammarPtr ident = new StringGrammar; ident->v = yytext; @@ -1008,7 +1008,7 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 204 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 204 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" { StringGrammarPtr str = new StringGrammar; bool e = false; @@ -1123,7 +1123,7 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 316 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 316 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" { errno = 0; IntergerGrammarPtr ptr = new IntergerGrammar; @@ -1148,7 +1148,7 @@ YY_RULE_SETUP YY_BREAK case 10: YY_RULE_SETUP -#line 338 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 338 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" { errno = 0; FloatGrammarPtr ptr = new FloatGrammar; @@ -1183,7 +1183,7 @@ YY_RULE_SETUP case 11: /* rule 11 can match eol */ YY_RULE_SETUP -#line 369 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 369 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" { if(yytext[0] == '\n') { @@ -1193,7 +1193,7 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 376 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 376 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" { if(yytext[0] < 32 || yytext[0] > 126) { @@ -1212,7 +1212,7 @@ YY_RULE_SETUP YY_BREAK case 13: YY_RULE_SETUP -#line 392 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 392 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" ECHO; YY_BREAK #line 1218 "tars.lex.cpp" @@ -2230,7 +2230,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 392 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" +#line 392 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" diff --git a/tools/tarsparse/tars.tab.cpp b/tools/tarsparse/tars.tab.cpp index 869dd6a2..4647924b 100644 --- a/tools/tarsparse/tars.tab.cpp +++ b/tools/tarsparse/tars.tab.cpp @@ -67,7 +67,7 @@ /* First part of user prologue. */ -#line 17 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 17 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" #include #include @@ -1384,14 +1384,14 @@ yyparse (void) switch (yyn) { case 3: /* $@1: %empty */ -#line 75 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 75 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1391 "tars.tab.cpp" break; case 5: /* $@2: %empty */ -#line 79 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 79 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyerrok; } @@ -1399,7 +1399,7 @@ yyparse (void) break; case 7: /* definitions: definition */ -#line 84 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 84 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } @@ -1407,14 +1407,14 @@ yyparse (void) break; case 8: /* definitions: %empty */ -#line 88 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 88 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1414 "tars.tab.cpp" break; case 9: /* definition: namespace_def */ -#line 96 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 96 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || NamespacePtr::dynamicCast(yyvsp[0])); } @@ -1422,7 +1422,7 @@ yyparse (void) break; case 10: /* definition: interface_def */ -#line 100 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 100 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || InterfacePtr::dynamicCast(yyvsp[0])); } @@ -1430,7 +1430,7 @@ yyparse (void) break; case 11: /* definition: struct_def */ -#line 104 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 104 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || StructPtr::dynamicCast(yyvsp[0])); } @@ -1438,14 +1438,14 @@ yyparse (void) break; case 12: /* definition: key_def */ -#line 108 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 108 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1445 "tars.tab.cpp" break; case 13: /* definition: enum_def */ -#line 111 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 111 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || EnumPtr::dynamicCast(yyvsp[0])); } @@ -1453,7 +1453,7 @@ yyparse (void) break; case 14: /* definition: const_def */ -#line 115 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 115 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || ConstPtr::dynamicCast(yyvsp[0])); } @@ -1461,7 +1461,7 @@ yyparse (void) break; case 15: /* @3: %empty */ -#line 124 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 124 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1469,7 +1469,7 @@ yyparse (void) break; case 16: /* enum_def: enum_id @3 '{' enumerator_list '}' */ -#line 128 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 128 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1487,7 +1487,7 @@ yyparse (void) break; case 17: /* enum_id: TARS_ENUM TARS_IDENTIFIER */ -#line 147 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 147 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { NamespacePtr c = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!c) @@ -1504,7 +1504,7 @@ yyparse (void) break; case 18: /* enum_id: TARS_ENUM keyword */ -#line 160 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 160 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumeration name"); @@ -1514,7 +1514,7 @@ yyparse (void) break; case 19: /* enumerator_list: enumerator ',' enumerator_list */ -#line 171 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 171 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[-1]; } @@ -1522,14 +1522,14 @@ yyparse (void) break; case 20: /* enumerator_list: enumerator */ -#line 175 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 175 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1529 "tars.tab.cpp" break; case 21: /* enumerator: TARS_IDENTIFIER */ -#line 183 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 183 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1544,7 +1544,7 @@ yyparse (void) break; case 22: /* enumerator: keyword */ -#line 194 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 194 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumerator"); @@ -1553,7 +1553,7 @@ yyparse (void) break; case 23: /* enumerator: TARS_IDENTIFIER '=' const_initializer */ -#line 199 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 199 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -1570,14 +1570,14 @@ yyparse (void) break; case 24: /* enumerator: %empty */ -#line 212 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 212 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1577 "tars.tab.cpp" break; case 25: /* @4: %empty */ -#line 220 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 220 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ContainerPtr c = g_parse->currentContainer(); @@ -1596,7 +1596,7 @@ yyparse (void) break; case 26: /* namespace_def: TARS_NAMESPACE TARS_IDENTIFIER @4 '{' definitions '}' */ -#line 235 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 235 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1612,7 +1612,7 @@ yyparse (void) break; case 27: /* $@5: %empty */ -#line 253 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 253 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-1]); StructPtr sp = StructPtr::dynamicCast(g_parse->findUserType(ident->v)); @@ -1627,14 +1627,14 @@ yyparse (void) break; case 28: /* key_def: TARS_KEY '[' scoped_name ',' $@5 key_members ']' */ -#line 264 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 264 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1634 "tars.tab.cpp" break; case 29: /* key_members: TARS_IDENTIFIER */ -#line 272 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 272 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1651,7 +1651,7 @@ yyparse (void) break; case 30: /* key_members: key_members ',' TARS_IDENTIFIER */ -#line 285 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 285 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1668,7 +1668,7 @@ yyparse (void) break; case 31: /* @6: %empty */ -#line 304 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 304 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1689,7 +1689,7 @@ yyparse (void) break; case 32: /* interface_def: interface_id @6 '{' interface_exports '}' */ -#line 321 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 321 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1705,7 +1705,7 @@ yyparse (void) break; case 33: /* interface_id: TARS_INTERFACE TARS_IDENTIFIER */ -#line 338 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 338 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1713,7 +1713,7 @@ yyparse (void) break; case 34: /* interface_id: TARS_INTERFACE keyword */ -#line 342 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 342 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as interface name"); @@ -1723,21 +1723,21 @@ yyparse (void) break; case 35: /* interface_exports: interface_export ';' interface_exports */ -#line 353 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 353 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1730 "tars.tab.cpp" break; case 36: /* interface_exports: error ';' interface_exports */ -#line 356 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 356 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1737 "tars.tab.cpp" break; case 37: /* interface_exports: interface_export */ -#line 359 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 359 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } @@ -1745,14 +1745,14 @@ yyparse (void) break; case 38: /* interface_exports: %empty */ -#line 363 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 363 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1752 "tars.tab.cpp" break; case 40: /* operation: operation_preamble parameters ')' */ -#line 377 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 377 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1768,7 +1768,7 @@ yyparse (void) break; case 41: /* operation_preamble: return_type TARS_OP */ -#line 394 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 394 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1796,7 +1796,7 @@ yyparse (void) break; case 43: /* return_type: TARS_VOID */ -#line 424 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 424 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = 0; } @@ -1804,14 +1804,14 @@ yyparse (void) break; case 44: /* parameters: %empty */ -#line 434 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 434 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 1811 "tars.tab.cpp" break; case 45: /* parameters: type_id */ -#line 437 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 437 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1826,7 +1826,7 @@ yyparse (void) break; case 46: /* parameters: parameters ',' type_id */ -#line 448 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 448 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1841,7 +1841,7 @@ yyparse (void) break; case 47: /* parameters: out_qualifier type_id */ -#line 459 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 459 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1857,7 +1857,7 @@ yyparse (void) break; case 48: /* parameters: parameters ',' out_qualifier type_id */ -#line 471 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 471 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1873,7 +1873,7 @@ yyparse (void) break; case 49: /* parameters: routekey_qualifier type_id */ -#line 483 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 483 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1889,7 +1889,7 @@ yyparse (void) break; case 50: /* parameters: parameters ',' routekey_qualifier type_id */ -#line 495 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 495 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1905,7 +1905,7 @@ yyparse (void) break; case 51: /* parameters: out_qualifier */ -#line 507 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 507 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("'out' must be defined with a type"); } @@ -1913,7 +1913,7 @@ yyparse (void) break; case 52: /* parameters: routekey_qualifier */ -#line 511 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 511 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("'routekey' must be defined with a type"); } @@ -1921,7 +1921,7 @@ yyparse (void) break; case 53: /* routekey_qualifier: TARS_ROUTE_KEY */ -#line 520 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 520 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr routekey = new BoolGrammar; routekey->v = true; @@ -1931,7 +1931,7 @@ yyparse (void) break; case 54: /* out_qualifier: TARS_OUT */ -#line 531 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 531 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr out = new BoolGrammar; out->v = true; @@ -1941,7 +1941,7 @@ yyparse (void) break; case 55: /* @7: %empty */ -#line 542 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 542 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); @@ -1967,7 +1967,7 @@ yyparse (void) break; case 56: /* struct_def: struct_id @7 '{' struct_exports '}' */ -#line 564 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 564 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1986,7 +1986,7 @@ yyparse (void) break; case 57: /* struct_id: TARS_STRUCT TARS_IDENTIFIER */ -#line 584 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 584 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -1994,7 +1994,7 @@ yyparse (void) break; case 58: /* struct_id: TARS_STRUCT keyword */ -#line 588 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 588 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2004,7 +2004,7 @@ yyparse (void) break; case 59: /* struct_id: TARS_STRUCT error */ -#line 594 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 594 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("abstract declarator '' used as declaration"); } @@ -2012,7 +2012,7 @@ yyparse (void) break; case 60: /* struct_exports: data_member ';' struct_exports */ -#line 603 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 603 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } @@ -2020,7 +2020,7 @@ yyparse (void) break; case 61: /* struct_exports: data_member */ -#line 607 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 607 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("';' missing after definition"); } @@ -2028,14 +2028,14 @@ yyparse (void) break; case 62: /* struct_exports: %empty */ -#line 611 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 611 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2035 "tars.tab.cpp" break; case 63: /* data_member: struct_type_id */ -#line 621 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 621 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2043,7 +2043,7 @@ yyparse (void) break; case 64: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id */ -#line 630 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 630 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2065,7 +2065,7 @@ yyparse (void) break; case 65: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id '=' const_initializer */ -#line 648 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 648 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2091,7 +2091,7 @@ yyparse (void) break; case 66: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id '=' const_initializer */ -#line 670 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 670 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2117,7 +2117,7 @@ yyparse (void) break; case 67: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id */ -#line 692 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 692 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2138,7 +2138,7 @@ yyparse (void) break; case 68: /* struct_type_id: TARS_REQUIRE type_id */ -#line 709 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 709 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } @@ -2146,7 +2146,7 @@ yyparse (void) break; case 69: /* struct_type_id: TARS_OPTIONAL type_id */ -#line 713 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 713 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } @@ -2154,7 +2154,7 @@ yyparse (void) break; case 70: /* struct_type_id: TARS_CONST_INTEGER type_id */ -#line 717 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 717 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'require' or 'optional'"); } @@ -2162,7 +2162,7 @@ yyparse (void) break; case 71: /* struct_type_id: type_id */ -#line 721 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 721 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag' or 'require' or 'optional'"); } @@ -2170,7 +2170,7 @@ yyparse (void) break; case 72: /* const_initializer: TARS_CONST_INTEGER */ -#line 730 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 730 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { IntergerGrammarPtr intVal = IntergerGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2184,7 +2184,7 @@ yyparse (void) break; case 73: /* const_initializer: TARS_CONST_FLOAT */ -#line 740 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 740 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { FloatGrammarPtr floatVal = FloatGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2198,7 +2198,7 @@ yyparse (void) break; case 74: /* const_initializer: TARS_STRING_LITERAL */ -#line 750 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 750 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2210,7 +2210,7 @@ yyparse (void) break; case 75: /* const_initializer: TARS_FALSE */ -#line 758 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 758 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2222,7 +2222,7 @@ yyparse (void) break; case 76: /* const_initializer: TARS_TRUE */ -#line 766 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 766 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2234,7 +2234,7 @@ yyparse (void) break; case 77: /* const_initializer: TARS_IDENTIFIER */ -#line 774 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 774 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2251,7 +2251,7 @@ yyparse (void) break; case 78: /* const_initializer: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 787 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 787 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2270,7 +2270,7 @@ yyparse (void) break; case 79: /* const_def: TARS_CONST type_id '=' const_initializer */ -#line 807 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 807 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!np) @@ -2287,7 +2287,7 @@ yyparse (void) break; case 80: /* type_id: type TARS_IDENTIFIER */ -#line 825 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 825 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2300,7 +2300,7 @@ yyparse (void) break; case 81: /* type_id: type TARS_IDENTIFIER '[' TARS_CONST_INTEGER ']' */ -#line 834 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 834 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-4])); IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast(yyvsp[-1]); @@ -2314,7 +2314,7 @@ yyparse (void) break; case 82: /* type_id: type '*' TARS_IDENTIFIER */ -#line 844 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 844 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-2])); //IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast($4); @@ -2328,7 +2328,7 @@ yyparse (void) break; case 83: /* type_id: type TARS_IDENTIFIER ':' TARS_CONST_INTEGER */ -#line 854 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 854 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-3]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2341,7 +2341,7 @@ yyparse (void) break; case 84: /* type_id: type keyword */ -#line 863 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 863 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as data member name"); @@ -2350,7 +2350,7 @@ yyparse (void) break; case 85: /* type_id: type */ -#line 868 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 868 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("missing data member name"); } @@ -2358,7 +2358,7 @@ yyparse (void) break; case 86: /* type_id: error */ -#line 872 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 872 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("unkown type"); } @@ -2366,7 +2366,7 @@ yyparse (void) break; case 87: /* type: type_no ':' TARS_CONST_INTEGER */ -#line 881 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 881 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-2]); @@ -2379,7 +2379,7 @@ yyparse (void) break; case 88: /* type: type_no */ -#line 890 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 890 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } @@ -2387,7 +2387,7 @@ yyparse (void) break; case 89: /* type: type_no ':' error */ -#line 894 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 894 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("array missing size"); } @@ -2395,7 +2395,7 @@ yyparse (void) break; case 90: /* type_no: TARS_BOOL */ -#line 903 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 903 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindBool); } @@ -2403,7 +2403,7 @@ yyparse (void) break; case 91: /* type_no: TARS_BYTE */ -#line 907 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 907 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindByte); } @@ -2411,7 +2411,7 @@ yyparse (void) break; case 92: /* type_no: TARS_UNSIGNED TARS_BYTE */ -#line 911 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 911 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort,true); } @@ -2419,7 +2419,7 @@ yyparse (void) break; case 93: /* type_no: TARS_SHORT */ -#line 915 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 915 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort); } @@ -2427,7 +2427,7 @@ yyparse (void) break; case 94: /* type_no: TARS_UNSIGNED TARS_SHORT */ -#line 919 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 919 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt,true); } @@ -2435,7 +2435,7 @@ yyparse (void) break; case 95: /* type_no: TARS_INT */ -#line 923 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 923 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt); } @@ -2443,7 +2443,7 @@ yyparse (void) break; case 96: /* type_no: TARS_UNSIGNED TARS_INT */ -#line 927 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 927 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong,true); } @@ -2451,7 +2451,7 @@ yyparse (void) break; case 97: /* type_no: TARS_LONG */ -#line 931 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 931 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong); } @@ -2459,7 +2459,7 @@ yyparse (void) break; case 98: /* type_no: TARS_FLOAT */ -#line 935 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 935 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindFloat); } @@ -2467,7 +2467,7 @@ yyparse (void) break; case 99: /* type_no: TARS_DOUBLE */ -#line 939 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 939 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindDouble); } @@ -2475,7 +2475,7 @@ yyparse (void) break; case 100: /* type_no: TARS_STRING */ -#line 943 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 943 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindString); } @@ -2483,7 +2483,7 @@ yyparse (void) break; case 101: /* type_no: vector */ -#line 947 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 947 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2491,7 +2491,7 @@ yyparse (void) break; case 102: /* type_no: map */ -#line 951 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 951 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } @@ -2499,7 +2499,7 @@ yyparse (void) break; case 103: /* type_no: scoped_name */ -#line 955 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 955 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypePtr sp = g_parse->findUserType(ident->v); @@ -2516,7 +2516,7 @@ yyparse (void) break; case 104: /* vector: TARS_VECTOR '<' type '>' */ -#line 973 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 973 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createVector(TypePtr::dynamicCast(yyvsp[-1]))); } @@ -2524,7 +2524,7 @@ yyparse (void) break; case 105: /* vector: TARS_VECTOR '<' error */ -#line 977 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 977 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector error"); } @@ -2532,7 +2532,7 @@ yyparse (void) break; case 106: /* vector: TARS_VECTOR '<' type error */ -#line 981 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 981 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing '>'"); } @@ -2540,7 +2540,7 @@ yyparse (void) break; case 107: /* vector: TARS_VECTOR error */ -#line 985 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 985 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing type"); } @@ -2548,7 +2548,7 @@ yyparse (void) break; case 108: /* map: TARS_MAP '<' type ',' type '>' */ -#line 994 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 994 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createMap(TypePtr::dynamicCast(yyvsp[-3]), TypePtr::dynamicCast(yyvsp[-1]))); } @@ -2556,7 +2556,7 @@ yyparse (void) break; case 109: /* map: TARS_MAP '<' error */ -#line 998 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 998 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("map error"); } @@ -2564,14 +2564,14 @@ yyparse (void) break; case 110: /* scoped_name: TARS_IDENTIFIER */ -#line 1007 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1007 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2571 "tars.tab.cpp" break; case 111: /* scoped_name: TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1010 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1010 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ident->v = "::" + ident->v; @@ -2581,7 +2581,7 @@ yyparse (void) break; case 112: /* scoped_name: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1016 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1016 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2593,175 +2593,175 @@ yyparse (void) break; case 113: /* keyword: TARS_STRUCT */ -#line 1029 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1029 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2600 "tars.tab.cpp" break; case 114: /* keyword: TARS_VOID */ -#line 1032 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1032 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2607 "tars.tab.cpp" break; case 115: /* keyword: TARS_BOOL */ -#line 1035 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1035 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2614 "tars.tab.cpp" break; case 116: /* keyword: TARS_BYTE */ -#line 1038 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1038 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2621 "tars.tab.cpp" break; case 117: /* keyword: TARS_SHORT */ -#line 1041 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1041 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2628 "tars.tab.cpp" break; case 118: /* keyword: TARS_INT */ -#line 1044 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1044 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2635 "tars.tab.cpp" break; case 119: /* keyword: TARS_FLOAT */ -#line 1047 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1047 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2642 "tars.tab.cpp" break; case 120: /* keyword: TARS_DOUBLE */ -#line 1050 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1050 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2649 "tars.tab.cpp" break; case 121: /* keyword: TARS_STRING */ -#line 1053 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1053 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2656 "tars.tab.cpp" break; case 122: /* keyword: TARS_VECTOR */ -#line 1056 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1056 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2663 "tars.tab.cpp" break; case 123: /* keyword: TARS_KEY */ -#line 1059 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1059 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2670 "tars.tab.cpp" break; case 124: /* keyword: TARS_MAP */ -#line 1062 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1062 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2677 "tars.tab.cpp" break; case 125: /* keyword: TARS_NAMESPACE */ -#line 1065 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1065 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2684 "tars.tab.cpp" break; case 126: /* keyword: TARS_INTERFACE */ -#line 1068 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1068 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2691 "tars.tab.cpp" break; case 127: /* keyword: TARS_OUT */ -#line 1071 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1071 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2698 "tars.tab.cpp" break; case 128: /* keyword: TARS_REQUIRE */ -#line 1074 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1074 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2705 "tars.tab.cpp" break; case 129: /* keyword: TARS_OPTIONAL */ -#line 1077 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1077 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2712 "tars.tab.cpp" break; case 130: /* keyword: TARS_CONST_INTEGER */ -#line 1080 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1080 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2719 "tars.tab.cpp" break; case 131: /* keyword: TARS_CONST_FLOAT */ -#line 1083 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1083 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2726 "tars.tab.cpp" break; case 132: /* keyword: TARS_FALSE */ -#line 1086 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1086 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2733 "tars.tab.cpp" break; case 133: /* keyword: TARS_TRUE */ -#line 1089 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1089 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2740 "tars.tab.cpp" break; case 134: /* keyword: TARS_STRING_LITERAL */ -#line 1092 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1092 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2747 "tars.tab.cpp" break; case 135: /* keyword: TARS_CONST */ -#line 1095 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1095 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2754 "tars.tab.cpp" break; case 136: /* keyword: TARS_ENUM */ -#line 1098 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1098 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2761 "tars.tab.cpp" break; case 137: /* keyword: TARS_UNSIGNED */ -#line 1101 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1101 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" { } #line 2768 "tars.tab.cpp" @@ -2962,7 +2962,7 @@ yyparse (void) return yyresult; } -#line 1105 "/Volumes/MyData/centos/CloudMarket/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" +#line 1105 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" From c099a2da252de17e115e59c061fb9fc568ce1647 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 6 Mar 2024 17:21:27 +0800 Subject: [PATCH 66/81] feat: mock add getFrameworkServer --- mock/TarsMockUtil.cpp | 5 +++++ mock/TarsMockUtil.h | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/mock/TarsMockUtil.cpp b/mock/TarsMockUtil.cpp index d065b925..067b8ea7 100644 --- a/mock/TarsMockUtil.cpp +++ b/mock/TarsMockUtil.cpp @@ -23,6 +23,11 @@ void TarsMockUtil::stopFramework() _fs->terminate(); } +std::shared_ptr TarsMockUtil::getFrameworkServer() +{ + return _fs; +} + void TarsMockUtil::refreshRegistry(const string &obj, size_t count) { do diff --git a/mock/TarsMockUtil.h b/mock/TarsMockUtil.h index 2eaad1fd..d8a262d6 100644 --- a/mock/TarsMockUtil.h +++ b/mock/TarsMockUtil.h @@ -6,6 +6,8 @@ #include #include +#include "servant/Application.h" +#include "mock/FrameworkServer.h" class FrameworkServer; @@ -33,6 +35,12 @@ class TarsMockUtil */ void refreshRegistry(const std::string &obj, size_t count); + /** + * + * @return + */ + std::shared_ptr getFrameworkServer(); + protected: std::shared_ptr _fs; }; From bdaaf623d5983909385192037610a4c40631ed0d Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 7 Mar 2024 10:47:00 +0800 Subject: [PATCH 67/81] fix mock dbhandle add host --- mock/DbHandle.cpp | 58 +++++++++++++++++------------------------------ mock/DbHandle.h | 12 +++++----- 2 files changed, 27 insertions(+), 43 deletions(-) diff --git a/mock/DbHandle.cpp b/mock/DbHandle.cpp index fd68b90e..c769cf0a 100755 --- a/mock/DbHandle.cpp +++ b/mock/DbHandle.cpp @@ -5,12 +5,9 @@ ////////////////////////////////////////////////////// -// -//typedef map ObjectsCache; static ObjectsCache _objectsCache; -//ObjectsCache CDbHandle::_objectsCache; CDbHandle::SetDivisionCache CDbHandle::_setDivisionCache; std::map CDbHandle::_mapGroupPriority; std::mutex CDbHandle::_mutex; @@ -330,7 +327,6 @@ void CDbHandle::updateObjectsCache(const ObjectsCache& objCache, bool updateAll) else { //用查询数据覆盖一下 -// _objectsCache.getWriterData() = _objectsCache.getReaderData(); ObjectsCache& tmpObjCache = _objectsCache; ObjectsCache::const_iterator it = objCache.begin(); @@ -339,7 +335,6 @@ void CDbHandle::updateObjectsCache(const ObjectsCache& objCache, bool updateAll) //增量的时候加载的是服务的所有节点,因此这里直接替换 tmpObjCache[it->first] = it->second; } -// _objectsCache.swap(); } } @@ -350,12 +345,10 @@ void CDbHandle::updateInactiveObjectsCache(const ObjectsCache& objCache, bool up if (updateAll) { _objectsCache = objCache; -// _objectsCache.swap(); } else { //用查询数据覆盖一下 -// _objectsCache.getWriterData() = _objectsCache.getReaderData(); ObjectsCache& tmpObjCache = _objectsCache; ObjectsCache::const_iterator it = objCache.begin(); @@ -364,7 +357,6 @@ void CDbHandle::updateInactiveObjectsCache(const ObjectsCache& objCache, bool up //增量的时候加载的是服务的所有节点,因此这里直接替换 tmpObjCache[it->first].vInactiveEndpoints.push_back((it->second).vInactiveEndpoints[0]); } -// _objectsCache.swap(); } } @@ -376,12 +368,10 @@ void CDbHandle::updateActiveObjectsCache(const ObjectsCache& objCache, bool upda if (updateAll) { _objectsCache = objCache; -// _objectsCache.swap(); } else { //用查询数据覆盖一下 -// _objectsCache.getWriterData() = _objectsCache.getReaderData(); ObjectsCache& tmpObjCache = _objectsCache; ObjectsCache::const_iterator it = objCache.begin(); @@ -390,7 +380,6 @@ void CDbHandle::updateActiveObjectsCache(const ObjectsCache& objCache, bool upda //增量的时候加载的是服务的所有节点,因此这里直接替换 tmpObjCache[it->first].vActiveEndpoints.push_back((it->second).vActiveEndpoints[0]); } -// _objectsCache.swap(); } } @@ -401,7 +390,7 @@ void CDbHandle::printActiveEndPoint(const string& objName) LOG_CONSOLE_DEBUG << "reader data" << endl; for (auto e : _objectsCache[objName].vActiveEndpoints) { - LOG_CONSOLE_DEBUG << e.port << endl; + LOG_CONSOLE_DEBUG << e.writeToJsonString() << endl; } } @@ -409,17 +398,17 @@ void CDbHandle::printActiveEndPoint(const string& objName) LOG_CONSOLE_DEBUG << "write data" << endl; for (auto e : _objectsCache[objName].vActiveEndpoints) { - LOG_CONSOLE_DEBUG << e.port << endl; + LOG_CONSOLE_DEBUG << e.writeToJsonString() << endl; } } } -void CDbHandle::addActiveEndPoint(const string& objName, const Int32 port, const Int32 istcp, const string &nodeName) +void CDbHandle::addActiveEndPoint(const string& objName, const string &host, const Int32 port, const Int32 istcp, const string &nodeName) { -#define LOCAL_HOST "127.0.0.1" +//#define LOCAL_HOST "127.0.0.1" ObjectsCache objectsCache; EndpointF endPoint; - endPoint.host = LOCAL_HOST; + endPoint.host = host; endPoint.port = port; endPoint.timeout = 30000; endPoint.istcp = istcp; @@ -429,12 +418,12 @@ void CDbHandle::addActiveEndPoint(const string& objName, const Int32 port, const updateActiveObjectsCache(objectsCache, false); } -void CDbHandle::addEndPointbySet(const string& objName, const Int32 port, const Int32 istcp, const string& setName, const string& setArea, const string& setGroup) +void CDbHandle::addEndPointbySet(const string& objName, const string &host, const Int32 port, const Int32 istcp, const string& setName, const string& setArea, const string& setGroup) { -#define LOCAL_HOST "127.0.0.1" +//#define LOCAL_HOST "127.0.0.1" ObjectsCache objectsCache; EndpointF endPoint; - endPoint.host = LOCAL_HOST; + endPoint.host = host; endPoint.port = port; endPoint.timeout = 30000; endPoint.istcp = istcp; @@ -448,12 +437,12 @@ void CDbHandle::addEndPointbySet(const string& objName, const Int32 port, const } } -void CDbHandle::addActiveWeight1EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName) +void CDbHandle::addActiveWeight1EndPoint(const string& objName, const string &host, const Int32 port, const Int32 istcp, const string& setName) { -#define LOCAL_HOST "127.0.0.1" +//#define LOCAL_HOST "127.0.0.1" ObjectsCache objectsCache; EndpointF endPoint; - endPoint.host = LOCAL_HOST; + endPoint.host = host; endPoint.port = port; endPoint.timeout = 30000; endPoint.istcp = istcp; @@ -464,12 +453,12 @@ void CDbHandle::addActiveWeight1EndPoint(const string& objName, const Int32 port updateActiveObjectsCache(objectsCache, false); } -void CDbHandle::addInActiveWeight1EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName) +void CDbHandle::addInActiveWeight1EndPoint(const string& objName, const string &host, const Int32 port, const Int32 istcp, const string& setName) { -#define LOCAL_HOST "127.0.0.1" +//#define LOCAL_HOST "127.0.0.1" ObjectsCache objectsCache; EndpointF endPoint; - endPoint.host = LOCAL_HOST; + endPoint.host = host; endPoint.port = port; endPoint.timeout = 30000; endPoint.istcp = istcp; @@ -481,12 +470,12 @@ void CDbHandle::addInActiveWeight1EndPoint(const string& objName, const Int32 po } -void CDbHandle::addActiveWeight2EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName) +void CDbHandle::addActiveWeight2EndPoint(const string& objName, const string &host, const Int32 port, const Int32 istcp, const string& setName) { -#define LOCAL_HOST "127.0.0.1" +//#define LOCAL_HOST "127.0.0.1" ObjectsCache objectsCache; EndpointF endPoint; - endPoint.host = LOCAL_HOST; + endPoint.host = host; endPoint.port = port; endPoint.timeout = 30000; endPoint.istcp = istcp; @@ -498,12 +487,12 @@ void CDbHandle::addActiveWeight2EndPoint(const string& objName, const Int32 port } -void CDbHandle::addInactiveEndPoint(const string& objName, const Int32 port, const Int32 istcp, const string &nodeName) +void CDbHandle::addInactiveEndPoint(const string& objName, const string &host, const Int32 port, const Int32 istcp, const string &nodeName) { -#define LOCAL_HOST "127.0.0.1" +//#define LOCAL_HOST "127.0.0.1" ObjectsCache objectsCache; EndpointF endPoint; - endPoint.host = LOCAL_HOST; + endPoint.host = host; endPoint.port = port; endPoint.timeout = 30000; endPoint.istcp = istcp; @@ -593,7 +582,7 @@ void CDbHandle::InsertSetRecord(const string& objName, const string& setName, co setDivisionCache[objName][setName].push_back(setServerInfo); setServerInfo.bActive = false; - setServerInfo.epf.port = 10204; +// setServerInfo.epf.port = 10204; setDivisionCache[objName][setName].push_back(setServerInfo); @@ -641,16 +630,13 @@ void CDbHandle::updateDivisionCache(SetDivisionCache& setDivisionCache,bool upda } } _setDivisionCache = setDivisionCache; -// _setDivisionCache.swap(); } else { -// _setDivisionCache.getWriterData() = _setDivisionCache.getReaderData(); SetDivisionCache& tmpsetCache = _setDivisionCache; SetDivisionCache::const_iterator it = setDivisionCache.begin(); for(;it != setDivisionCache.end();it++) { - //��set��Ϣ�Ÿ��� if(it->second.size() > 0) { tmpsetCache[it->first] = it->second; @@ -661,7 +647,5 @@ void CDbHandle::updateDivisionCache(SetDivisionCache& setDivisionCache,bool upda } } - -// _setDivisionCache.swap(); } } diff --git a/mock/DbHandle.h b/mock/DbHandle.h index 9c815636..0b83ad3d 100755 --- a/mock/DbHandle.h +++ b/mock/DbHandle.h @@ -166,17 +166,17 @@ class CDbHandle static void InsertSetRecord4Inactive(const string& objName, const string& setName, const string& setArea, const string& setGroup, EndpointF epf); - static void addActiveEndPoint(const string& objName, const Int32 port, const Int32 istcp, const string &nodeName = ""); + static void addActiveEndPoint(const string& objName, const string &host, const Int32 port, const Int32 istcp, const string &nodeName = ""); - static void addInactiveEndPoint(const string& objName, const Int32 port, const Int32 istcp, const string &nodeName = ""); + static void addInactiveEndPoint(const string& objName, const string &host, const Int32 port, const Int32 istcp, const string &nodeName = ""); - static void addEndPointbySet(const string& objName, const Int32 port, const Int32 istcp, const string& setName, const string& setArea, const string& setGroup); + static void addEndPointbySet(const string& objName, const string &host, const Int32 port, const Int32 istcp, const string& setName, const string& setArea, const string& setGroup); - static void addActiveWeight1EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName = ""); + static void addActiveWeight1EndPoint(const string& objName, const string &host, const Int32 port, const Int32 istcp, const string& setName = ""); - static void addInActiveWeight1EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName = ""); + static void addInActiveWeight1EndPoint(const string& objName, const string &host, const Int32 port, const Int32 istcp, const string& setName = ""); - static void addActiveWeight2EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName = ""); + static void addActiveWeight2EndPoint(const string& objName, const string &host, const Int32 port, const Int32 istcp, const string& setName = ""); static void cleanEndPoint(); From 3ca83756346f12dc873848b70f0f4b37de7159f7 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 7 Mar 2024 17:06:16 +0800 Subject: [PATCH 68/81] fix ObjectProxy::doInvokeException error info --- servant/libservant/ObjectProxy.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/servant/libservant/ObjectProxy.cpp b/servant/libservant/ObjectProxy.cpp index b55b45b7..f7f1dae5 100755 --- a/servant/libservant/ObjectProxy.cpp +++ b/servant/libservant/ObjectProxy.cpp @@ -273,17 +273,17 @@ void ObjectProxy::doInvokeException(ReqMessage * msg) } catch(exception & e) { - TLOGERROR("[ObjectProxy::doInvokeException exp:"<request.sServantName << ":" << msg->request.sFuncName << " error: " << e.what() <request.sServantName << ":" << msg->request.sFuncName << ", error" << endl); } } else { _communicatorEpoll->pushAsyncThreadQueue(msg); - TLOGERROR("[ObjectProxy::doInvokeException push adapter is null|" << __LINE__ << endl); + TLOGERROR("[ObjectProxy::doInvokeException " << msg->request.sServantName << ":" << msg->request.sFuncName << ", ret: " << msg->response->iRet << endl); } } else From 2f563ac3718397afa546bea1474b8a32f94d10b0 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Mon, 11 Mar 2024 13:36:08 +0800 Subject: [PATCH 69/81] fix tarsmock config --- mock/framework.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mock/framework.h b/mock/framework.h index 1dd2e77f..2635b9a1 100644 --- a/mock/framework.h +++ b/mock/framework.h @@ -3,7 +3,7 @@ #define FRAMEWORK_CONFIG " \n\ \n\ \n\ - locator = raft.FrameworkServer.QueryObj@tcp -h 127.0.0.1 -p 13004 \n \ + locator = tars.tarsmock.QueryObj@tcp -h 127.0.0.1 -p 17890 \n \ sync-invoke-timeout = 5000 \n \ async-invoke-timeout = 60000 \n \ refresh-endpoint-interval = 5000 \n \ @@ -12,13 +12,13 @@ asyncthread = 3 \n \ netthread = 2 \n \ mergenetasync = 0 \n \ - modulename = raft.FrameworkServer \n \ + modulename = tars.tarsmock \n \ \n \ \n \ start_output = ERROR \n \ closecout = 0 \n \ - app = raft \n \ - server = FrameworkServer \n \ + app = tars \n \ + server = tarsmock \n \ basepath = . \n \ datapath = . \n \ logpath = . \n \ @@ -31,7 +31,7 @@ allow = \n \ maxconns = 4096 \n \ threads = 5 \n \ - servant = raft.FrameworkServer.QueryObj \n \ + servant = tars.tarsmock.QueryObj \n \ queuecap = 1000000 \n \ \n \ \n \ From 794360851e8a766e338bed91843028a713e53398 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 13 Mar 2024 09:17:24 +0800 Subject: [PATCH 70/81] feat: tc_port add freopen --- util/include/util/tc_port.h | 97 ++++++++++++++++++++++++++++++++++++- util/src/tc_port.cpp | 18 ++++--- 2 files changed, 106 insertions(+), 9 deletions(-) diff --git a/util/include/util/tc_port.h b/util/include/util/tc_port.h index f2cbd937..daae3d4a 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -59,39 +59,132 @@ class TC_Port */ static const char* strnstr(const char* s1, const char* s2, int pos1); + /** + * 字符串比较 + * @param s1 + * @param s2 + * @return + */ static int strcmp(const char *s1, const char *s2); + /** + * 字符串比较 + * @param s1 + * @param s2 + * @param n + * @return + */ static int strncmp(const char *s1, const char *s2, size_t n); + /** + * 忽略大小写比较 + * @param s1 + * @param s2 + * @return + */ static int strcasecmp(const char *s1, const char *s2); + /** + * 忽略大小写比较 + * @param s1 + * @param s2 + * @param n + * @return + */ static int strncasecmp(const char *s1, const char *s2, size_t n); + /** + * 从clock得到当前(到时区的)时间 + * @param clock + * @param result + */ static void localtime_r(const time_t *clock, struct tm *result); + /** + * 从clock得到当前时间GMT(不考虑时区, 夏令时等) + * @param clock + * @param result + */ static void gmtime_r(const time_t *clock, struct tm *result); + /** + * 转换成时间戳(GMT时间) + * @param timeptr + * @return + */ static time_t timegm(struct tm *timeptr); + /** + * 当前时间 + * @param tv + * @return + */ static int gettimeofday(struct timeval &tv); + /** + * 改变文件属性 + * @param path + * @param mode + * @return + */ static int chmod(const char *path, mode_t mode); - static FILE * fopen(const char * path, const char * mode); - #if TARGET_PLATFORM_WINDOWS typedef struct _stat stat_t; #else typedef struct stat stat_t; #endif + + /** + * 查看文件属性 + * @param path + * @param buf + * @return + */ static int lstat(const char * path, stat_t * buf); + /** + * 创建目录(可以使用TC_File下的函数makeDir/makeDirRecursive) + * @param path + * @return + */ static int mkdir(const char *path); + /** + * 删除路径 可以使用TC_File::removeFile + * @param path + * @return + */ static int rmdir(const char *path); + /** + * 打开一个文件 + * @param path + * @param mode + * @return + */ + static FILE * fopen(const char * path, const char * mode); + + /** + * src重定向到file + * @param src + * @param mode + * @param dst + * @return + */ + static FILE *freopen(const char * dst, const char * mode, FILE * src); + + /** + * 关闭网络句柄 + * @param fd + * @return + */ static int closeSocket(int fd); + /** + * 获取进程pid + * @return + */ static int64_t getpid(); /** diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index 0a69b31e..70639895 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -721,6 +721,15 @@ vector TC_Port::getPidsByCmdline(const string &cmdLine, bool accurateMa #endif } +FILE *TC_Port::freopen(const char * dst, const char * mode, FILE * src) +{ +#if TARGET_PLATFORM_IOS + return freopen(dst, mode, src); +#else + return freopen64(dst, mode, src); +#endif +} + int64_t TC_Port::forkExec(const string& sExePath, const string& sPwdPath, const string& sRollLogPath, const vector& vOptions) { vector vEnvs; @@ -826,13 +835,8 @@ int64_t TC_Port::forkExec(const string& sExePath, const string& sPwdPath, const if (!sRollLogPath.empty()) { TC_File::makeDirRecursive(TC_File::extractFilePath(sRollLogPath)); -#if TARGET_PLATFORM_IOS - freopen(sRollLogPath.c_str(), "ab", stdout); - freopen(sRollLogPath.c_str(), "ab", stderr); -#else - freopen64(sRollLogPath.c_str(), "ab", stdout); - freopen64(sRollLogPath.c_str(), "ab", stderr); -#endif + TC_Port::freopen(sRollLogPath.c_str(), "ab", stdout); + TC_Port::freopen(sRollLogPath.c_str(), "ab", stderr); } if (strlen(pwdCStr) != 0) From e9e75cf5826a2cf71b1be5d94be5f5215eb3cb54 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 13 Mar 2024 10:59:40 +0800 Subject: [PATCH 71/81] fix tc_port exec out buff size limit --- unit-test/util/test_tc_port.cpp | 77 +++------------------------------ util/include/util/tc_port.h | 4 +- util/src/tc_port.cpp | 29 +++++++------ 3 files changed, 24 insertions(+), 86 deletions(-) diff --git a/unit-test/util/test_tc_port.cpp b/unit-test/util/test_tc_port.cpp index 355743ec..1c14ea97 100755 --- a/unit-test/util/test_tc_port.cpp +++ b/unit-test/util/test_tc_port.cpp @@ -2,7 +2,7 @@ #include "util/tc_common.h" #include #include "gtest/gtest.h" - +#include "util/tc_file.h" #include #include @@ -32,6 +32,10 @@ TEST_F(UtilPortTest, testExec) string err; string result = TC_Port::exec("ls '*.txt'", err); cout << result << endl; + + string out = TC_Port::exec(("file " + TC_File::getExePath()).c_str()); + + cout << out << endl; } TEST_F(UtilPortTest, testGetPidMemUsed) @@ -126,74 +130,6 @@ TEST_F(UtilPortTest, testGetDisk) } #endif -// -//#if TARGET_PLATFORM_IOS -//#include -//#include -//#include -//#include -//#include -//#endif -// -// -//vector getPidsByCmdline(const string &cmdLine, bool accurateMatch) -//{ -// vector pids; -// -//#if TARGET_PLATFORM_IOS -// int mib[4]; -// mib[0] = CTL_KERN; -// mib[1] = KERN_PROC; -// mib[2] = KERN_PROC_ALL; -// mib[3] = 0; -// -// size_t size; -// if (sysctl(mib, 4, NULL, &size, NULL, 0) == -1) { -// return {}; -// } -// -// struct kinfo_proc* proc_list = (struct kinfo_proc*)malloc(size); -// if (proc_list == NULL) { -// return {}; -// } -// -// if (sysctl(mib, 4, proc_list, &size, NULL, 0) == -1) { -// free(proc_list); -// return {}; -// } -// -// int num_procs = size / sizeof(struct kinfo_proc); -// for (int i = 0; i < num_procs; i++) -// { -// vector args = getArgs(proc_list[i].kp_proc.p_pid); -// string path = TC_Common::tostr(args.begin(), args.end(), " "); -// -// if(accurateMatch) -// { -// if(cmdLine == path) -// { -// pids.push_back(proc_list[i].kp_proc.p_pid); -// } -// } -// else -// { -// if(std::string(path).find(cmdLine) != std::string::npos) -// { -// pids.push_back(proc_list[i].kp_proc.p_pid); -// } -// } -// } -// -// free(proc_list); -// return pids; -//#elif TARGET_PLATFORM_LINUX -// return {}; -//#elif TARGET_PLATFORM_WINDOWS -// return {}; -//#else -// return {}; -//#endif -//} TEST_F(UtilPortTest, testGetCommandline) { @@ -215,4 +151,5 @@ TEST_F(UtilPortTest, testGetPidsByCmdline) int64_t pid = TC_Port::getpid(); ASSERT_TRUE(std::find(pids.begin(), pids.end(), pid) != pids.end()); -} \ No newline at end of file +} + diff --git a/util/include/util/tc_port.h b/util/include/util/tc_port.h index daae3d4a..d88d45d6 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -217,7 +217,7 @@ class TC_Port * 运行一个脚本 * @param cmd * @param err - * @return 程序的标准输出(最大2k的输出长度) + * @return 程序的标准输出 */ static std::string exec(const char* cmd); @@ -225,7 +225,7 @@ class TC_Port * 运行一个脚本(程序+命令行) * @param cmd * @param err - * @return: 程序的标准输出(最大2k的输出长度) + * @return: 程序的标准输出 */ static std::string exec(const char* cmd, std::string &err); diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index 70639895..c11adc0f 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -300,29 +300,30 @@ string TC_Port::exec(const char *cmd) std::string TC_Port::exec(const char* cmd, std::string &err) { - string fileData; + std::string result; #if TARGET_PLATFORM_WINDOWS FILE* fp = _popen(cmd, "r"); #else FILE* fp = popen(cmd, "r"); #endif - if(fp == NULL) { - err = "open '" + string(cmd) + "' error"; - return ""; - } - static size_t buf_len = 2 * 1024 * 1024; - char *buf = new char[buf_len]; - memset(buf, 0, buf_len); - fread(buf, sizeof(char), buf_len - 1, fp); + if(fp == NULL) { + err = "open '" + string(cmd) + "' error"; + return ""; + } + + char buffer[1024]; + while (!feof(fp)) { + if (fgets(buffer, 1024, fp) != NULL) + result.append(buffer); + } + #if TARGET_PLATFORM_WINDOWS _pclose(fp); #else pclose(fp); #endif - fileData = string(buf); - delete []buf; - return fileData; + return result; } #if TARGET_PLATFORM_LINUX @@ -724,9 +725,9 @@ vector TC_Port::getPidsByCmdline(const string &cmdLine, bool accurateMa FILE *TC_Port::freopen(const char * dst, const char * mode, FILE * src) { #if TARGET_PLATFORM_IOS - return freopen(dst, mode, src); + return ::freopen(dst, mode, src); #else - return freopen64(dst, mode, src); + return ::freopen64(dst, mode, src); #endif } From 2336f070f0c864aaaec548bd67c563b789acbef2 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 13 Mar 2024 14:12:15 +0800 Subject: [PATCH 72/81] fix servant handle error info log --- servant/libservant/ServantHandle.cpp | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/servant/libservant/ServantHandle.cpp b/servant/libservant/ServantHandle.cpp index 0847c7f0..67e42cd1 100644 --- a/servant/libservant/ServantHandle.cpp +++ b/servant/libservant/ServantHandle.cpp @@ -568,17 +568,6 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) cookieOp.setCookie(cookie); current->setCookie(cookie); } -// processSample(current); - -// if (_servant->getName() != current->getServantName()) -// { -// current->sendResponse(TARSSERVERNOSERVANTERR); -//// #ifdef TARS_OPENTRACKING -//// finishTracking(TARSSERVERNOSERVANTERR, current); -//// #endif -// return; -// } - int ret = TARSSERVERUNKNOWNERR; string sResultDesc; @@ -599,7 +588,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) } catch (TarsDecodeException &ex) { - TLOGERROR("[ServantHandle::handleTarsProtocol " << ex.what() << "]" << endl); + TLOGERROR("[ServantHandle::handleTarsProtocol decode error: " << _servant->getName() << current->getFuncName() << ":" << current->getFuncName() << ", " << ex.what() << "]" << endl); ret = TARSSERVERDECODEERR; @@ -607,7 +596,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) } catch (TarsEncodeException &ex) { - TLOGERROR("[ServantHandle::handleTarsProtocol " << ex.what() << "]" << endl); + TLOGERROR("[ServantHandle::handleTarsProtocol encode error: " << _servant->getName() << current->getFuncName() << ":" << current->getFuncName()<< ", " << ex.what() << "]" << endl); ret = TARSSERVERENCODEERR; @@ -615,7 +604,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) } catch (exception &ex) { - TLOGERROR("[ServantHandle::handleTarsProtocol " << ex.what() << "]" << endl); + TLOGERROR("[ServantHandle::handleTarsProtocol error: " << _servant->getName() << current->getFuncName() << ":" << current->getFuncName()<< ", " << ex.what() << "]" << endl); ret = TARSSERVERUNKNOWNERR; @@ -623,7 +612,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) } catch (...) { - TLOGERROR("[ServantHandle::handleTarsProtocol unknown error]" << endl); + TLOGERROR("[ServantHandle::handleTarsProtocol unknown error, server:" << _servant->getName() << "]" << endl); ret = TARSSERVERUNKNOWNERR; @@ -640,9 +629,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) { current->sendResponse(ret, response, {}, sResultDesc); } -#ifdef TARS_OPENTRACKING - finishTracking(ret, current); -#endif + } void ServantHandle::handleNoTarsProtocol(const TarsCurrentPtr ¤t) @@ -661,11 +648,11 @@ void ServantHandle::handleNoTarsProtocol(const TarsCurrentPtr ¤t) } catch (exception &ex) { - TLOGERROR("[ServantHandle::handleNoTarsProtocol " << ex.what() << "]" << endl); + TLOGERROR("[ServantHandle::handleNoTarsProtocol error: " << current->getServantName() << ", " << ex.what() << "]" << endl); } catch (...) { - TLOGERROR("[ServantHandle::handleNoTarsProtocol unknown error]" << endl); + TLOGERROR("[ServantHandle::handleNoTarsProtocol unknown error: " << current->getServantName() << endl); } if (current->isResponse() && !buffer.empty()) From d4f923e92f7236cdc008c5003562ad76d0da16e9 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 13 Mar 2024 14:38:43 +0800 Subject: [PATCH 73/81] fix servant handle log info --- servant/libservant/ServantHandle.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/servant/libservant/ServantHandle.cpp b/servant/libservant/ServantHandle.cpp index 67e42cd1..6cc7c4aa 100644 --- a/servant/libservant/ServantHandle.cpp +++ b/servant/libservant/ServantHandle.cpp @@ -588,7 +588,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) } catch (TarsDecodeException &ex) { - TLOGERROR("[ServantHandle::handleTarsProtocol decode error: " << _servant->getName() << current->getFuncName() << ":" << current->getFuncName() << ", " << ex.what() << "]" << endl); + TLOGERROR("[ServantHandle::handleTarsProtocol decode error: " << _servant->getName() << ":" << current->getFuncName() << ":" << current->getFuncName() << ", " << ex.what() << "]" << endl); ret = TARSSERVERDECODEERR; @@ -596,7 +596,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) } catch (TarsEncodeException &ex) { - TLOGERROR("[ServantHandle::handleTarsProtocol encode error: " << _servant->getName() << current->getFuncName() << ":" << current->getFuncName()<< ", " << ex.what() << "]" << endl); + TLOGERROR("[ServantHandle::handleTarsProtocol encode error: " << _servant->getName()<< ":" << current->getFuncName() << ":" << current->getFuncName()<< ", " << ex.what() << "]" << endl); ret = TARSSERVERENCODEERR; @@ -604,7 +604,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) } catch (exception &ex) { - TLOGERROR("[ServantHandle::handleTarsProtocol error: " << _servant->getName() << current->getFuncName() << ":" << current->getFuncName()<< ", " << ex.what() << "]" << endl); + TLOGERROR("[ServantHandle::handleTarsProtocol error: " << _servant->getName() << ":" << current->getFuncName() << ":" << current->getFuncName()<< ", " << ex.what() << "]" << endl); ret = TARSSERVERUNKNOWNERR; From bb80944c1b82f00b5894f432f1d430a9184fe6e5 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 13 Mar 2024 14:39:37 +0800 Subject: [PATCH 74/81] fix servant handle log --- servant/libservant/ServantHandle.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/servant/libservant/ServantHandle.cpp b/servant/libservant/ServantHandle.cpp index 6cc7c4aa..3b929408 100644 --- a/servant/libservant/ServantHandle.cpp +++ b/servant/libservant/ServantHandle.cpp @@ -588,7 +588,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) } catch (TarsDecodeException &ex) { - TLOGERROR("[ServantHandle::handleTarsProtocol decode error: " << _servant->getName() << ":" << current->getFuncName() << ":" << current->getFuncName() << ", " << ex.what() << "]" << endl); + TLOGERROR("[ServantHandle::handleTarsProtocol decode error: " << _servant->getName() << ":" << current->getFuncName() << ", " << ex.what() << "]" << endl); ret = TARSSERVERDECODEERR; @@ -596,7 +596,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) } catch (TarsEncodeException &ex) { - TLOGERROR("[ServantHandle::handleTarsProtocol encode error: " << _servant->getName()<< ":" << current->getFuncName() << ":" << current->getFuncName()<< ", " << ex.what() << "]" << endl); + TLOGERROR("[ServantHandle::handleTarsProtocol encode error: " << _servant->getName()<< ":" << current->getFuncName() << ", " << ex.what() << "]" << endl); ret = TARSSERVERENCODEERR; @@ -604,7 +604,7 @@ void ServantHandle::handleTarsProtocol(const CurrentPtr ¤t) } catch (exception &ex) { - TLOGERROR("[ServantHandle::handleTarsProtocol error: " << _servant->getName() << ":" << current->getFuncName() << ":" << current->getFuncName()<< ", " << ex.what() << "]" << endl); + TLOGERROR("[ServantHandle::handleTarsProtocol error: " << _servant->getName() << ":" << current->getFuncName() << ", " << ex.what() << "]" << endl); ret = TARSSERVERUNKNOWNERR; From dce5fd6957799782fe712b0e75580c1d5c38172e Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 14 Mar 2024 11:34:51 +0800 Subject: [PATCH 75/81] fix communicator _schedCommunicatorEpoll create use array fix unittest test push bug --- servant/libservant/Communicator.cpp | 55 ++++++++++++++++++----------- servant/libservant/StatReport.cpp | 2 +- servant/servant/Communicator.h | 15 ++++---- unit-test/hello_test.cpp | 2 +- unit-test/hello_test.h | 4 +-- unit-test/rpc/test_push.cpp | 2 +- 6 files changed, 48 insertions(+), 32 deletions(-) diff --git a/servant/libservant/Communicator.cpp b/servant/libservant/Communicator.cpp index bb0d5f65..9ab47751 100644 --- a/servant/libservant/Communicator.cpp +++ b/servant/libservant/Communicator.cpp @@ -338,6 +338,8 @@ void Communicator::initialize() _asyncThreadNum = MAX_CLIENT_ASYNCTHREAD_NUM; } + _schedCommunicatorEpoll.resize(MAX_CLIENT_NOTIFYEVENT_NUM); + bool merge = TC_Common::strto(getProperty("mergenetasync", "0")); //异步队列的大小 @@ -371,8 +373,8 @@ void Communicator::initialize() } { - std::unique_lock lock(_mutex); - _cond.wait(lock, [&]{ return _communicatorEpollStartNum == clientThreadNum; }); + std::unique_lock tlock(_mutex); + _cond.wait(tlock, [&]{ return _communicatorEpollStartNum == clientThreadNum; }); } //异步队列数目上报 @@ -483,43 +485,59 @@ vector> Communicator::getAllCommunicatorEpoll() return communicatorEpolls; } -void Communicator::forEachSchedCommunicatorEpoll(std::function &)> func) +void Communicator::forEachSchedCommunicatorEpoll(const std::function &)>& func) { - TC_LockT lock(_schedMutex); - for(auto it : _schedCommunicatorEpoll) +// TC_LockT lock(_schedMutex); +// for(const auto& it : _schedCommunicatorEpoll) +// { +// func(it.second); +// } + + for(const auto& it : _schedCommunicatorEpoll) { - func(it.second); + if(it) + { + func(it); + } } } shared_ptr Communicator::createSchedCommunicatorEpoll(size_t netThreadSeq, const shared_ptr &reqInfoQueue) { + assert(netThreadSeq < MAX_CLIENT_NOTIFYEVENT_NUM); + shared_ptr communicatorEpoll = std::make_shared(this, netThreadSeq); communicatorEpoll->initializeEpoller(); communicatorEpoll->initNotify(netThreadSeq, reqInfoQueue); - { - TC_LockT lock(_schedMutex); + _schedCommunicatorEpoll[netThreadSeq] = communicatorEpoll; - _schedCommunicatorEpoll.insert(std::make_pair(netThreadSeq, communicatorEpoll)); - } +// { +// TC_LockT lock(_schedMutex); +// +// _schedCommunicatorEpoll.insert(std::make_pair(netThreadSeq, communicatorEpoll)); +// } return communicatorEpoll; } void Communicator::eraseSchedCommunicatorEpoll(size_t netThreadSeq) { - shared_ptr ce; - { - TC_LockT lock(_schedMutex); + assert(netThreadSeq < MAX_CLIENT_NOTIFYEVENT_NUM); - ce = _schedCommunicatorEpoll[netThreadSeq]; - - _schedCommunicatorEpoll.erase(netThreadSeq); - } + shared_ptr ce = _schedCommunicatorEpoll[netThreadSeq]; + _schedCommunicatorEpoll[netThreadSeq].reset(); +// { +// TC_LockT lock(_schedMutex); +// +// ce = _schedCommunicatorEpoll[netThreadSeq]; +// +// _schedCommunicatorEpoll.erase(netThreadSeq); +// } +// if(ce) { ce->terminate(); @@ -531,13 +549,10 @@ void Communicator::reloadLocator() for (size_t i = 0; i < _communicatorEpoll.size(); ++i) { _communicatorEpoll[i]->_epoller->syncCallback(std::bind(&CommunicatorEpoll::loadObjectLocator, _communicatorEpoll[i].get())); - -// _communicatorEpoll[i]->loadObjectLocator(); } forEachSchedCommunicatorEpoll([](const shared_ptr &c){ c->_epoller->syncCallback(std::bind(&CommunicatorEpoll::loadObjectLocator, c.get())); -// c->loadObjectLocator(); }); } diff --git a/servant/libservant/StatReport.cpp b/servant/libservant/StatReport.cpp index ce9cb295..905e34fb 100755 --- a/servant/libservant/StatReport.cpp +++ b/servant/libservant/StatReport.cpp @@ -682,7 +682,7 @@ void StatReport::run() auto communicatorEpolls = _communicator->getAllCommunicatorEpoll(); - for(auto ce : communicatorEpolls) + for(const auto& ce : communicatorEpolls) { MapStatMicMsg * pStatMsg; while(ce->popStatMsg(pStatMsg)) diff --git a/servant/servant/Communicator.h b/servant/servant/Communicator.h index 201270af..0d184238 100644 --- a/servant/servant/Communicator.h +++ b/servant/servant/Communicator.h @@ -449,7 +449,7 @@ class SVT_DLL_API Communicator : public TC_HandleBase, public TC_ThreadRecMutex * * @param func */ - void forEachSchedCommunicatorEpoll(std::function &)> func); + void forEachSchedCommunicatorEpoll(const std::function &)>& func); /** * 创建一个协程内的网络通信器 @@ -518,17 +518,18 @@ class SVT_DLL_API Communicator : public TC_HandleBase, public TC_ThreadRecMutex /* * 公有网络线程 */ - vector> _communicatorEpoll;//[MAX_CLIENT_THREAD_NUM]; + vector> _communicatorEpoll; //[MAX_CLIENT_THREAD_NUM]; /** * 私有网络线程, 会动态变化 */ - unordered_map> _schedCommunicatorEpoll; +// unordered_map> _schedCommunicatorEpoll; + vector> _schedCommunicatorEpoll; //MAX_CLIENT_NOTIFYEVENT_NUM - /** - * 操作通信器的锁 - */ - TC_SpinLock _schedMutex; +// /** +// * 操作通信器的锁 +// */ +// TC_SpinLock _schedMutex; /** * 锁 diff --git a/unit-test/hello_test.cpp b/unit-test/hello_test.cpp index f21e4161..7c45f1ae 100755 --- a/unit-test/hello_test.cpp +++ b/unit-test/hello_test.cpp @@ -316,7 +316,7 @@ void HelloTest::testPush(Communicator *comm, const string &adapter) wait(1000); - ASSERT_TRUE(cNew->_onconnect); + ASSERT_TRUE(c->_onconnect); ASSERT_TRUE(cNew->_onprintresult); wait(10000); diff --git a/unit-test/hello_test.h b/unit-test/hello_test.h index 683a174a..031650e4 100755 --- a/unit-test/hello_test.h +++ b/unit-test/hello_test.h @@ -42,13 +42,13 @@ class PushCallBack : public ServantProxyCallback void onConnect(const TC_Endpoint &ep) { _onconnect = true; -// LOG_CONSOLE_DEBUG << "onConnect:" << ep.toString() << ", " << _onconnect << ", " << this << endl; + LOG_CONSOLE_DEBUG << "onConnect:" << ep.toString() << ", " << _onconnect << ", " << this << endl; } void onClose() { _onclose = true; -// LOG_CONSOLE_DEBUG << "onClose:" << _onclose << endl; + LOG_CONSOLE_DEBUG << "onClose:" << _onclose << endl; } bool _onclose = false; diff --git a/unit-test/rpc/test_push.cpp b/unit-test/rpc/test_push.cpp index 3b837c86..8c7848b0 100755 --- a/unit-test/rpc/test_push.cpp +++ b/unit-test/rpc/test_push.cpp @@ -46,7 +46,7 @@ class RegisterPushCallBack : public PushPrxCallback bool _close = false; }; -typedef TC_AutoPtr RegisterPushCallBackPtr; +//typedef TC_AutoPtr RegisterPushCallBackPtr; TEST_F(HelloTest, push) { From 6b5788990534b2eaf5128752e7e036717c135988 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 14 Mar 2024 11:42:17 +0800 Subject: [PATCH 76/81] fix remote log sync bug when log size too big --- servant/libservant/RemoteLogger.cpp | 62 +++++++++++++++-------------- servant/servant/RemoteLogger.h | 2 +- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/servant/libservant/RemoteLogger.cpp b/servant/libservant/RemoteLogger.cpp index 37afdcc6..00b18d63 100644 --- a/servant/libservant/RemoteLogger.cpp +++ b/servant/libservant/RemoteLogger.cpp @@ -300,62 +300,64 @@ void RemoteTimeWriteT::setTimeWriteT(TimeWriteT *pTimeWrite) void RemoteTimeWriteT::operator()(ostream &of, const deque > &buffer) { - const static uint32_t len = 2000; + //此处传递set信息到远程logserver + LogInfo stInfo; + stInfo.appname = _timeWrite->_app; + stInfo.servername = _timeWrite->_server; + stInfo.sFilename = _timeWrite->_file; + stInfo.sFormat = _timeWrite->_format; + stInfo.setdivision = _timeWrite->_setDivision; + stInfo.bHasSufix = _timeWrite->_hasSufix; + stInfo.bHasAppNamePrefix = _timeWrite->_hasAppNamePrefix; + stInfo.sConcatStr = _timeWrite->_concatStr; + stInfo.bHasSquareBracket = _timeWrite->_hasSquareBracket; + stInfo.sSepar = _timeWrite->_separ; + stInfo.sLogType = _timeWrite->_logType; + +// const static uint32_t len = 2000; //写远程日志 if(_timeWrite->_logPrx && !buffer.empty()) { - //大于50w条, 直接抛弃掉,否则容易导致内存泄漏 - if(buffer.size() > 500000) - { - _timeWrite->writeError(buffer); - return; - } - +// //大于50w条, 直接抛弃掉,否则容易导致内存泄漏 +// if(buffer.size() > 500000) +// { +// _timeWrite->writeError(buffer); +// return; +// } vector v; - v.reserve(len); - deque >::const_iterator it = buffer.begin(); + size_t len = 0; + deque>::const_iterator it = buffer.begin(); while(it != buffer.end()) { + len += it->second.size(); + v.push_back(it->second); ++it; //每次最多同步len条 - if(v.size() >= len) +// if(v.size() >= len) + if(len > 5*1024*1024 || v.size() > 200) { - sync2remote(v); + //>5M 或超过200条 就要传输了! + sync2remote(stInfo, v); v.clear(); - v.reserve(len); } } - if(v.size() > 0) + if(!v.empty()) { - sync2remote(v); + sync2remote(stInfo, v); } } } -void RemoteTimeWriteT::sync2remote(const vector &v) +void RemoteTimeWriteT::sync2remote(const LogInfo &stInfo, const vector &v) { try { - //此处传递set信息到远程logserver - LogInfo stInfo; - stInfo.appname = _timeWrite->_app; - stInfo.servername = _timeWrite->_server; - stInfo.sFilename = _timeWrite->_file; - stInfo.sFormat = _timeWrite->_format; - stInfo.setdivision = _timeWrite->_setDivision; - stInfo.bHasSufix = _timeWrite->_hasSufix; - stInfo.bHasAppNamePrefix = _timeWrite->_hasAppNamePrefix; - stInfo.sConcatStr = _timeWrite->_concatStr; - stInfo.bHasSquareBracket = _timeWrite->_hasSquareBracket; - stInfo.sSepar = _timeWrite->_separ; - stInfo.sLogType = _timeWrite->_logType; - _timeWrite->_logPrx->loggerbyInfo(stInfo,v, _timeWrite->_logPrx->tars_communicator()->getClientConfig().Context); if (_timeWrite->_reportSuccPtr) diff --git a/servant/servant/RemoteLogger.h b/servant/servant/RemoteLogger.h index 98ad441b..fe3fc413 100755 --- a/servant/servant/RemoteLogger.h +++ b/servant/servant/RemoteLogger.h @@ -291,7 +291,7 @@ class RemoteTimeWriteT /** * 同步到远程 */ - void sync2remote(const vector &buffer); + void sync2remote(const LogInfo &stInfo, const vector &buffer); /** * 染色日志同步到远程 From 21bf27958ad7b0262e3639c0d249d1b7b6229c11 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 14 Mar 2024 15:38:55 +0800 Subject: [PATCH 77/81] unit-test use tarsmock --- .../server/framework => mock}/ConfigImp.cpp | 0 .../server/framework => mock}/ConfigImp.h | 0 mock/DbHandle.cpp | 15 +- mock/FrameworkServer.cpp | 112 ++- mock/FrameworkServer.h | 3 + .../server/framework => mock}/LogImp.cpp | 0 {unit-test/server/framework => mock}/LogImp.h | 0 .../server/framework => mock}/StatImp.cpp | 2 +- .../server/framework => mock}/StatImp.h | 0 mock/TarsMockUtil.cpp | 2 +- mock/framework.h | 179 ++++- unit-test/CMakeLists.txt | 6 +- unit-test/certs.h | 3 +- unit-test/hello_test.cpp | 4 +- unit-test/hello_test.h | 8 +- unit-test/rpc/test_admin.cpp | 26 +- unit-test/rpc/test_async_rpc.cpp | 1 + unit-test/rpc/test_communicator.cpp | 2 +- unit-test/rpc/test_dyeing.cpp | 47 +- unit-test/rpc/test_proxy_timeout.cpp | 6 - unit-test/rpc/test_prx_update.cpp | 4 +- unit-test/rpc/test_registry.cpp | 61 +- unit-test/rpc/test_stat.cpp | 17 +- unit-test/rpc/test_trans.cpp | 16 +- unit-test/rpc/test_win_server.cpp | 22 +- unit-test/rpc/test_wup_trans.cpp | 6 +- unit-test/server/FrameworkServer.cpp | 154 ---- unit-test/server/FrameworkServer.h | 62 -- unit-test/server/HelloServer.cpp | 50 +- unit-test/server/RpcServer.cpp | 32 + unit-test/server/RpcServer.h | 32 + unit-test/server/WinServer.cpp | 2 +- unit-test/server/client.conf | 4 +- unit-test/server/framework.conf | 129 ---- unit-test/server/framework/DbHandle.cpp | 688 ------------------ unit-test/server/framework/DbHandle.h | 214 ------ unit-test/server/framework/QueryImp.cpp | 196 ----- unit-test/server/framework/QueryImp.h | 119 --- unit-test/server/hello.conf | 8 +- unit-test/server/rpc1.conf | 2 +- unit-test/server/rpc2.conf | 2 +- unit-test/server/rpc3.conf | 2 +- unit-test/server/windows.conf | 6 +- 43 files changed, 491 insertions(+), 1753 deletions(-) rename {unit-test/server/framework => mock}/ConfigImp.cpp (100%) rename {unit-test/server/framework => mock}/ConfigImp.h (100%) rename {unit-test/server/framework => mock}/LogImp.cpp (100%) rename {unit-test/server/framework => mock}/LogImp.h (100%) rename {unit-test/server/framework => mock}/StatImp.cpp (95%) rename {unit-test/server/framework => mock}/StatImp.h (100%) delete mode 100755 unit-test/server/FrameworkServer.cpp delete mode 100755 unit-test/server/FrameworkServer.h create mode 100644 unit-test/server/RpcServer.cpp create mode 100644 unit-test/server/RpcServer.h delete mode 100755 unit-test/server/framework.conf delete mode 100755 unit-test/server/framework/DbHandle.cpp delete mode 100755 unit-test/server/framework/DbHandle.h delete mode 100755 unit-test/server/framework/QueryImp.cpp delete mode 100755 unit-test/server/framework/QueryImp.h diff --git a/unit-test/server/framework/ConfigImp.cpp b/mock/ConfigImp.cpp similarity index 100% rename from unit-test/server/framework/ConfigImp.cpp rename to mock/ConfigImp.cpp diff --git a/unit-test/server/framework/ConfigImp.h b/mock/ConfigImp.h similarity index 100% rename from unit-test/server/framework/ConfigImp.h rename to mock/ConfigImp.h diff --git a/mock/DbHandle.cpp b/mock/DbHandle.cpp index c769cf0a..b2efef07 100755 --- a/mock/DbHandle.cpp +++ b/mock/DbHandle.cpp @@ -505,7 +505,20 @@ void CDbHandle::addInactiveEndPoint(const string& objName, const string &host, c void CDbHandle::cleanEndPoint() { - ObjectsCache objectsCache; + ObjectsCache objectsCache = _objectsCache; + + //从objectsCache删除不是tars的服务 + for (auto it = objectsCache.begin(); it != objectsCache.end();) + { + if (it->first.find("tars.") == string::npos) + { + objectsCache.erase(it++); + } + else + { + ++it; + } + } updateObjectsCache(objectsCache, true); } diff --git a/mock/FrameworkServer.cpp b/mock/FrameworkServer.cpp index 2996fd1d..806f2904 100755 --- a/mock/FrameworkServer.cpp +++ b/mock/FrameworkServer.cpp @@ -1,18 +1,122 @@ #include "mock/FrameworkServer.h" #include "mock/QueryImp.h" +#include "mock/ConfigImp.h" +#include "mock/QueryImp.h" +#include "mock/StatImp.h" +#include "mock/LogImp.h" +#include "mock/framework.h" using namespace std; +vector> _clientStatData; +vector> _serverStatData; + FrameworkServer::~FrameworkServer() { } - void FrameworkServer::initialize() { - addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".QueryObj"); + CDbHandle::addActiveEndPoint("tars.tarsmock.ConfigObj", "127.0.0.1", 11003, 1); + CDbHandle::addActiveEndPoint("tars.tarsmock.QueryObj", "127.0.0.1", 17890, 1); + CDbHandle::addActiveEndPoint("tars.tarsmock.LogObj", "127.0.0.1", 11005, 1); + CDbHandle::addActiveEndPoint("tars.tarsmock.StatObj", "127.0.0.1", 12004, 1); + + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".ConfigObj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".QueryObj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".StatObj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".LogObj"); + + string s; + loadLogFormat("","",s); + + //日志路径 + g_globe._log_path = _conf["/tars/log"]; + + //启动写线程 + g_globe._group.start(TC_Common::strto(_conf["/tars/log"])); + + string prefix = TC_Common::lower(_conf.get("/tars/log","true")); + g_globe._bIpPrefix = (prefix == "true") ? true : false; + + //增加对象 + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName +".LogObj"); + + TARS_ADD_ADMIN_CMD_NORMAL("reloadLogFormat", FrameworkServer::loadLogFormat); +} + + +bool FrameworkServer::loadLogFormat(const string& command, const string& params, string& result) +{ + TLOGDEBUG("FrameworkServer::loadLogFormat command:" << command << "|params:" << params << endl); + + try + { + TC_Config conf; + + conf.parseString(MOCK_FRAMEWORK_CONFIG); + + vector vHourlist; + + map mLogType; + + try + { + string sHour = conf["/tars/log/format"]; + + vHourlist = TC_Common::sepstr(sHour,"|;,"); + + sort(vHourlist.begin(),vHourlist.end()); + + unique(vHourlist.begin(),vHourlist.end()); + + result = "loadLogFormat succ:" + sHour; + + TLOGDEBUG("FrameworkServer::loadLogFormat result:" << result << endl); + + DLOG<< "FrameworkServer::loadLogFormat result:" << result << endl; + + //hour=app.server.file|app2.server2.file2 + map mType; + if(conf.getDomainMap("/tars/log/logtype", mType)) + { + map::iterator it = mType.begin(); + while(it != mType.end()) + { + vector vList = TC_Common::sepstr(it->second,"|;,"); + for(size_t i = 0;i < vList.size();i++) + { + //app.server.file = hour + mLogType[vList[i]] = it->first; + + TLOGDEBUG("FrameworkServer::loadLogFormat " << vList[i] << "|" << it->first << endl); + + DLOG<<"FrameworkServer::loadLogFormat " << vList[i] << "|" << it->first << endl; + } + it++; + } + } + + g_globe.update(vHourlist, mLogType); + + } + catch(exception& e) + { + result += e.what(); + TLOGERROR("FrameworkServer::loadLogFormat command:" << command << "|params:" << params << "|result:" << result << endl); + } + + return true; + } + catch(exception &e) + { + result += e.what(); + TLOGERROR("FrameworkServer::loadLogFormat command:" << command << "|params:" << params << "|result:" << result << endl); + } + + return false; } void FrameworkServer::destroyApp() @@ -21,5 +125,5 @@ void FrameworkServer::destroyApp() void FrameworkServer::run() { - waitForShutdown(); -} + this->waitForShutdown(); +} \ No newline at end of file diff --git a/mock/FrameworkServer.h b/mock/FrameworkServer.h index da264df4..20081c4e 100755 --- a/mock/FrameworkServer.h +++ b/mock/FrameworkServer.h @@ -28,6 +28,9 @@ class FrameworkServer : public Application, public TC_Thread protected: virtual void run(); + + + bool loadLogFormat(const string& command, const string& params, string& result); }; diff --git a/unit-test/server/framework/LogImp.cpp b/mock/LogImp.cpp similarity index 100% rename from unit-test/server/framework/LogImp.cpp rename to mock/LogImp.cpp diff --git a/unit-test/server/framework/LogImp.h b/mock/LogImp.h similarity index 100% rename from unit-test/server/framework/LogImp.h rename to mock/LogImp.h diff --git a/unit-test/server/framework/StatImp.cpp b/mock/StatImp.cpp similarity index 95% rename from unit-test/server/framework/StatImp.cpp rename to mock/StatImp.cpp index ad98b4bd..85ff5f88 100644 --- a/unit-test/server/framework/StatImp.cpp +++ b/mock/StatImp.cpp @@ -1,7 +1,7 @@  #include "StatImp.h" -#include "../FrameworkServer.h" +#include "FrameworkServer.h" /////////////////////////////////////////////////////////// // diff --git a/unit-test/server/framework/StatImp.h b/mock/StatImp.h similarity index 100% rename from unit-test/server/framework/StatImp.h rename to mock/StatImp.h diff --git a/mock/TarsMockUtil.cpp b/mock/TarsMockUtil.cpp index 067b8ea7..93d808e5 100644 --- a/mock/TarsMockUtil.cpp +++ b/mock/TarsMockUtil.cpp @@ -13,7 +13,7 @@ TarsMockUtil::TarsMockUtil() void TarsMockUtil::startFramework() { - _fs->main(FRAMEWORK_CONFIG); + _fs->main(MOCK_FRAMEWORK_CONFIG); _fs->start(); _fs->waitForReady(); } diff --git a/mock/framework.h b/mock/framework.h index 2635b9a1..e75480f1 100644 --- a/mock/framework.h +++ b/mock/framework.h @@ -1,39 +1,144 @@ #pragma once -#define FRAMEWORK_CONFIG " \n\ - \n\ - \n\ - locator = tars.tarsmock.QueryObj@tcp -h 127.0.0.1 -p 17890 \n \ - sync-invoke-timeout = 5000 \n \ - async-invoke-timeout = 60000 \n \ - refresh-endpoint-interval = 5000 \n \ - sendqueuelimit = 1000000 \n \ - asyncqueuecap = 1000000 \n \ - asyncthread = 3 \n \ - netthread = 2 \n \ - mergenetasync = 0 \n \ - modulename = tars.tarsmock \n \ - \n \ - \n \ - start_output = ERROR \n \ - closecout = 0 \n \ - app = tars \n \ - server = tarsmock \n \ - basepath = . \n \ - datapath = . \n \ - logpath = . \n \ - netthread = 1 \n \ - mergenetimp = 0 \n \ - opencoroutine = 0 \n \ - loglevel=TARS \n \ - \n \ - endpoint = tcp -h 127.0.0.1 -p 13004 -t 60000 \n \ - allow = \n \ - maxconns = 4096 \n \ - threads = 5 \n \ - servant = tars.tarsmock.QueryObj \n \ - queuecap = 1000000 \n \ - \n \ - \n \ - \n\ -" +#include + +const static std::string &MOCK_FRAMEWORK_CONFIG = R"( + + + #proxy需要的配置 + + #地址 + locator = tars.tarsmock.QueryObj@tcp -h 127.0.0.1 -p 17890 + #最大超时时间(毫秒) + sync-invoke-timeout = 5000 + async-invoke-timeout = 60000 + #刷新端口时间间隔(毫秒) + refresh-endpoint-interval = 5000 + #模块间调用[可选] + stat = tars.tarsmock.StatObj + #发送队列长度 + sendqueuelimit = 100000 + #异步回调队列个数限制 + asyncqueuecap = 100000 + #网络异步回调线程个数 + asyncthread = 3 + #网络线程个数 + netthread = 2 + #合并回调线程和网络线程(以网络线程个数为准) + mergenetasync = 0 + #模块名称 + modulename = tars.tarsmock + + + + #定义所有绑定的IP + + start_output = ERROR + closecout = 0 + #应用名称 + app = tars + #服务名称 + server = tarsmock + #服务的数据目录,可执行文件,配置文件等 + basepath = . + datapath = . + #日志路径 + logpath = . + #网络线程个数 + netthread = 1 + #合并网络和业务线程(以网络线程个数为准) + mergenetimp = 0 + opencoroutine = 0 + loglevel=TARS + + #本地管理套接字[可选] + local = tcp -h 127.0.0.1 -p 15791 -t 10000 + + #本地node的ip:port:timeout[可选] +# node = ServerObj@tcp -h 127.0.0.1 -p 2345 -t 10000 + #配置中心的地址[可选] + config = tars.tarsmock.ConfigObj + #配置中心的地址[可选] +# notify = tars.tarsconfig.NotifyObj + #远程LogServer[可选] + log = tars.tarsmock.LogObj + + + #ip:port:timeout + endpoint = tcp -h 127.0.0.1 -p 11003 -t 60000 + #allow ip + allow = + #max connection num + maxconns = 4096 + #imp thread num + threads = 5 + #servant + servant = tars.tarsmock.ConfigObj + #queue capacity + queuecap = 1000000 + + + + #ip:port:timeout + endpoint = tcp -h 127.0.0.1 -p 11005 -t 60000 + #allow ip + allow = + #max connection num + maxconns = 4096 + #imp thread num + threads = 5 + #servant + servant = tars.tarsmock.LogObj + #queue capacity + queuecap = 1000000 + + + + #ip:port:timeout + endpoint = tcp -h 127.0.0.1 -p 17890 -t 60000 + #allow ip + allow = + #max connection num + maxconns = 4096 + #imp thread num + threads = 5 + #servant + servant = tars.tarsmock.QueryObj + #queue capacity + queuecap = 1000000 + + + + #ip:port:timeout + endpoint = tcp -h 127.0.0.1 -p 12004 -t 60000 + #allow ip + allow = + #max connection num + maxconns = 4096 + #imp thread num + threads = 5 + #servant + servant = tars.tarsmock.StatObj + #queue capacity + queuecap = 1000000 + + + + + + logpath = . + logthread = 1 + ipfix = true + + hour=app.server.file|app2.server2.file2 + + + app.server.file = hour + + + + + +)"; + + diff --git a/unit-test/CMakeLists.txt b/unit-test/CMakeLists.txt index 04ad1afa..6c9154ae 100755 --- a/unit-test/CMakeLists.txt +++ b/unit-test/CMakeLists.txt @@ -1,5 +1,6 @@ project(unit-test) + include_directories(${servant_SOURCE_DIR}/protocol/framework) include_directories(${servant_SOURCE_DIR}/protocol/servant) @@ -7,14 +8,15 @@ include_directories(${CMAKE_BINARY_DIR}/src/gtest/include) link_directories(${CMAKE_BINARY_DIR}/src/gtest/lib) link_directories(${CMAKE_BINARY_DIR}/src/gtest/lib64) include_directories(./) +include_directories(../) build_tars_server("unit-test" "") add_definitions(-DCMAKE_SOURCE_DIR="${PROJECT_SOURCE_DIR}") -target_link_libraries(unit-test ${LIB_GTEST}) +target_link_libraries(unit-test ${LIB_GTEST} tarsmock) if(TARS_MYSQL) target_link_libraries(unit-test ${LIB_MYSQL}) endif() -add_dependencies(unit-test FRAMEWORK-PROTOCOL) +add_dependencies(unit-test FRAMEWORK-PROTOCOL tarsmock) diff --git a/unit-test/certs.h b/unit-test/certs.h index 4513bc15..d7f5dc56 100755 --- a/unit-test/certs.h +++ b/unit-test/certs.h @@ -2,6 +2,7 @@ #define PATH_HEAER #include "util/tc_config.h" +#include "mock/framework.h" using namespace tars; @@ -30,7 +31,7 @@ inline TC_Config CLIENT_CONFIG() inline TC_Config FRAMEWORK_CONFIG() { TC_Config conf; - conf.parseFile(CONFIGPATH + "/server/framework.conf"); + conf.parseString(MOCK_FRAMEWORK_CONFIG); return conf; } diff --git a/unit-test/hello_test.cpp b/unit-test/hello_test.cpp index 7c45f1ae..1f458957 100755 --- a/unit-test/hello_test.cpp +++ b/unit-test/hello_test.cpp @@ -866,7 +866,7 @@ void HelloTest::forEach(function func) HelloServer server; startServer(server, (TC_EpollServer::SERVER_OPEN_COROUTINE) i); - func(server.getCommunicator().get()); + func(server.getApplicationCommunicator().get()); stopServer(server); } @@ -895,7 +895,7 @@ void HelloTest::forEachInCoroutine(function func) s->terminate(); }); - func(server.getCommunicator().get()); + func(server.getApplicationCommunicator().get()); }); diff --git a/unit-test/hello_test.h b/unit-test/hello_test.h index 031650e4..571581f3 100755 --- a/unit-test/hello_test.h +++ b/unit-test/hello_test.h @@ -193,8 +193,11 @@ class HelloTest : public testing::Test //添加日志 static void SetUpTestCase() { + LocalRollLogger::getInstance()->setLogInfo("tars", "test", ".", 1024*1024*10, 5, nullptr, ""); + + LocalRollLogger::getInstance()->logger()->setLogLevel("TARS"); + } - } static void TearDownTestCase() { } @@ -259,7 +262,7 @@ class HelloTest : public testing::Test // comm->setProperty("asyncqueuecap", "1000000"); string obj = getObj(_conf, adapter); - LOG_CONSOLE_DEBUG << obj << endl; +// LOG_CONSOLE_DEBUG << obj << endl; T prx = comm->stringToProxy(obj); prx->tars_timeout(60000); @@ -376,7 +379,6 @@ class HelloTest : public testing::Test protected: int _count = 1000; - // int _count = 10; string _buffer; diff --git a/unit-test/rpc/test_admin.cpp b/unit-test/rpc/test_admin.cpp index 53e9b523..549cecf0 100755 --- a/unit-test/rpc/test_admin.cpp +++ b/unit-test/rpc/test_admin.cpp @@ -17,25 +17,22 @@ #include "hello_test.h" #include "../server/WinServer.h" #include "servant/AdminF.h" -#include "server/FrameworkServer.h" -#include "server/framework/DbHandle.h" +#include "mock/TarsMockUtil.h" +#include "mock/DbHandle.h" +#include "mock/ConfigImp.h" TEST_F(HelloTest, testAdmin) { - LocalRollLogger::getInstance()->setLogInfo("tars", "test", ".", 1024*1024*10, 5, nullptr, ""); - - LocalRollLogger::getInstance()->logger()->setLogLevel("TARS"); - - FrameworkServer fs; - startServer(fs, FRAMEWORK_CONFIG()); + TarsMockUtil tarsMockUtil; + tarsMockUtil.startFramework(); + ConfigImp::setConfigFile("test.conf", "test-content"); CDbHandle::cleanEndPoint(); - CDbHandle::addActiveEndPoint("TestApp.FrameworkServer.ConfigObj", 11003, 1); WinServer ws; startServer(ws, WIN_CONFIG()); - CommunicatorPtr c = ws.getCommunicator(); + CommunicatorPtr c = ws.getApplicationCommunicator(); string adminObj = "AdminObj@" + getLocalEndpoint(WIN_CONFIG()).toString(); @@ -81,11 +78,6 @@ TEST_F(HelloTest, testAdmin) string reloadlocator = adminFPrx->notify("tars.reloadlocator reload"); EXPECT_TRUE(reloadlocator.find("[notify prefix object num:1]") != string::npos); -// string closecore = adminFPrx->notify("tars.closecore no"); -// EXPECT_TRUE(closecore.find("after set cur:18446744073709551615;max: 18446744073709551615") != string::npos); -// closecore = adminFPrx->notify("tars.closecore yes"); -// EXPECT_TRUE(closecore.find("after set cur:0;max: 18446744073709551615") != string::npos); - string errorcmd = adminFPrx->notify("tars.errorcmd"); EXPECT_STREQ(errorcmd.c_str(), ""); @@ -96,8 +88,6 @@ TEST_F(HelloTest, testAdmin) EXPECT_STREQ(normaldeletecmd.c_str(), "[notify servant object num:1]\n[1]:Delete success!\n"); stopServer(ws); - stopServer(fs); + tarsMockUtil.stopFramework(); } - - diff --git a/unit-test/rpc/test_async_rpc.cpp b/unit-test/rpc/test_async_rpc.cpp index ace19ec2..7d2100b3 100755 --- a/unit-test/rpc/test_async_rpc.cpp +++ b/unit-test/rpc/test_async_rpc.cpp @@ -12,6 +12,7 @@ TEST_F(HelloTest, test) } + TEST_F(HelloTest, rpcASyncGlobalCommunicator) { { diff --git a/unit-test/rpc/test_communicator.cpp b/unit-test/rpc/test_communicator.cpp index f4b2db97..b1bf7b91 100755 --- a/unit-test/rpc/test_communicator.cpp +++ b/unit-test/rpc/test_communicator.cpp @@ -277,7 +277,7 @@ TEST_F(HelloTest, testNotifyCtrlC) HelloServer server; startServer(server, (TC_EpollServer::SERVER_OPEN_COROUTINE) 0); - HelloPrx prx = getObj(server.getCommunicator(), "HelloAdapter"); + HelloPrx prx = getObj(server.getApplicationCommunicator(), "HelloAdapter"); for(int i = 0; i < 10000; i++) { diff --git a/unit-test/rpc/test_dyeing.cpp b/unit-test/rpc/test_dyeing.cpp index 67cd504d..5dcb15f6 100755 --- a/unit-test/rpc/test_dyeing.cpp +++ b/unit-test/rpc/test_dyeing.cpp @@ -16,8 +16,10 @@ #include "hello_test.h" #include "servant/AdminF.h" -#include "server/FrameworkServer.h" -#include "server/framework/DbHandle.h" +//#include "server/FrameworkServer.h" +//#include "server/framework/DbHandle.h" +#include "mock/TarsMockUtil.h" +#include "mock/DbHandle.h" #define DYEFILEPATH (string("tars_dyeing") + FILE_SEP) @@ -52,11 +54,11 @@ TEST_F(HelloTest, DyeingNo) HelloServer server; startServer(server, (TC_EpollServer::SERVER_OPEN_COROUTINE) 0); - HelloPrx prx = getObj(server.getCommunicator().get(), "HelloAdapter"); + HelloPrx prx = getObj(server.getApplicationCommunicator().get(), "HelloAdapter"); // int64_t tBegin = TC_TimeProvider::getInstance()->getNowMs(); -// HelloPrx dyeingPrx= server.getCommunicator()->stringToProxy(DYEING_SERVANT_ENDPOINT); +// HelloPrx dyeingPrx= server.getApplicationCommunicator()->stringToProxy(DYEING_SERVANT_ENDPOINT); string strIn="123456"; string strOut; int ret=prx->testDyeing(strIn,strOut); @@ -70,26 +72,28 @@ TEST_F(HelloTest, DyeingNo) //打开染色开关,但未使用染色key调用的场景 TEST_F(HelloTest, DyeingNoKey) { - FrameworkServer fs; - startServer(fs, FRAMEWORK_CONFIG()); + TarsMockUtil tarsMockUtil; + tarsMockUtil.startFramework(); +// FrameworkServer fs; +// startServer(fs, FRAMEWORK_CONFIG()); - CDbHandle::cleanEndPoint(); - CDbHandle::addActiveEndPoint("TestApp.FrameworkServer.LogObj", 11005, 1); +// CDbHandle::cleanEndPoint(); +// CDbHandle::addActiveEndPoint("tars.tarsmock.LogObj", "127.0.0.1", 11005, 1); HelloServer server; startServer(server, (TC_EpollServer::SERVER_OPEN_COROUTINE) 0); // int64_t tBegin = TC_TimeProvider::getInstance()->getNowMs(); - AdminFPrx adminFPrx = server.getCommunicator()->stringToProxy("AdminObj@" + getLocalEndpoint(CONFIG()).toString()); + AdminFPrx adminFPrx = server.getApplicationCommunicator()->stringToProxy("AdminObj@" + getLocalEndpoint(CONFIG()).toString()); -// AdminFPrx adminFPrx = server.getCommunicator()->stringToProxy(UNIT_TEST_ADMIN_NAME_ENDPOINT); +// AdminFPrx adminFPrx = server.getApplicationCommunicator()->stringToProxy(UNIT_TEST_ADMIN_NAME_ENDPOINT); string setdyeing = adminFPrx->notify("tars.setdyeing 123456 TestApp.HelloServer.HelloObj testDyeing"); EXPECT_TRUE(setdyeing.find("DyeingKey=123456") != string::npos); - HelloPrx prx = getObj(server.getCommunicator().get(), "HelloAdapter"); + HelloPrx prx = getObj(server.getApplicationCommunicator().get(), "HelloAdapter"); -// DyeingTestPrx dyeingPrx= server.getCommunicator()->stringToProxy(DYEING_SERVANT_ENDPOINT); +// DyeingTestPrx dyeingPrx= server.getApplicationCommunicator()->stringToProxy(DYEING_SERVANT_ENDPOINT); string strIn="abc"; string strOut; int ret=prx->testDyeing(strIn,strOut); @@ -99,29 +103,31 @@ TEST_F(HelloTest, DyeingNoKey) // TLOGDEBUG("dyeing without key request time cost: "<< " | " << TC_TimeProvider::getInstance()->getNowMs() - tBegin << "(ms)" << endl); stopServer(server); - stopServer(fs); + tarsMockUtil.stopFramework(); +// stopServer(fs); } //打开染色开关,使用染色key调用的场景 TEST_F(HelloTest, DyeingKey) { - FrameworkServer fs; - startServer(fs, FRAMEWORK_CONFIG()); + TarsMockUtil tarsMockUtil; +// FrameworkServer fs; +// startServer(fs, FRAMEWORK_CONFIG()); - CDbHandle::cleanEndPoint(); - CDbHandle::addActiveEndPoint("TestApp.FrameworkServer.LogObj", 11005, 1); +// CDbHandle::cleanEndPoint(); +// CDbHandle::addActiveEndPoint("tars.tarsmock.LogObj", "127.0.0.1", 11005, 1); HelloServer server; startServer(server, (TC_EpollServer::SERVER_OPEN_COROUTINE) 0); - AdminFPrx adminFPrx = server.getCommunicator()->stringToProxy("AdminObj@" + getLocalEndpoint(CONFIG()).toString()); + AdminFPrx adminFPrx = server.getApplicationCommunicator()->stringToProxy("AdminObj@" + getLocalEndpoint(CONFIG()).toString()); string setdyeing = adminFPrx->notify("tars.setdyeing 123456 TestApp.HelloServer.HelloObj testDyeing"); EXPECT_TRUE(setdyeing.find("DyeingKey=123456") != string::npos); TC_File::removeFile("./tars_dyeing", true); - HelloPrx prx = getObj(server.getCommunicator().get(), "HelloAdapter"); + HelloPrx prx = getObj(server.getApplicationCommunicator().get(), "HelloAdapter"); string strIn="123456"; string strOut; @@ -138,7 +144,8 @@ TEST_F(HelloTest, DyeingKey) EXPECT_EQ(getFileLine(dyeDebugFile.c_str()), 4); stopServer(server); - stopServer(fs); + tarsMockUtil.stopFramework(); +// stopServer(fs); } diff --git a/unit-test/rpc/test_proxy_timeout.cpp b/unit-test/rpc/test_proxy_timeout.cpp index 89225b81..8b9e938b 100755 --- a/unit-test/rpc/test_proxy_timeout.cpp +++ b/unit-test/rpc/test_proxy_timeout.cpp @@ -10,28 +10,22 @@ TEST_F(HelloTest, proxyInvokeTimeout) checkSyncTimeout(comm); }, c.get()); - LOG_CONSOLE_DEBUG << endl; - transInCoroutineGlobalCommunicator([&](Communicator *comm){ checkSyncTimeout(comm); }, c.get()); - LOG_CONSOLE_DEBUG << endl; transServerCommunicator([&](Communicator *comm){ checkSyncTimeout(comm); }); - LOG_CONSOLE_DEBUG << endl; transInCoroutineServerCommunicator([&](Communicator *comm){ checkSyncTimeout(comm); }); - LOG_CONSOLE_DEBUG << endl; transAllocCommunicator([&](Communicator *comm){ checkSyncTimeout(comm); }); - LOG_CONSOLE_DEBUG << endl; transInCoroutineAllocCommunicator([&](Communicator *comm){ checkSyncTimeout(comm); }); diff --git a/unit-test/rpc/test_prx_update.cpp b/unit-test/rpc/test_prx_update.cpp index fb4ccea5..07cf2861 100755 --- a/unit-test/rpc/test_prx_update.cpp +++ b/unit-test/rpc/test_prx_update.cpp @@ -2,8 +2,8 @@ #include "hello_test.h" #include "servant/CommunicatorEpoll.h" #include "servant/ObjectProxy.h" -#include "server/framework/DbHandle.h" -#include "server/FrameworkServer.h" +//#include "server/framework/DbHandle.h" +#include "server/RpcServer.h" #include "QueryF.h" TEST_F(HelloTest, prxUpdate) diff --git a/unit-test/rpc/test_registry.cpp b/unit-test/rpc/test_registry.cpp index a8f9fbda..a407ce5e 100755 --- a/unit-test/rpc/test_registry.cpp +++ b/unit-test/rpc/test_registry.cpp @@ -2,9 +2,10 @@ #include "hello_test.h" #include "servant/CommunicatorEpoll.h" #include "servant/ObjectProxy.h" -#include "server/framework/DbHandle.h" -#include "server/FrameworkServer.h" +#include "mock/DbHandle.h" +#include "mock/TarsMockUtil.h" #include "QueryF.h" +#include "server/RpcServer.h" TEST_F(HelloTest, registryQuery) { @@ -17,11 +18,13 @@ TEST_F(HelloTest, registryQuery) TC_Config fconf = FRAMEWORK_CONFIG(); CDbHandle::cleanEndPoint(); - CDbHandle::addActiveEndPoint("TestApp.RpcServer.HelloObj", 9990, 1); - CDbHandle::addActiveEndPoint("TestApp.RpcServer.HelloObj", 9991, 1); + CDbHandle::addActiveEndPoint("TestApp.RpcServer.HelloObj", "127.0.0.1", 9990, 1); + CDbHandle::addActiveEndPoint("TestApp.RpcServer.HelloObj", "127.0.0.1", 9991, 1); - FrameworkServer fs; - startServer(fs, FRAMEWORK_CONFIG()); + TarsMockUtil tarsMockUtil; + tarsMockUtil.startFramework(); +// FrameworkServer fs; +// startServer(fs, FRAMEWORK_CONFIG()); string obj = getObj(fconf, "RegistryAdapter"); @@ -36,7 +39,7 @@ TEST_F(HelloTest, registryQuery) } { - CDbHandle::addActiveEndPoint("TestApp.RpcServer.HelloObj", 9992, 1); + CDbHandle::addActiveEndPoint("TestApp.RpcServer.HelloObj", "127.0.0.1", 9992, 1); TC_Common::sleep(6); @@ -55,7 +58,7 @@ TEST_F(HelloTest, registryQuery) } { - CDbHandle::addActiveEndPoint("TestApp.RpcServer.HelloObj", 9993, 1); + CDbHandle::addActiveEndPoint("TestApp.RpcServer.HelloObj", "127.0.0.1", 9993, 1); TC_Common::sleep(6); @@ -74,16 +77,17 @@ TEST_F(HelloTest, registryQuery) } } - stopServer(fs); + tarsMockUtil.stopFramework(); +// stopServer(fs); } #define START_FRAMEWORK_SERVER_1_2 \ CDbHandle::cleanEndPoint(); \ -CDbHandle::addActiveEndPoint("TestApp.RpcServer.HelloObj", 9990, 1); \ -CDbHandle::addActiveEndPoint("TestApp.RpcServer.HelloObj", 9991, 1); \ -FrameworkServer fs; \ -startServer(fs, FRAMEWORK_CONFIG()); \ +CDbHandle::addActiveEndPoint("TestApp.RpcServer.HelloObj", "127.0.0.1", 9990, 1); \ +CDbHandle::addActiveEndPoint("TestApp.RpcServer.HelloObj", "127.0.0.1", 9991, 1); \ +TarsMockUtil tarsMockUtil; \ +tarsMockUtil.startFramework(); \ RpcServer rpc1Server; \ startServer(rpc1Server, RPC1_CONFIG()); \ RpcServer rpc2Server; \ @@ -92,16 +96,16 @@ startServer(rpc2Server, RPC2_CONFIG()); #define START_FRAMEWORK_HTTP_SERVER_1_2 \ CDbHandle::cleanEndPoint(); \ -CDbHandle::addActiveEndPoint("TestApp.RpcServer.HttpObj", 8180, 1); \ -CDbHandle::addActiveEndPoint("TestApp.RpcServer.HttpObj", 8181, 1); \ -FrameworkServer fs; \ -startServer(fs, FRAMEWORK_CONFIG()); \ +CDbHandle::addActiveEndPoint("TestApp.RpcServer.HttpObj", "127.0.0.1", 8180, 1); \ +CDbHandle::addActiveEndPoint("TestApp.RpcServer.HttpObj", "127.0.0.1", 8181, 1); \ +TarsMockUtil tarsMockUtil; \ +tarsMockUtil.startFramework(); \ RpcServer rpc1Server; \ startServer(rpc1Server, RPC1_CONFIG()); \ RpcServer rpc2Server; \ startServer(rpc2Server, RPC2_CONFIG()); -#define STOP_FRAMEWORK_SERVER stopServer(fs); +#define STOP_FRAMEWORK_SERVER tarsMockUtil.stopFramework(); #define HELLO_CALL {\ HelloPrx qPrx = comm->stringToProxy("TestApp.RpcServer.HelloObj"); \ @@ -114,7 +118,7 @@ ASSERT_TRUE(out == _buffer); } #define CHECK_REGISTRY_UPDATE {\ stopServer(rpc1Server); \ CDbHandle::cleanEndPoint(); \ -CDbHandle::addActiveEndPoint("TestApp.RpcServer.HelloObj", 9992, 1); \ +CDbHandle::addActiveEndPoint("TestApp.RpcServer.HelloObj", "127.0.0.1", 9992, 1); \ RpcServer rpc3Server; \ startServer(rpc3Server, RPC3_CONFIG()); \ wait(6000); \ @@ -188,7 +192,8 @@ TEST_F(HelloTest, registryRpc) LOG_CONSOLE_DEBUG << endl; stopServer(rpc1Server); stopServer(rpc2Server); - stopServer(fs); + tarsMockUtil.stopFramework(); +// stopServer(fs); } @@ -196,8 +201,8 @@ TEST_F(HelloTest, registryRpc) TEST_F(HelloTest, registryRpcConHashInvoke) { START_FRAMEWORK_SERVER_1_2 - CDbHandle::addInactiveEndPoint("TestApp.RpcServer.HelloObj", 9989, 1); - CDbHandle::addInactiveEndPoint("TestApp.RpcServer.HelloObj", 9992, 1); + CDbHandle::addInactiveEndPoint("TestApp.RpcServer.HelloObj", "127.0.0.1", 9989, 1); + CDbHandle::addInactiveEndPoint("TestApp.RpcServer.HelloObj","127.0.0.1", 9992, 1); shared_ptr c = getCommunicator(); @@ -330,7 +335,7 @@ TEST_F(HelloTest, registryRpcCheckUpdateList) //更新主控ip list CDbHandle::cleanEndPoint(); - CDbHandle::addActiveEndPoint("TestApp.RpcServer.HelloObj", 9992, 1); + CDbHandle::addActiveEndPoint("TestApp.RpcServer.HelloObj", "127.0.0.1", 9992, 1); RpcServer rpc3Server; startServer(rpc3Server, RPC3_CONFIG()); @@ -430,7 +435,7 @@ TEST_F(HelloTest, registryHttpRpcCheckUpdateList) //更新主控ip list CDbHandle::cleanEndPoint(); - CDbHandle::addActiveEndPoint("TestApp.RpcServer.HttpObj", 8182, 1); + CDbHandle::addActiveEndPoint("TestApp.RpcServer.HttpObj", "127.0.0.1", 8182, 1); RpcServer rpc3Server; startServer(rpc3Server, RPC3_CONFIG()); @@ -471,8 +476,8 @@ TEST_F(HelloTest, registryHttpRpcCheckUpdateList) TEST_F(HelloTest, registryRpcHashTagInvoke) { START_FRAMEWORK_SERVER_1_2 - CDbHandle::addInactiveEndPoint("TestApp.RpcServer.HelloObj", 9989, 1); - CDbHandle::addInactiveEndPoint("TestApp.RpcServer.HelloObj", 9992, 1); + CDbHandle::addInactiveEndPoint("TestApp.RpcServer.HelloObj", "127.0.0.1", 9989, 1); + CDbHandle::addInactiveEndPoint("TestApp.RpcServer.HelloObj", "127.0.0.1", 9992, 1); shared_ptr c = getCommunicator(); @@ -495,8 +500,8 @@ TEST_F(HelloTest, registryRpcHashTagInvoke) TEST_F(HelloTest, registryRpcMultiHashTagInvoke) { START_FRAMEWORK_SERVER_1_2 - CDbHandle::addInactiveEndPoint("TestApp.RpcServer.HelloObj", 9989, 1); - CDbHandle::addInactiveEndPoint("TestApp.RpcServer.HelloObj", 9992, 1); + CDbHandle::addInactiveEndPoint("TestApp.RpcServer.HelloObj", "127.0.0.1", 9989, 1); + CDbHandle::addInactiveEndPoint("TestApp.RpcServer.HelloObj", "127.0.0.1", 9992, 1); shared_ptr c = getCommunicator(); diff --git a/unit-test/rpc/test_stat.cpp b/unit-test/rpc/test_stat.cpp index 200b94d9..94ee7a98 100755 --- a/unit-test/rpc/test_stat.cpp +++ b/unit-test/rpc/test_stat.cpp @@ -1,6 +1,6 @@  #include "hello_test.h" -#include "server/FrameworkServer.h" +#include "mock/TarsMockUtil.h" int getStatCount(const vector> &data) { @@ -21,8 +21,10 @@ int getStatCount(const vector> & TEST_F(HelloTest, statReport) { - FrameworkServer fs; - startServer(fs, FRAMEWORK_CONFIG()); + TarsMockUtil tarsMockUtil; + tarsMockUtil.startFramework(); +// FrameworkServer fs; +// startServer(fs, FRAMEWORK_CONFIG()); HelloServer hs; startServer(hs, CONFIG()); @@ -62,14 +64,15 @@ TEST_F(HelloTest, statReport) // LOG_CONSOLE_DEBUG << "server stat:" << _serverStatData.size() << endl; stopServer(hs); - stopServer(fs); + tarsMockUtil.stopFramework(); +// stopServer(fs); } TEST_F(HelloTest, statReportInCoroutine) { - FrameworkServer fs; - startServer(fs, FRAMEWORK_CONFIG()); + TarsMockUtil tarsMockUtil; + tarsMockUtil.startFramework(); HelloServer hs; startServer(hs, CONFIG()); @@ -110,5 +113,5 @@ TEST_F(HelloTest, statReportInCoroutine) }, true); stopServer(hs); - stopServer(fs); + tarsMockUtil.stopFramework(); } \ No newline at end of file diff --git a/unit-test/rpc/test_trans.cpp b/unit-test/rpc/test_trans.cpp index 97b3180d..0868fc7b 100755 --- a/unit-test/rpc/test_trans.cpp +++ b/unit-test/rpc/test_trans.cpp @@ -1,7 +1,7 @@  #include "hello_test.h" -TEST_F(HelloTest, rpcTransGlobalCommunicator) +TEST_F(HelloTest, transGlobalCommunicator) { shared_ptr c = getCommunicator(); @@ -22,7 +22,7 @@ TEST_F(HelloTest, rpcTransGlobalCommunicator) }, c.get()); } -TEST_F(HelloTest, rpcTransGlobalCommunicatorInCoroutine) +TEST_F(HelloTest, transGlobalCommunicatorInCoroutine) { shared_ptr c = getCommunicator(); @@ -43,7 +43,7 @@ TEST_F(HelloTest, rpcTransGlobalCommunicatorInCoroutine) }, c.get()); } -TEST_F(HelloTest, rpcTransServerCommunicator) +TEST_F(HelloTest, transServerCommunicator) { transServerCommunicator([&](Communicator *comm){ checkTransSyncASync(comm); @@ -62,7 +62,7 @@ TEST_F(HelloTest, rpcTransServerCommunicator) }); } -TEST_F(HelloTest, rpcTransServerCommunicatorInCoroutine) +TEST_F(HelloTest, transServerCommunicatorInCoroutine) { transInCoroutineServerCommunicator([&](Communicator *comm){ checkTransSyncASync(comm); @@ -81,7 +81,7 @@ TEST_F(HelloTest, rpcTransServerCommunicatorInCoroutine) }); } -TEST_F(HelloTest, rpcTransAllocCommunicator) +TEST_F(HelloTest, transAllocCommunicator) { transAllocCommunicator([&](Communicator *comm){ checkTransSyncASync(comm); @@ -100,7 +100,7 @@ TEST_F(HelloTest, rpcTransAllocCommunicator) }); } -TEST_F(HelloTest, rpcTransAllocCommunicatorInCoroutine) +TEST_F(HelloTest, transAllocCommunicatorInCoroutine) { transInCoroutineAllocCommunicator([&](Communicator *comm){ checkTransSyncASync(comm); @@ -120,7 +120,7 @@ TEST_F(HelloTest, rpcTransAllocCommunicatorInCoroutine) } -TEST_F(HelloTest, rpcTransComplexCommunicator) +TEST_F(HelloTest, transComplexCommunicator) { shared_ptr c = getCommunicator(); @@ -142,7 +142,7 @@ TEST_F(HelloTest, rpcTransComplexCommunicator) } -TEST_F(HelloTest, rpcTransComplexCommunicatorInCoroutine) +TEST_F(HelloTest, transComplexCommunicatorInCoroutine) { shared_ptr c = getCommunicator(); diff --git a/unit-test/rpc/test_win_server.cpp b/unit-test/rpc/test_win_server.cpp index fb85e6d5..f6a03a3e 100644 --- a/unit-test/rpc/test_win_server.cpp +++ b/unit-test/rpc/test_win_server.cpp @@ -1,9 +1,9 @@  #include "hello_test.h" #include "../server/WinServer.h" -#include "server/FrameworkServer.h" -#include "server/framework/DbHandle.h" -#include "server/framework/ConfigImp.h" +#include "mock/TarsMockUtil.h" +#include "mock/DbHandle.h" +#include "mock/ConfigImp.h" TEST_F(HelloTest, winServerInCoroutine) @@ -370,10 +370,15 @@ TEST_F(HelloTest, winServerConfig) TC_File::removeFile("./test.conf.2.bak", true); TC_File::removeFile("./test.conf.3.bak", true); TC_File::removeFile("./test.conf.4.bak", true); - TC_File::removeFile("./FrameworkServer.tarsdat", true); + TC_File::removeFile("./tarsmock.tarsdat", true); - FrameworkServer fs; - startServer(fs, FRAMEWORK_CONFIG()); + TarsMockUtil tarsMockUtil; + tarsMockUtil.startFramework(); + + ConfigImp::setConfigFile("test.conf", "test-content"); + +// FrameworkServer fs; +// startServer(fs, FRAMEWORK_CONFIG()); { WinServer ws; @@ -385,7 +390,7 @@ TEST_F(HelloTest, winServerConfig) stopServer(ws); } - CDbHandle::addActiveEndPoint("TestApp.FrameworkServer.ConfigObj", 11003, 1); +// CDbHandle::addActiveEndPoint("tars.tarsmock.ConfigObj", "127.0.0.1", 11003, 1); { WinServer ws; @@ -420,6 +425,7 @@ TEST_F(HelloTest, winServerConfig) stopServer(ws); } - stopServer(fs); +// stopServer(fs); + tarsMockUtil.stopFramework(); } diff --git a/unit-test/rpc/test_wup_trans.cpp b/unit-test/rpc/test_wup_trans.cpp index c1f2e25c..b49339d1 100755 --- a/unit-test/rpc/test_wup_trans.cpp +++ b/unit-test/rpc/test_wup_trans.cpp @@ -1,7 +1,7 @@  #include "hello_test.h" -TEST_F(HelloTest, rpcWupTransGlobalCommunicator) +TEST_F(HelloTest, wupTransGlobalCommunicator) { shared_ptr c = getCommunicator(); @@ -10,7 +10,7 @@ TEST_F(HelloTest, rpcWupTransGlobalCommunicator) }, c.get()); } -TEST_F(HelloTest, rpcWupTransGlobalCommunicatorInCoroutine) +TEST_F(HelloTest, wupTransGlobalCommunicatorInCoroutine) { shared_ptr c = getCommunicator(); @@ -20,7 +20,7 @@ TEST_F(HelloTest, rpcWupTransGlobalCommunicatorInCoroutine) } -TEST_F(HelloTest, rpcWupTransServerCommunicator) +TEST_F(HelloTest, wupTransServerCommunicator) { transServerCommunicator([&](Communicator *comm){ checkWupTransSync(comm); diff --git a/unit-test/server/FrameworkServer.cpp b/unit-test/server/FrameworkServer.cpp deleted file mode 100755 index c6ddfcbb..00000000 --- a/unit-test/server/FrameworkServer.cpp +++ /dev/null @@ -1,154 +0,0 @@ -#include "FrameworkServer.h" -#include "framework/ConfigImp.h" -#include "framework/QueryImp.h" -#include "framework/StatImp.h" -#include "framework/LogImp.h" - -#include "HttpImp.h" -#include "HelloImp.h" - -using namespace std; - -vector> _clientStatData; -vector> _serverStatData; - -FrameworkServer::~FrameworkServer() -{ - -} - - -void -FrameworkServer::initialize() -{ - ConfigImp::setConfigFile("test.conf", "test-content"); - - addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".ConfigObj"); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".QueryObj"); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".StatObj"); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".LogObj"); - - string s; - loadLogFormat("","",s); - - //日志路径 - g_globe._log_path = _conf["/tars/log"]; - - //启动写线程 - g_globe._group.start(TC_Common::strto(_conf["/tars/log"])); - - string prefix = TC_Common::lower(_conf.get("/tars/log","true")); - g_globe._bIpPrefix = (prefix == "true") ? true : false; - - //增加对象 - addServant(ServerConfig::Application + "." + ServerConfig::ServerName +".LogObj"); - - TARS_ADD_ADMIN_CMD_NORMAL("reloadLogFormat", FrameworkServer::loadLogFormat); -} - - -bool FrameworkServer::loadLogFormat(const string& command, const string& params, string& result) -{ - TLOGDEBUG("FrameworkServer::loadLogFormat command:" << command << "|params:" << params << endl); - - try - { - TC_Config conf; - - conf.parseFile(ServerConfig::ConfigFile); - - vector vHourlist; - - map mLogType; - - try - { - string sHour = conf["/tars/log/format"]; - - vHourlist = TC_Common::sepstr(sHour,"|;,"); - - sort(vHourlist.begin(),vHourlist.end()); - - unique(vHourlist.begin(),vHourlist.end()); - - result = "loadLogFormat succ:" + sHour; - - TLOGDEBUG("FrameworkServer::loadLogFormat result:" << result << endl); - - DLOG<< "FrameworkServer::loadLogFormat result:" << result << endl; - - //hour=app.server.file|app2.server2.file2 - map mType; - if(conf.getDomainMap("/tars/log/logtype", mType)) - { - map::iterator it = mType.begin(); - while(it != mType.end()) - { - vector vList = TC_Common::sepstr(it->second,"|;,"); - for(size_t i = 0;i < vList.size();i++) - { - //app.server.file = hour - mLogType[vList[i]] = it->first; - - TLOGDEBUG("FrameworkServer::loadLogFormat " << vList[i] << "|" << it->first << endl); - - DLOG<<"FrameworkServer::loadLogFormat " << vList[i] << "|" << it->first << endl; - } - it++; - } - } - - g_globe.update(vHourlist, mLogType); - - } - catch(exception& e) - { - result += e.what(); - TLOGERROR("FrameworkServer::loadLogFormat command:" << command << "|params:" << params << "|result:" << result << endl); - } - - return true; - } - catch(exception &e) - { - result += e.what(); - TLOGERROR("FrameworkServer::loadLogFormat command:" << command << "|params:" << params << "|result:" << result << endl); - } - - return false; -} - -void FrameworkServer::destroyApp() -{ -} - -void FrameworkServer::run() -{ - this->waitForShutdown(); -} -///////////////////////////////////////////////////////////////// - -RpcServer::~RpcServer() -{ - -} - - -void -RpcServer::initialize() -{ - addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".HelloObj"); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".HttpObj"); - addServantProtocol(ServerConfig::Application + "." + ServerConfig::ServerName + ".HttpObj", &TC_NetWorkBuffer::parseHttp); - -} - -///////////////////////////////////////////////////////////////// -void RpcServer::destroyApp() -{ -} - -void RpcServer::run() -{ - this->waitForShutdown(); -} \ No newline at end of file diff --git a/unit-test/server/FrameworkServer.h b/unit-test/server/FrameworkServer.h deleted file mode 100755 index 5d6a95e0..00000000 --- a/unit-test/server/FrameworkServer.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef _FrameworkServer_H_ -#define _FrameworkServer_H_ - -#include -#include "servant/Application.h" - -using namespace tars; - -extern vector> _clientStatData; -extern vector> _serverStatData; - -class FrameworkServer : public Application, public TC_Thread -{ -public: - /** - * 析构函数 - **/ - virtual ~FrameworkServer(); - - /** - * 服务初始化 - **/ - virtual void initialize(); - - /** - * 服务销毁 - **/ - virtual void destroyApp(); - -protected: - virtual void run(); - - bool loadLogFormat(const string& command, const string& params, string& result); - -}; - -class RpcServer : public Application, public TC_Thread -{ -public: - /** - * 析构函数 - **/ - virtual ~RpcServer(); - - /** - * 服务初始化 - **/ - virtual void initialize(); - - /** - * 服务销毁 - **/ - virtual void destroyApp(); - -protected: - virtual void run(); - -}; - - -//////////////////////////////////////////// -#endif diff --git a/unit-test/server/HelloServer.cpp b/unit-test/server/HelloServer.cpp index 0618904f..c565d071 100755 --- a/unit-test/server/HelloServer.cpp +++ b/unit-test/server/HelloServer.cpp @@ -55,42 +55,42 @@ HelloServer::initialize() { // this->_epollServer->setUdpRecvBufferSize(10 * 1024 * 1024); // this->_epollServer->setUdpSendBufferSize(10 * 1024 * 1024); - g_HelloServerObj = ServerConfig::Application + "." + ServerConfig::ServerName +".HelloObj@" + getEpollServer()->getBindAdapter("HelloAdapter")->getEndpoint().toString(); - g_TransDstServerObj = ServerConfig::Application + "." + ServerConfig::ServerName +".TransDstObj@" + getEpollServer()->getBindAdapter("TransDstAdapter")->getEndpoint().toString(); + g_HelloServerObj =_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName +".HelloObj@" + getEpollServer()->getBindAdapter("HelloAdapter")->getEndpoint().toString(); + g_TransDstServerObj =_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName +".TransDstObj@" + getEpollServer()->getBindAdapter("TransDstAdapter")->getEndpoint().toString(); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName +".HelloObj"); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName +".TransObj"); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName +".HelloTimeoutObj"); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName +".HelloNoTimeoutObj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName +".HelloObj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName +".TransObj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName +".HelloTimeoutObj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName +".HelloNoTimeoutObj"); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName +".Ipv6Obj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName +".Ipv6Obj"); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName +".HttpObj"); - addServantProtocol(ServerConfig::Application + "." + ServerConfig::ServerName + ".HttpObj", &TC_NetWorkBuffer::parseHttp); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName +".HttpsObj"); - addServantProtocol(ServerConfig::Application + "." + ServerConfig::ServerName + ".HttpsObj", &TC_NetWorkBuffer::parseHttp); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName +".HttpObj"); + addServantProtocol(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".HttpObj", &TC_NetWorkBuffer::parseHttp); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName +".HttpsObj"); + addServantProtocol(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".HttpsObj", &TC_NetWorkBuffer::parseHttp); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName +".TransDstObj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName +".TransDstObj"); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName +".TransWupObj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName +".TransWupObj"); //设置服务的协议解析器, 对服务器端而言, 解析器的目的就是识别包长度 //parseStream,表示第0个字节开始,类型是uint32_t, 字节序, 这个字段表示包的长度 TC_NetWorkBuffer::protocol_functor func = AppProtocol::parseStream<0, uint32_t, true>; - addServantProtocol(ServerConfig::Application + "." + ServerConfig::ServerName +".TransWupObj", func); + addServantProtocol(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName +".TransWupObj", func); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".CustomObj"); - addServantProtocol(ServerConfig::Application + "." + ServerConfig::ServerName + ".CustomObj", parse); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".CustomObj"); + addServantProtocol(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".CustomObj", parse); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".SSLObj"); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".SSL1Obj"); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".SSL2Obj"); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".SSL3Obj"); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".AuthObj"); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".UdpObj"); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".UdpIpv6Obj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".SSLObj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".SSL1Obj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".SSL2Obj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".SSL3Obj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".AuthObj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".UdpObj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".UdpIpv6Obj"); - addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".PushObj"); - addServantProtocol(ServerConfig::Application + "." + ServerConfig::ServerName + ".PushObj", parse); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".PushObj"); + addServantProtocol(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".PushObj", parse); pushThread = new PushInfoThread(); pushThread->start(); diff --git a/unit-test/server/RpcServer.cpp b/unit-test/server/RpcServer.cpp new file mode 100644 index 00000000..105ee8d7 --- /dev/null +++ b/unit-test/server/RpcServer.cpp @@ -0,0 +1,32 @@ +// +// Created by jarod on 2024/3/14. +// + +#include "RpcServer.h" +#include "HelloImp.h" +#include "HttpImp.h" + +RpcServer::~RpcServer() +{ + +} + + +void +RpcServer::initialize() +{ + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".HelloObj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".HttpObj"); + addServantProtocol(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".HttpObj", &TC_NetWorkBuffer::parseHttp); + +} + +///////////////////////////////////////////////////////////////// +void RpcServer::destroyApp() +{ +} + +void RpcServer::run() +{ + this->waitForShutdown(); +} \ No newline at end of file diff --git a/unit-test/server/RpcServer.h b/unit-test/server/RpcServer.h new file mode 100644 index 00000000..debf5799 --- /dev/null +++ b/unit-test/server/RpcServer.h @@ -0,0 +1,32 @@ +// +// Created by jarod on 2024/3/14. +// + +#pragma once +#include +#include "servant/Application.h" + +using namespace tars; + +class RpcServer : public Application, public TC_Thread +{ +public: + /** + * 析构函数 + **/ + virtual ~RpcServer(); + + /** + * 服务初始化 + **/ + virtual void initialize(); + + /** + * 服务销毁 + **/ + virtual void destroyApp(); + +protected: + virtual void run(); + +}; diff --git a/unit-test/server/WinServer.cpp b/unit-test/server/WinServer.cpp index 103b4445..b99090fe 100644 --- a/unit-test/server/WinServer.cpp +++ b/unit-test/server/WinServer.cpp @@ -13,7 +13,7 @@ WinServer::~WinServer() void WinServer::initialize() { - addServant(ServerConfig::Application + "." + ServerConfig::ServerName + ".WinObj"); + addServant(_serverBaseInfo.Application + "." + _serverBaseInfo.ServerName + ".WinObj"); addConfig("test.conf"); TARS_ADD_ADMIN_CMD_NORMAL("AdminCmdNormalTest", WinServer::cmdAdd); diff --git a/unit-test/server/client.conf b/unit-test/server/client.conf index df0fb2ce..8b8045fb 100755 --- a/unit-test/server/client.conf +++ b/unit-test/server/client.conf @@ -3,13 +3,13 @@ #tarsregistry locator - locator = TestApp.FrameworkServer.QueryObj@tcp -h 127.0.0.1 -p 11004 + locator = tars.tarsmock.QueryObj@tcp -h 127.0.0.1 -p 17890 sync-invoke-timeout = 50000 async-invoke-timeout = 50000 #refresh endpoint interval refresh-endpoint-interval = 3000 #stat obj - stat = TestApp.FrameworkServer.StatObj@tcp -h 127.0.0.1 -p 12004 + stat = tars.tarsmock.StatObj@tcp -h 127.0.0.1 -p 12004 #max send queue length limit sendqueuelimit = 1000000 #async queue length limit diff --git a/unit-test/server/framework.conf b/unit-test/server/framework.conf deleted file mode 100755 index 6aa2e1d8..00000000 --- a/unit-test/server/framework.conf +++ /dev/null @@ -1,129 +0,0 @@ - - - #proxy需要的配置 - - #地址 - locator = TestApp.FrameworkServer.QueryObj@tcp -h 127.0.0.1 -p 11004 - #最大超时时间(毫秒) - sync-invoke-timeout = 5000 - async-invoke-timeout = 60000 - #刷新端口时间间隔(毫秒) - refresh-endpoint-interval = 5000 - #模块间调用[可选] - stat = TestApp.FrameworkServer.StatObj - #发送队列长度 - sendqueuelimit = 1000000 - #异步回调队列个数限制 - asyncqueuecap = 1000000 - #网络异步回调线程个数 - asyncthread = 3 - #网络线程个数 - netthread = 2 - #合并回调线程和网络线程(以网络线程个数为准) - mergenetasync = 0 - #模块名称 - modulename = TestApp.FrameworkServer - - - - #定义所有绑定的IP - - start_output = ERROR - closecout = 0 - #应用名称 - app = TestApp - #服务名称 - server = FrameworkServer - #服务的数据目录,可执行文件,配置文件等 - basepath = . - datapath = . - #日志路径 - logpath = . - #网络线程个数 - netthread = 1 - #合并网络和业务线程(以网络线程个数为准) - mergenetimp = 0 - opencoroutine = 0 - loglevel=TARS - - #本地管理套接字[可选] - local = tcp -h 127.0.0.1 -p 15791 -t 10000 - - #本地node的ip:port:timeout[可选] -# node = ServerObj@tcp -h 127.0.0.1 -p 2345 -t 10000 - #配置中心的地址[可选] - config = TestApp.FrameworkServer.ConfigObj - #配置中心的地址[可选] -# notify = tars.tarsconfig.NotifyObj - #远程LogServer[可选] - log = TestApp.FrameworkServer.LogObj - - - #ip:port:timeout - endpoint = tcp -h 127.0.0.1 -p 11003 -t 60000 - #allow ip - allow = - #max connection num - maxconns = 4096 - #imp thread num - threads = 5 - #servant - servant = TestApp.FrameworkServer.ConfigObj - #queue capacity - queuecap = 1000000 - - - - #ip:port:timeout - endpoint = tcp -h 127.0.0.1 -p 11005 -t 60000 - #allow ip - allow = - #max connection num - maxconns = 4096 - #imp thread num - threads = 5 - #servant - servant = TestApp.FrameworkServer.LogObj - #queue capacity - queuecap = 1000000 - - - - #ip:port:timeout - endpoint = tcp -h 127.0.0.1 -p 11004 -t 60000 - #allow ip - allow = - #max connection num - maxconns = 4096 - #imp thread num - threads = 5 - #servant - servant = TestApp.FrameworkServer.QueryObj - #queue capacity - queuecap = 1000000 - - - - #ip:port:timeout - endpoint = tcp -h 127.0.0.1 -p 12004 -t 60000 - #allow ip - allow = - #max connection num - maxconns = 4096 - #imp thread num - threads = 5 - #servant - servant = TestApp.FrameworkServer.StatObj - #queue capacity - queuecap = 1000000 - - - - - - logpath = . - logthread = 1 - ipfix = true - - - diff --git a/unit-test/server/framework/DbHandle.cpp b/unit-test/server/framework/DbHandle.cpp deleted file mode 100755 index 6ee1e54f..00000000 --- a/unit-test/server/framework/DbHandle.cpp +++ /dev/null @@ -1,688 +0,0 @@ - -#include -#include -#include "DbHandle.h" - -TC_ReadersWriterData CDbHandle::_objectsCache; -TC_ReadersWriterData CDbHandle::_setDivisionCache; -TC_ReadersWriterData > CDbHandle::_mapGroupPriority; - -//key-ip, value-组编号 -TC_ReadersWriterData > CDbHandle::_groupIdMap; -//key-group_name, value-组编号 -TC_ReadersWriterData > CDbHandle::_groupNameMap; - -int CDbHandle::init(TC_Config *pconf) -{ - return 0; -} - -vector CDbHandle::findObjectById(const string& id) -{ - ObjectsCache::iterator it; - ObjectsCache& usingCache = _objectsCache.getReaderData(); - - if ((it = usingCache.find(id)) != usingCache.end()) - { - return it->second.vActiveEndpoints; - } - else - { - vector activeEp; - return activeEp; - } -} - - -int CDbHandle::findObjectById4All(const string& id, vector& activeEp, vector& inactiveEp) -{ - - TLOGDEBUG(__FUNCTION__ << " id: " << id << endl); - - ObjectsCache::iterator it; - ObjectsCache& usingCache = _objectsCache.getReaderData(); - - if ((it = usingCache.find(id)) != usingCache.end()) - { - activeEp = it->second.vActiveEndpoints; - inactiveEp = it->second.vInactiveEndpoints; - } - else - { - activeEp.clear(); - inactiveEp.clear(); - } - - return 0; -} - -vector CDbHandle::getEpsByGroupId(const vector& vecEps, const GroupUseSelect GroupSelect, int iGroupId, ostringstream& os) -{ - os << "|"; - vector vResult; - - for (unsigned i = 0; i < vecEps.size(); i++) - { - os << vecEps[i].host << ":" << vecEps[i].port << "(" << vecEps[i].groupworkid << ");"; - if (GroupSelect == ENUM_USE_WORK_GROUPID && vecEps[i].groupworkid == iGroupId) - { - vResult.push_back(vecEps[i]); - } - if (GroupSelect == ENUM_USE_REAL_GROUPID && vecEps[i].grouprealid == iGroupId) - { - vResult.push_back(vecEps[i]); - } - } - - return vResult; -} - -vector CDbHandle::getEpsByGroupId(const vector& vecEps, const GroupUseSelect GroupSelect, const set& setGroupID, ostringstream& os) -{ - os << "|"; - std::vector vecResult; - - for (std::vector::size_type i = 0; i < vecEps.size(); i++) - { - os << vecEps[i].host << ":" << vecEps[i].port << "(" << vecEps[i].groupworkid << ")"; - if (GroupSelect == ENUM_USE_WORK_GROUPID && setGroupID.count(vecEps[i].groupworkid) == 1) - { - vecResult.push_back(vecEps[i]); - } - if (GroupSelect == ENUM_USE_REAL_GROUPID && setGroupID.count(vecEps[i].grouprealid) == 1) - { - vecResult.push_back(vecEps[i]); - } - } - - return vecResult; -} - -int CDbHandle::findObjectByIdInSameGroup(const string& id, const string& ip, vector& activeEp, vector& inactiveEp, ostringstream& os) -{ - activeEp.clear(); - inactiveEp.clear(); - - int iClientGroupId = getGroupId(ip); - - os << "|(" << iClientGroupId << ")"; - - if (iClientGroupId == -1) - { - return findObjectById4All(id, activeEp, inactiveEp); - } - - ObjectsCache::iterator it; - ObjectsCache& usingCache = _objectsCache.getReaderData(); - - if ((it = usingCache.find(id)) != usingCache.end()) - { - activeEp = getEpsByGroupId(it->second.vActiveEndpoints, ENUM_USE_WORK_GROUPID, iClientGroupId, os); - inactiveEp = getEpsByGroupId(it->second.vInactiveEndpoints, ENUM_USE_WORK_GROUPID, iClientGroupId, os); - - if (activeEp.size() == 0) //没有同组的endpoit,匹配未启用分组的服务 - { - activeEp = getEpsByGroupId(it->second.vActiveEndpoints, ENUM_USE_WORK_GROUPID, -1, os); - inactiveEp = getEpsByGroupId(it->second.vInactiveEndpoints, ENUM_USE_WORK_GROUPID, -1, os); - } - if (activeEp.size() == 0) //没有同组的endpoit - { - activeEp = it->second.vActiveEndpoints; - inactiveEp = it->second.vInactiveEndpoints; - } - } - - return 0; -} - -int CDbHandle::findObjectByIdInGroupPriority(const std::string& sID, const std::string& sIP, std::vector& vecActive, std::vector& vecInactive, std::ostringstream& os) -{ - vecActive.clear(); - vecInactive.clear(); - - int iClientGroupID = getGroupId(sIP); - os << "|(" << iClientGroupID << ")"; - if (iClientGroupID == -1) - { - return findObjectById4All(sID, vecActive, vecInactive); - } - - ObjectsCache& usingCache = _objectsCache.getReaderData(); - ObjectsCache::iterator itObject = usingCache.find(sID); - if (itObject == usingCache.end()) return 0; - - //首先在同组中查找 - { - vecActive = getEpsByGroupId(itObject->second.vActiveEndpoints, ENUM_USE_WORK_GROUPID, iClientGroupID, os); - vecInactive = getEpsByGroupId(itObject->second.vInactiveEndpoints, ENUM_USE_WORK_GROUPID, iClientGroupID, os); - os << "|(In Same Group: " << iClientGroupID << " Active=" << vecActive.size() << " Inactive=" << vecInactive.size() << ")"; - } - - //启用分组,但同组中没有找到,在优先级序列中查找 - std::map & mapPriority = _mapGroupPriority.getReaderData(); - for (std::map::iterator it = mapPriority.begin(); it != mapPriority.end() && vecActive.empty(); it++) - { - if (it->second.setGroupID.count(iClientGroupID) == 0) - { - os << "|(Not In Priority " << it->second.sGroupID << ")"; - continue; - } - vecActive = getEpsByGroupId(itObject->second.vActiveEndpoints, ENUM_USE_WORK_GROUPID, it->second.setGroupID, os); - vecInactive = getEpsByGroupId(itObject->second.vInactiveEndpoints, ENUM_USE_WORK_GROUPID, it->second.setGroupID, os); - os << "|(In Priority: " << it->second.sGroupID << " Active=" << vecActive.size() << " Inactive=" << vecInactive.size() << ")"; - } - - //没有同组的endpoit,匹配未启用分组的服务 - if (vecActive.empty()) - { - vecActive = getEpsByGroupId(itObject->second.vActiveEndpoints, ENUM_USE_WORK_GROUPID, -1, os); - vecInactive = getEpsByGroupId(itObject->second.vInactiveEndpoints, ENUM_USE_WORK_GROUPID, -1, os); - os << "|(In No Grouop: Active=" << vecActive.size() << " Inactive=" << vecInactive.size() << ")"; - } - - //在未分组的情况下也没有找到,返回全部地址(此时基本上所有的服务都已挂掉) - if (vecActive.empty()) - { - vecActive = itObject->second.vActiveEndpoints; - vecInactive = itObject->second.vInactiveEndpoints; - os << "|(In All: Active=" << vecActive.size() << " Inactive=" << vecInactive.size() << ")"; - } - - return 0; -} - -int CDbHandle::findObjectByIdInSameStation(const std::string& sID, const std::string& sStation, std::vector& vecActive, std::vector& vecInactive, std::ostringstream& os) -{ - vecActive.clear(); - vecInactive.clear(); - - //获得station所有组 - std::map & mapPriority = _mapGroupPriority.getReaderData(); - std::map::iterator itGroup = mapPriority.end(); - for (itGroup = mapPriority.begin(); itGroup != mapPriority.end(); itGroup++) - { - if (itGroup->second.sStation != sStation) continue; - - break; - } - - if (itGroup == mapPriority.end()) - { - os << "|not found station:" << sStation; - return -1; - } - - ObjectsCache& usingCache = _objectsCache.getReaderData(); - ObjectsCache::iterator itObject = usingCache.find(sID); - if (itObject == usingCache.end()) return 0; - - //查找对应所有组下的IP地址 - vecActive = getEpsByGroupId(itObject->second.vActiveEndpoints, ENUM_USE_REAL_GROUPID, itGroup->second.setGroupID, os); - vecInactive = getEpsByGroupId(itObject->second.vInactiveEndpoints, ENUM_USE_REAL_GROUPID, itGroup->second.setGroupID, os); - - return 0; -} - -int CDbHandle::findObjectByIdInSameSet(const string& sID, const vector& vtSetInfo, std::vector& vecActive, std::vector& vecInactive, std::ostringstream& os) -{ - string sSetName = vtSetInfo[0]; - string sSetArea = vtSetInfo[0] + "." + vtSetInfo[1]; - string sSetId = vtSetInfo[0] + "." + vtSetInfo[1] + "." + vtSetInfo[2]; - - SetDivisionCache& usingSetDivisionCache = _setDivisionCache.getReaderData(); - SetDivisionCache::iterator it = usingSetDivisionCache.find(sID); - if (it == usingSetDivisionCache.end()) - { - //此情况下没启动set - TLOGINFO("CDbHandle::findObjectByIdInSameSet:" << __LINE__ << "|" << sID << " haven't start set|" << sSetId << endl); - return -1; - } - - map >::iterator setNameIt = it->second.find(sSetName); - if (setNameIt == (it->second).end()) - { - //此情况下没启动set - TLOGINFO("CDbHandle::findObjectByIdInSameSet:" << __LINE__ << "|" << sID << " haven't start set|" << sSetId << endl); - return -1; - } - - if (vtSetInfo[2] == "*") - { - //检索通配组和set组中的所有服务 - vector vServerInfo = setNameIt->second; - for (size_t i = 0; i < vServerInfo.size(); i++) - { - if (vServerInfo[i].sSetArea == sSetArea) - { - if (vServerInfo[i].bActive) - { - vecActive.push_back(vServerInfo[i].epf); - } - else - { - vecInactive.push_back(vServerInfo[i].epf); - } - } - } - - return (vecActive.empty() && vecInactive.empty()) ? -2 : 0; - } - else - { - - // 1.从指定set组中查找 - int iRet = findObjectByIdInSameSet(sSetId, setNameIt->second, vecActive, vecInactive, os); - if (iRet != 0 && vtSetInfo[2] != "*") - { - // 2. 步骤1中没找到,在通配组里找 - string sWildSetId = vtSetInfo[0] + "." + vtSetInfo[1] + ".*"; - iRet = findObjectByIdInSameSet(sWildSetId, setNameIt->second, vecActive, vecInactive, os); - } - - return iRet; - } -} - -int CDbHandle::findObjectByIdInSameSet(const string& sSetId, const vector& vSetServerInfo, std::vector& vecActive, std::vector& vecInactive, std::ostringstream& os) -{ - for (size_t i = 0; i < vSetServerInfo.size(); ++i) - { - if (vSetServerInfo[i].sSetId == sSetId) - { - if (vSetServerInfo[i].bActive) - { - vecActive.push_back(vSetServerInfo[i].epf); - } - else - { - vecInactive.push_back(vSetServerInfo[i].epf); - } - } - } - - int iRet = (vecActive.empty() && vecInactive.empty()) ? -2 : 0; - return iRet; -} - -void CDbHandle::updateObjectsCache(const ObjectsCache& objCache, bool updateAll) -{ - //全量更新 - if (updateAll) - { - _objectsCache.getWriterData() = objCache; - _objectsCache.swap(); - } - else - { - //用查询数据覆盖一下 - _objectsCache.getWriterData() = _objectsCache.getReaderData(); - ObjectsCache& tmpObjCache = _objectsCache.getWriterData(); - - ObjectsCache::const_iterator it = objCache.begin(); - for (; it != objCache.end(); it++) - { - //增量的时候加载的是服务的所有节点,因此这里直接替换 - tmpObjCache[it->first] = it->second; - } - _objectsCache.swap(); - } -} - -void CDbHandle::updateInactiveObjectsCache(const ObjectsCache& objCache, bool updateAll) -{ - //全量更新 - if (updateAll) - { - _objectsCache.getWriterData() = objCache; - _objectsCache.swap(); - } - else - { - //用查询数据覆盖一下 - _objectsCache.getWriterData() = _objectsCache.getReaderData(); - ObjectsCache& tmpObjCache = _objectsCache.getWriterData(); - - ObjectsCache::const_iterator it = objCache.begin(); - for (; it != objCache.end(); it++) - { - //增量的时候加载的是服务的所有节点,因此这里直接替换 - tmpObjCache[it->first].vInactiveEndpoints.push_back((it->second).vInactiveEndpoints[0]); - } - _objectsCache.swap(); - } -} - - -void CDbHandle::updateActiveObjectsCache(const ObjectsCache& objCache, bool updateAll) -{ - //全量更新 - if (updateAll) - { - _objectsCache.getWriterData() = objCache; - _objectsCache.swap(); - } - else - { - //用查询数据覆盖一下 - _objectsCache.getWriterData() = _objectsCache.getReaderData(); - ObjectsCache& tmpObjCache = _objectsCache.getWriterData(); - - ObjectsCache::const_iterator it = objCache.begin(); - for (; it != objCache.end(); it++) - { - //增量的时候加载的是服务的所有节点,因此这里直接替换 - tmpObjCache[it->first].vActiveEndpoints.push_back((it->second).vActiveEndpoints[0]); - } - _objectsCache.swap(); - } -} - - -void CDbHandle::addActiveEndPoint(const string& objName, const Int32 port, const Int32 istcp) -{ -#define LOCAL_HOST "127.0.0.1" - ObjectsCache objectsCache; - EndpointF endPoint; - endPoint.host = LOCAL_HOST; - endPoint.port = port; - endPoint.timeout = 30000; - endPoint.istcp = istcp; - //endPoint.setId = setName + "." + setArea + "." + setGroup; - objectsCache[objName].vActiveEndpoints.push_back(endPoint); - updateActiveObjectsCache(objectsCache, false); -} - -void CDbHandle::addEndPointbySet(const string& objName, const Int32 port, const Int32 istcp, const string& setName, const string& setArea, const string& setGroup) -{ -#define LOCAL_HOST "127.0.0.1" - ObjectsCache objectsCache; - EndpointF endPoint; - endPoint.host = LOCAL_HOST; - endPoint.port = port; - endPoint.timeout = 30000; - endPoint.istcp = istcp; - endPoint.setId = setName + "." + setArea + "." + setGroup; - objectsCache[objName].vActiveEndpoints.push_back(endPoint); - updateActiveObjectsCache(objectsCache, false); - - if (setName.size()) - { - InsertSetRecord(objName, setName, setArea, setGroup, endPoint); - } -} - -void CDbHandle::addActiveWeight1EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName) -{ -#define LOCAL_HOST "127.0.0.1" - ObjectsCache objectsCache; - EndpointF endPoint; - endPoint.host = LOCAL_HOST; - endPoint.port = port; - endPoint.timeout = 30000; - endPoint.istcp = istcp; - endPoint.setId = setName; - endPoint.weight = 2; - endPoint.weightType = 1; - objectsCache[objName].vActiveEndpoints.push_back(endPoint); - updateActiveObjectsCache(objectsCache, false); -} - -void CDbHandle::addInActiveWeight1EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName) -{ -#define LOCAL_HOST "127.0.0.1" - ObjectsCache objectsCache; - EndpointF endPoint; - endPoint.host = LOCAL_HOST; - endPoint.port = port; - endPoint.timeout = 30000; - endPoint.istcp = istcp; - endPoint.setId = setName; - endPoint.weight = 2; - endPoint.weightType = 1; - objectsCache[objName].vInactiveEndpoints.push_back(endPoint); - updateInactiveObjectsCache(objectsCache, false); -} - - -void CDbHandle::addActiveWeight2EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName) -{ -#define LOCAL_HOST "127.0.0.1" - ObjectsCache objectsCache; - EndpointF endPoint; - endPoint.host = LOCAL_HOST; - endPoint.port = port; - endPoint.timeout = 30000; - endPoint.istcp = istcp; - endPoint.setId = setName; - endPoint.weight = 2; - endPoint.weightType = 2; - objectsCache[objName].vActiveEndpoints.push_back(endPoint); - updateActiveObjectsCache(objectsCache, false); -} - - -void CDbHandle::addInactiveEndPoint(const string& objName, const Int32 port, const Int32 istcp) -{ -#define LOCAL_HOST "127.0.0.1" - ObjectsCache objectsCache; - EndpointF endPoint; - endPoint.host = LOCAL_HOST; - endPoint.port = port; - endPoint.timeout = 30000; - endPoint.istcp = istcp; - //endPoint.setId = setName; - objectsCache[objName].vInactiveEndpoints.push_back(endPoint); - updateInactiveObjectsCache(objectsCache, false); - -} - -void CDbHandle::cleanEndPoint() -{ - ObjectsCache objectsCache; - updateObjectsCache(objectsCache, true); -} - -int CDbHandle::getGroupId(const string& ip) -{ - - map& groupIdMap = _groupIdMap.getReaderData(); - map::iterator it = groupIdMap.find(ip); - if (it != groupIdMap.end()) - { - return it->second; - } - - uint32_t uip = stringIpToInt(ip); - string ipStar = Ip2StarStr(uip); - it = groupIdMap.find(ipStar); - if (it != groupIdMap.end()) - { - return it->second; - } - - return -1; -} - -uint32_t CDbHandle::stringIpToInt(const std::string& sip) -{ - string ip1, ip2, ip3, ip4; - uint32_t dip, p1, p2, p3; - dip = 0; - p1 = sip.find('.'); - p2 = sip.find('.', p1 + 1); - p3 = sip.find('.', p2 + 1); - ip1 = sip.substr(0, p1); - ip2 = sip.substr(p1 + 1, p2 - p1 - 1); - ip3 = sip.substr(p2 + 1, p3 - p2 - 1); - ip4 = sip.substr(p3 + 1, sip.size() - p3 - 1); - (((unsigned char *)&dip)[0]) = TC_Common::strto(ip1); - (((unsigned char *)&dip)[1]) = TC_Common::strto(ip2); - (((unsigned char *)&dip)[2]) = TC_Common::strto(ip3); - (((unsigned char *)&dip)[3]) = TC_Common::strto(ip4); - return htonl(dip); -} - -string CDbHandle::Ip2Str(uint32_t ip) -{ - char str[50]; - unsigned char *p = (unsigned char *)&ip; - sprintf(str, "%u.%u.%u.%u", p[3], p[2], p[1], p[0]); - return string(str); -} - -string CDbHandle::Ip2StarStr(uint32_t ip) -{ - char str[50]; - unsigned char *p = (unsigned char *)&ip; - sprintf(str, "%u.%u.%u.*", p[3], p[2], p[1]); - return string(str); -} - - -void CDbHandle::InsertSetRecord(const string& objName, const string& setName, const string& setArea, const string& setGroup, EndpointF epf) -{ - SetDivisionCache setDivisionCache; - - string setId = setName + "." + setArea + "." + setGroup; - SetServerInfo setServerInfo; - setServerInfo.bActive = true; - setServerInfo.epf = epf; - - setServerInfo.sSetId = setId; - setServerInfo.sSetArea = setArea; - - setDivisionCache[objName][setName].push_back(setServerInfo); - - setServerInfo.bActive = false; - setServerInfo.epf.port = 10204; - - setDivisionCache[objName][setName].push_back(setServerInfo); - - updateDivisionCache(setDivisionCache, true); -} - - -void CDbHandle::InsertSetRecord4Inactive(const string& objName, const string& setName, const string& setArea, const string& setGroup, EndpointF epf) -{ - SetDivisionCache setDivisionCache; - - string setId = setName + "." + setArea + "." + setGroup; - SetServerInfo setServerInfo; - setServerInfo.bActive = false; - setServerInfo.epf = epf; - - setServerInfo.sSetId = setId; - setServerInfo.sSetArea = setArea; - - setDivisionCache[objName][setName].push_back(setServerInfo); - - updateDivisionCache(setDivisionCache, false); -} - - -void CDbHandle::updateDivisionCache(SetDivisionCache& setDivisionCache,bool updateAll) -{ - //ȫ������ - if(updateAll) - { - if (setDivisionCache.size() == 0) - { - return; - } - SetDivisionCache::iterator it = setDivisionCache.begin(); - for(;it != setDivisionCache.end();it++) - { - if(it->second.size() > 0) - { - map >::iterator it_inner = it->second.begin(); - for(;it_inner != it->second.end();it_inner++) - { - //updateCpuLoadInfo(it_inner->second); - } - } - } - _setDivisionCache.getWriterData() = setDivisionCache; - _setDivisionCache.swap(); - } - else - { - _setDivisionCache.getWriterData() = _setDivisionCache.getReaderData(); - SetDivisionCache& tmpsetCache = _setDivisionCache.getWriterData(); - SetDivisionCache::const_iterator it = setDivisionCache.begin(); - for(;it != setDivisionCache.end();it++) - { - //��set��Ϣ�Ÿ��� - if(it->second.size() > 0) - { - tmpsetCache[it->first] = it->second; - } - else if(tmpsetCache.count(it->first)) - { - tmpsetCache.erase(it->first); - } - - } - - _setDivisionCache.swap(); - } -} -#if 0 - -void CDbHandle::updateCpuLoadInfo(vector &vEndpointF) -{ - CpuLoadCache &cpuLoadCacheMap = _cpuLoadCacheMap.getReaderData(); - for(size_t i = 0; i < vEndpointF.size(); ++i) - { - map::const_iterator const_it_cpu = cpuLoadCacheMap.find(vEndpointF[i].host); - if(const_it_cpu != cpuLoadCacheMap.end()) - { - struct tm tb; - int ret = TC_Common::str2tm(const_it_cpu->second.sHeartTime, "%Y-%m-%d %H:%M:%S", tb); - if(ret == 0) - { - vEndpointF[i].cpuload = const_it_cpu->second.iCpuLoad; - vEndpointF[i].sampletime = mktime(&tb); - } - else - { - vEndpointF[i].cpuload = -1; - vEndpointF[i].sampletime = 0; - } - } - else - { - vEndpointF[i].cpuload = -1; - vEndpointF[i].sampletime = 0; - } - } -} - -void CDbHandle::updateCpuLoadInfo(vector &vSetServerInfo) -{ - CpuLoadCache &cpuLoadCacheMap = _cpuLoadCacheMap.getReaderData(); - for(size_t i = 0; i < vSetServerInfo.size(); ++i) - { - map::const_iterator const_it_cpu = cpuLoadCacheMap.find(vSetServerInfo[i].epf.host); - if(const_it_cpu != cpuLoadCacheMap.end()) - { - struct tm tb; - int ret = TC_Common::str2tm(const_it_cpu->second.sHeartTime, "%Y-%m-%d %H:%M:%S", tb); - if(ret == 0) - { - vSetServerInfo[i].epf.cpuload = const_it_cpu->second.iCpuLoad; - vSetServerInfo[i].epf.sampletime = mktime(&tb); - } - else - { - vSetServerInfo[i].epf.cpuload = -1; - vSetServerInfo[i].epf.sampletime = 0; - } - } - else - { - vSetServerInfo[i].epf.cpuload = -1; - vSetServerInfo[i].epf.sampletime = 0; - } - } -} -#endif diff --git a/unit-test/server/framework/DbHandle.h b/unit-test/server/framework/DbHandle.h deleted file mode 100755 index 01761695..00000000 --- a/unit-test/server/framework/DbHandle.h +++ /dev/null @@ -1,214 +0,0 @@ - - -#ifndef __DB_HANDLE_H__ -#define __DB_HANDLE_H__ - -#include "util/tc_common.h" -#include "util/tc_config.h" -#include "util/tc_monitor.h" -#include "util/tc_file.h" -#include "jmem/jmem_hashmap.h" -#include "util/tc_readers_writer_data.h" -#include -#include "servant/RemoteLogger.h" -#include "servant/EndpointF.h" -#include "RegistryDescriptor.h" - -using namespace tars; -////////////////////////////////////////////////////// -// -typedef map ObjectsCache; -////////////////////////////////////////////////////// -/** - * 数据库操作类 - */ -class CDbHandle -{ -private: - struct GroupPriorityEntry - { - std::string sGroupID; - std::string sStation; - std::set setGroupID; - }; - - enum GroupUseSelect - { - ENUM_USE_WORK_GROUPID, - ENUM_USE_REAL_GROUPID - }; - //set中服务的信息 - struct SetServerInfo - { - string sSetId; - string sSetArea; - bool bActive; - EndpointF epf; - }; - // - typedef map > > SetDivisionCache; - -public: - /** - * 构造函数 - */ - CDbHandle() - { - } - - /** - * 初始化 - * @param pconf 配置文件 - * @return 0-成功 others-失败 - */ - int init(TC_Config *pconf); - - /** 根据id获取对象 - * - * @param id 对象名称 - * - * @return 返回所有该对象的活动endpoint列表 - */ - vector findObjectById(const string & id); - - /** 根据id获取对象 - * - * @param id 对象名称 - * @out param activeEp 存活的列表 - * @out param inactiveEp 非存活的列表 - * - * @return 0-成功 others-失败 - */ - int findObjectById4All(const string & id, vector& activeEp, vector& inactiveEp); - - /** 根据id获取同组对象 - * - * @param id 对象名称 - * @param ip - * @out param activeEp 存活的列表 - * @out param inactiveEp 非存活的列表 - * @out param os 打印日志使用 - * - * @return 0-成功 others-失败 - */ - int findObjectByIdInSameGroup(const string & id, const string & ip, vector& activeEp, vector& inactiveEp, ostringstream &os); - - /** 根据id获取优先级序列中的对象 - * - * @param id 对象名称 - * @param ip - * @out param vecActive 存活的列表 - * @out param vecInactive 非存活的列表 - * @out param os 打印日志使用 - * - * @return 0-成功 others-失败 - */ - int findObjectByIdInGroupPriority(const std::string &sID, const std::string &sIP, std::vector & vecActive, std::vector & vecInactive, std::ostringstream & os); - - /** 根据id和归属地获取全部对象 - * - * @param id 对象名称 - * @param sStation 归属地 - * @out param vecActive 存活的列表 - * @out param vecInactive 非存活的列表 - * @out param os 打印日志使用 - * - * @return 0-成功 others-失败 - */ - int findObjectByIdInSameStation(const std::string &sID, const std::string & sStation, std::vector & vecActive, std::vector & vecInactive, std::ostringstream & os); - - /** 根据id和set信息获取全部对象 - * - * @param sID 对象名称 - * @param vtSetInfo set信息 - * @out param vecActive 存活的列表 - * @out param vecInactive 非存活的列表 - * @out param os 打印日志使用 - * - * @return 0-成功 others-失败 - */ - int findObjectByIdInSameSet(const string &sID, const vector &vtSetInfo, std::vector & vecActive, std::vector & vecInactive, std::ostringstream & os); - - /** 根据setId获取全部对象 - * - * @param sSetId set名称 - * @param vSetServerInfo SetName下部署的服务信息 - * @out param vecActive 存活的列表 - * @out param vecInactive 非存活的列表 - * @out param os 打印日志使用 - * - * @return 0-成功 others-失败 - */ - int findObjectByIdInSameSet(const string &sSetId, const vector& vSetServerInfo, std::vector & vecActive, std::vector & vecInactive, std::ostringstream & os); - /** - * 根据ip获取组id - * @return int <0 失败 其它正常 - */ - int getGroupId(const string& ip); - /** - * ip转换 - */ - static uint32_t stringIpToInt(const std::string& sip); - - /** - * ip转换 - */ - static string Ip2Str(uint32_t ip); - - /** - * ip转换 - */ - static string Ip2StarStr(uint32_t ip); - - static void updateObjectsCache(const ObjectsCache& objCache, bool updateAll); - - static void updateActiveObjectsCache(const ObjectsCache& objCache, bool updateAll); - - static void updateInactiveObjectsCache(const ObjectsCache& objCache, bool updateAll); - - static void updateDivisionCache(SetDivisionCache& setDivisionCache,bool updateAll); - - static void updateCpuLoadInfo(vector &vEndpointF); - - static void updateCpuLoadInfo(vector &vSetServerInfo); - - static void InsertSetRecord(const string& objName, const string& setName, const string& setArea, const string& setGroup, EndpointF epf); - - - static void InsertSetRecord4Inactive(const string& objName, const string& setName, const string& setArea, const string& setGroup, EndpointF epf); - - static void addActiveEndPoint(const string& objName, const Int32 port, const Int32 istcp); - - static void addInactiveEndPoint(const string& objName, const Int32 port, const Int32 istcp); - - static void addEndPointbySet(const string& objName, const Int32 port, const Int32 istcp, const string& setName, const string& setArea, const string& setGroup); - - static void addActiveWeight1EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName = ""); - - static void addInActiveWeight1EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName = ""); - - static void addActiveWeight2EndPoint(const string& objName, const Int32 port, const Int32 istcp, const string& setName = ""); - - static void cleanEndPoint();; -protected: - - /** - * 根据group id获取Endpoint - */ - vector getEpsByGroupId(const vector & vecEps, const GroupUseSelect GroupSelect, int iGroupId, ostringstream &os); - - vector getEpsByGroupId(const vector & vecEps, const GroupUseSelect GroupSelect, const set & setGroupID, ostringstream & os); - -protected: - - static TC_ReadersWriterData _objectsCache; - //set划分缓存 - static TC_ReadersWriterData _setDivisionCache; - //优先级的序列 - static TC_ReadersWriterData > _mapGroupPriority; - //分组信息 - static TC_ReadersWriterData > _groupIdMap; - static TC_ReadersWriterData > _groupNameMap; -}; - -#endif diff --git a/unit-test/server/framework/QueryImp.cpp b/unit-test/server/framework/QueryImp.cpp deleted file mode 100755 index 4b2e5e15..00000000 --- a/unit-test/server/framework/QueryImp.cpp +++ /dev/null @@ -1,196 +0,0 @@ - - -#include "QueryImp.h" -#include "util/tc_logger.h" -#include "util/tc_clientsocket.h" - -void QueryImp::initialize() -{ - TLOGDEBUG("begin QueryImp init"< QueryImp::findObjectById(const string & id, tars::CurrentPtr current) -{ -// LOG_CONSOLE_DEBUG << endl; - vector eps = _db.findObjectById(id); - - ostringstream os; - doDaylog(FUNID_findObjectById,id,eps,vector(),current,os); - - return eps; -} - -tars::Int32 QueryImp::findObjectById4Any(const std::string & id,vector &activeEp,vector &inactiveEp,tars::CurrentPtr current) -{ -// LOG_CONSOLE_DEBUG << endl; - int iRet = _db.findObjectById4All(id, activeEp, inactiveEp); - - ostringstream os; - doDaylog(FUNID_findObjectById4Any,id,activeEp,inactiveEp,current,os); - - return iRet; -} - -int QueryImp::findObjectById4All(const std::string & id, vector &activeEp,vector &inactiveEp,tars::CurrentPtr current) -{ -// LOG_CONSOLE_DEBUG << endl; - ostringstream os; - - int iRet = _db.findObjectByIdInGroupPriority(id,current->getIp(),activeEp, inactiveEp,os); - - doDaylog(FUNID_findObjectById4All,id,activeEp,inactiveEp,current,os); - - return iRet; -} - -int QueryImp::findObjectByIdInSameGroup(const std::string & id, vector &activeEp,vector &inactiveEp, tars::CurrentPtr current) -{ -// LOG_CONSOLE_DEBUG << endl; - ostringstream os; - TLOGINFO(__FUNCTION__ << ":" << __LINE__ << "|" << id << "|" << current->getIp() << endl); - - int iRet = _db.findObjectByIdInGroupPriority(id, current->getIp(), activeEp, inactiveEp, os); - - doDaylog(FUNID_findObjectByIdInSameGroup,id,activeEp,inactiveEp,current,os); - - return iRet; -} - -Int32 QueryImp::findObjectByIdInSameStation(const std::string & id, const std::string & sStation, vector &activeEp, vector &inactiveEp, tars::CurrentPtr current) -{ -// LOG_CONSOLE_DEBUG << endl; - ostringstream os; - - int iRet = _db.findObjectByIdInSameStation(id, sStation, activeEp, inactiveEp, os); - - doDaylog(FUNID_findObjectByIdInSameStation,id,activeEp,inactiveEp,current,os); - - return iRet; -} - -Int32 QueryImp::findObjectByIdInSameSet(const std::string & id,const std::string & setId,vector &activeEp,vector &inactiveEp, tars::CurrentPtr current) -{ -// LOG_CONSOLE_DEBUG << endl; - vector vtSetInfo = TC_Common::sepstr(setId,"."); - - if (vtSetInfo.size()!=3 ||(vtSetInfo.size()==3&&(vtSetInfo[0]=="*"||vtSetInfo[1]=="*"))) - { - TLOGERROR("QueryImp::findObjectByIdInSameSet:|set full name error[" << id << "_" << setId <<"]|" << current->getIp() << endl); - return -1; - } - - ostringstream os; - int iRet = _db.findObjectByIdInSameSet(id, vtSetInfo, activeEp, inactiveEp, os); - if (-1 == iRet) - { - //未启动set,启动ip分组策略 - return findObjectByIdInSameGroup(id, activeEp, inactiveEp, current); - } - else if (-2 == iRet) - { - //启动了set,但未找到任何服务节点 - TLOGERROR("QueryImp::findObjectByIdInSameSet |no one server found for [" << id << "_" << setId <<"]|" << current->getIp() << endl); - return -1; - } - else if (-3 == iRet) - { - //启动了set,但未找到任何地区set,严格上不应该出现此类情形,配置错误或主调设置错误会引起此类错误 - TLOGERROR("QueryImp::findObjectByIdInSameSet |no set area found [" << id << "_" << setId <<"]|" << current->getIp() << endl); - return -1; - } - - doDaylog(FUNID_findObjectByIdInSameSet,id,activeEp,inactiveEp,current,os,setId); - - return iRet; -} - -void QueryImp::doDaylog(const FUNID eFnId,const string& id,const vector &activeEp, const vector &inactiveEp, const tars::CurrentPtr& current,const ostringstream& os,const string& sSetid) -{ - string sEpList; - for(size_t i = 0; i < activeEp.size(); i++) - { - if(0 != i) - { - sEpList += ";"; - } - sEpList += activeEp[i].host + ":" + TC_Common::tostr(activeEp[i].port); - } - - sEpList += "|"; - - for(size_t i = 0; i < inactiveEp.size(); i++) - { - if(0 != i) - { - sEpList += ";"; - } - sEpList += inactiveEp[i].host + ":" + TC_Common::tostr(inactiveEp[i].port); - } - - switch(eFnId) - { - case FUNID_findObjectById4All: - case FUNID_findObjectByIdInSameGroup: - { - FDLOG("query_idc") << eFunTostr(eFnId)<<"|"<getIp() << "|"<< current->getPort() << "|" << id << "|" <getIp() << "|"<< current->getPort() << "|" << id << "|" <getIp() << "|"<< current->getPort() << "|" << id << "|" < findObjectById(const string & id, tars::CurrentPtr current); - - /** - * 根据id获取所有对象,包括活动和非活动对象 - */ - virtual tars::Int32 findObjectById4Any(const std::string & id, vector &activeEp, vector &inactiveEp, tars::CurrentPtr current); - - /** - * 根据id获取对象所有endpoint列表 - */ - Int32 findObjectById4All(const std::string & id, vector &activeEp, vector &inactiveEp, tars::CurrentPtr current); - - /** - * 根据id获取对象同组endpoint列表 - */ - Int32 findObjectByIdInSameGroup(const std::string & id, vector &activeEp, vector &inactiveEp, tars::CurrentPtr current); - - /** - * 根据id获取对象指定归属地的endpoint列表 - */ - Int32 findObjectByIdInSameStation(const std::string & id, const std::string & sStation, vector &activeEp, vector &inactiveEp, tars::CurrentPtr current); - - /** - * 根据id获取对象同set endpoint列表 - */ - Int32 findObjectByIdInSameSet(const std::string & id,const std::string & setId,vector &activeEp,vector &inactiveEp, tars::CurrentPtr current); - - /** 查找某个obj部署在哪些节点上 (企业版功能) - * - * @param id obj名称 - * @return: 0-成功 others-失败 - */ - int findObjectNodeName(const string &id, vector &nodeName, CurrentPtr current) { return -1; }; - - /** 注册数据通知, 同时上报本地缓存数据的最后时间, 如果服务端发现变化则全量推送(企业版功能) - * 可以定时上报数据 - * @param timestamp <数据类型, 最后数据时间戳> - * @param name 当前模块名称 - * @return: 0-成功 others-失败 - */ - Int32 registerChange(const map ×tamp, const string &name, CurrentPtr current) { return -1; }; - - /** 注册id变化的通知, 通知时后需要自己主动find(企业版功能) - * - * @param id 对象名称 - * @param name 当前模块名称 - * @return: 0-成功 others-失败 - */ - Int32 registerQuery(const string &id, const string &name, CurrentPtr current) { return -1; }; - - /** - * 获取锁, 实现业务服务一主多备的模式(企业版功能) - * @return 0: 获取锁成功; 1:获取锁失败; 2: 数据异常, -1:其他异常 - */ - Int32 getLocker(const tars::GetMasterSlaveLock &req, CurrentPtr current) { return -1;}; - - -private: - /** - * 打印按天日志 - */ - void doDaylog(const FUNID eFnId,const string& id,const vector &activeEp, const vector &inactiveEp, const tars::CurrentPtr& current,const std::ostringstream& os,const string& sSetid=""); - - /** - * 转化成字符串 - */ - string eFunTostr(const FUNID eFnId); -protected: - //数据库操作 - CDbHandle _db; -}; - -#endif diff --git a/unit-test/server/hello.conf b/unit-test/server/hello.conf index 063886fc..4a175ab2 100755 --- a/unit-test/server/hello.conf +++ b/unit-test/server/hello.conf @@ -3,14 +3,14 @@ #proxy需要的配置 #地址 - locator = TestApp.FrameworkServer.QueryObj@tcp -h 127.0.0.1 -p 11004 + locator = tars.tarsmock.QueryObj@tcp -h 127.0.0.1 -p 17890 #最大超时时间(毫秒) sync-invoke-timeout = 50000 async-invoke-timeout = 60000 #刷新端口时间间隔(毫秒) refresh-endpoint-interval = 100000 #模块间调用[可选] - stat = TestApp.FrameworkServer.StatObj + stat = tars.tarsmock.StatObj #发送队列长度 sendqueuelimit = 1000000 #异步回调队列个数限制 @@ -95,11 +95,11 @@ local = tcp -h 127.0.0.1 -p 18001 -t 10000 #配置中心的地址[可选] - config = TestApp.FrameworkServer.ConfigObj + config = tars.tarsmock.ConfigObj #配置中心的地址[可选] # notify = tars.tarsconfig.NotifyObj #远程LogServer[可选] - log = TestApp.FrameworkServer.LogObj + log = tars.tarsmock.LogObj # manuallisten = 1 diff --git a/unit-test/server/rpc1.conf b/unit-test/server/rpc1.conf index 3c145946..54ad56f0 100755 --- a/unit-test/server/rpc1.conf +++ b/unit-test/server/rpc1.conf @@ -3,7 +3,7 @@ #proxy需要的配置 #地址 - locator = TestApp.FrameworkServer.QueryObj@tcp -h 127.0.0.1 -p 11004 + locator = tars.tarsmock.QueryObj@tcp -h 127.0.0.1 -p 17890 #最大超时时间(毫秒) sync-invoke-timeout = 5000 async-invoke-timeout = 60000 diff --git a/unit-test/server/rpc2.conf b/unit-test/server/rpc2.conf index 0b34ca9e..5965f08e 100755 --- a/unit-test/server/rpc2.conf +++ b/unit-test/server/rpc2.conf @@ -3,7 +3,7 @@ #proxy需要的配置 #地址 - locator = TestApp.FrameworkServer.QueryObj@tcp -h 127.0.0.1 -p 11004 + locator = tars.tarsmock.QueryObj@tcp -h 127.0.0.1 -p 17890 #最大超时时间(毫秒) sync-invoke-timeout = 5000 async-invoke-timeout = 60000 diff --git a/unit-test/server/rpc3.conf b/unit-test/server/rpc3.conf index 715dd241..45dc4949 100755 --- a/unit-test/server/rpc3.conf +++ b/unit-test/server/rpc3.conf @@ -3,7 +3,7 @@ #proxy需要的配置 #地址 - locator = TestApp.FrameworkServer.QueryObj@tcp -h 127.0.0.1 -p 11004 + locator = tars.tarsmock.QueryObj@tcp -h 127.0.0.1 -p 17890 #最大超时时间(毫秒) sync-invoke-timeout = 5000 async-invoke-timeout = 60000 diff --git a/unit-test/server/windows.conf b/unit-test/server/windows.conf index a76f3d95..4cf97513 100644 --- a/unit-test/server/windows.conf +++ b/unit-test/server/windows.conf @@ -3,14 +3,14 @@ #proxy需要的配置 #地址 - locator = TestApp.FrameworkServer.QueryObj@tcp -h 127.0.0.1 -p 11004 + locator = tars.tarsmock.QueryObj@tcp -h 127.0.0.1 -p 17890 #最大超时时间(毫秒) sync-invoke-timeout = 15000 async-invoke-timeout = 60000 #刷新端口时间间隔(毫秒) refresh-endpoint-interval = 100000 #模块间调用[可选] - stat = TestApp.FrameworkServer.StatObj + stat = tars.tarsmock.StatObj #发送队列长度 sendqueuelimit = 1000000 #异步回调队列个数限制 @@ -49,7 +49,7 @@ local = tcp -h 127.0.0.1 -p 15001 -t 10000 #配置中心的地址[可选] - config = TestApp.FrameworkServer.ConfigObj + config = tars.tarsmock.ConfigObj #配置中心的地址[可选] # notify = tars.tarsconfig.NotifyObj #远程LogServer[可选] From 79680e408a2e19534591e7f5f0311bb5b3f353cc Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 14 Mar 2024 17:14:03 +0800 Subject: [PATCH 78/81] fix windows tc_port freopen compiler bug --- util/src/tc_port.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index c11adc0f..604c9bca 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -724,7 +724,7 @@ vector TC_Port::getPidsByCmdline(const string &cmdLine, bool accurateMa FILE *TC_Port::freopen(const char * dst, const char * mode, FILE * src) { -#if TARGET_PLATFORM_IOS +#if TARGET_PLATFORM_IOS || TARGET_PLATFORM_WINDOWS return ::freopen(dst, mode, src); #else return ::freopen64(dst, mode, src); From 9e052e7ebf08e7fb98a625e94857366e3fd4cb8d Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 14 Mar 2024 17:27:41 +0800 Subject: [PATCH 79/81] fix endpoint manager log --- servant/libservant/EndpointManager.cpp | 50 +++++++++++++------------- servant/servant/EndpointManager.h | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/servant/libservant/EndpointManager.cpp b/servant/libservant/EndpointManager.cpp index caca5e24..249afa58 100644 --- a/servant/libservant/EndpointManager.cpp +++ b/servant/libservant/EndpointManager.cpp @@ -58,7 +58,7 @@ QueryEpBase::QueryEpBase(Communicator * pComm, bool bFirstNetThread,bool bInterf void QueryEpBase::callback_findObjectById4All(Int32 ret, const vector& activeEp, const vector& inactiveEp) { - TLOGTARS("[callback_findObjectById4All _objName:" << _objName << "|ret:" << ret + TLOGTARS("[callback_findObjectById4All objName:" << _objName << "|ret:" << ret << ",active:" << activeEp.size() << ",inactive:" << inactiveEp.size() << "]" << endl); @@ -67,14 +67,14 @@ void QueryEpBase::callback_findObjectById4All(Int32 ret, const vector void QueryEpBase::callback_findObjectById4All_exception(Int32 ret) { - TLOGERROR("[callback_findObjectById4All_exception _objName:" << _objName << "|ret:" << ret << "]" << endl); + TLOGTARS("[callback_findObjectById4All_exception objName:" << _objName << "|ret:" << ret << "]" << endl); doEndpointsExp(ret); } void QueryEpBase::callback_findObjectById4Any(Int32 ret, const vector& activeEp, const vector& inactiveEp) { - TLOGTARS("[callback_findObjectById4Any _objName:" << _objName << "|ret:" << ret + TLOGTARS("[callback_findObjectById4Any objName:" << _objName << "|ret:" << ret << ",active:" << activeEp.size() << ",inactive:" << inactiveEp.size() << "]" << endl); @@ -83,14 +83,14 @@ void QueryEpBase::callback_findObjectById4Any(Int32 ret, const vector void QueryEpBase::callback_findObjectById4Any_exception(Int32 ret) { - TLOGERROR("[callback_findObjectById4Any_exception _objName:" << _objName << "|ret:" << ret << "]" << endl); + TLOGTARS("[callback_findObjectById4Any_exception objName:" << _objName << "|ret:" << ret << "]" << endl); doEndpointsExp(ret); } void QueryEpBase::callback_findObjectByIdInSameGroup(Int32 ret, const vector& activeEp, const vector& inactiveEp) { - TLOGTARS("[callback_findObjectByIdInSameGroup _objName:" << _objName << "|ret:"< &activeEp, const vector & inactiveEp) { - TLOGTARS("[callback_findObjectByIdInSameSet _objName:" << _objName << "|ret:" << ret + TLOGTARS("[callback_findObjectByIdInSameSet objName:" << _objName << "|ret:" << ret << ",active:" << activeEp.size() << ",inactive:" << inactiveEp.size() << "]" << endl); @@ -115,14 +115,14 @@ void QueryEpBase::callback_findObjectByIdInSameSet( Int32 ret, const vector &activeEp, const vector &inactiveEp) { - TLOGTARS("[callback_findObjectByIdInSameStation _objName:" << _objName << "|ret:" << ret + TLOGTARS("[callback_findObjectByIdInSameStation objName:" << _objName << "|ret:" << ret << ",active:" << activeEp.size() << ",inactive:" << inactiveEp.size() << "]" << endl); @@ -131,12 +131,12 @@ void QueryEpBase::callback_findObjectByIdInSameStation( Int32 ret, const vector< void QueryEpBase::callback_findObjectByIdInSameStation_exception( Int32 ret) { - TLOGERROR("[callback_findObjectByIdInSameStation_exception _objName:" << _objName << "|ret:" << ret << "]" << endl); + TLOGTARS("[callback_findObjectByIdInSameStation_exception objName:" << _objName << ", ret:" << ret << "]" << endl); doEndpointsExp(ret); } -int QueryEpBase::setLocatorPrx(QueryFPrx prx) +int QueryEpBase::setLocatorPrx(const QueryFPrx& prx) { _queryFPrx = prx; @@ -201,7 +201,7 @@ void QueryEpBase::setObjName(const string & sObjName) sEndpoints = sObjName.substr(pos + 1); - pos = _objName.find_first_of("#"); + pos = _objName.find_first_of('#'); if(pos != string::npos) { @@ -211,7 +211,7 @@ void QueryEpBase::setObjName(const string & sObjName) _direct = true; //如果就是主控, 则认为是非direct - size_t pos = _locator.find_first_not_of('@'); + pos = _locator.find_first_not_of('@'); if(pos != string::npos && _objName == _locator.substr(0, pos)) { _direct = false; @@ -238,11 +238,11 @@ void QueryEpBase::setObjName(const string & sObjName) if(_locator.find_first_not_of('@') == string::npos) { - TLOGERROR("[QueryEpBase::setObjName locator is not valid,_locator:" << _locator << "]" << endl); - throw TarsRegistryException("locator is not valid,_locator:" + _locator); + TLOGERROR("[QueryEpBase::setObjName locator is not valid, locator:" << _locator << "]" << endl); + throw TarsRegistryException("locator is not valid, locator:" + _locator); } - pos = _objName.find_first_of("#"); + pos = _objName.find_first_of('#'); if(pos != string::npos) { _objName = _objName.substr(0, pos); @@ -514,7 +514,7 @@ void QueryEpBase::doEndpoints(const vector& activeEp, const vector 0) @@ -1145,7 +1145,7 @@ AdapterProxy* EndpointManager::getConHashProxyForWeight(int64_t hashCode, bool b if (_indexActiveProxys.empty()) { - TLOGERROR("[EndpointManager::getConHashProxyForNormal _activeEndpoints is empty]" << endl); + TLOGERROR("[EndpointManager::getConHashProxyForNormal activeEndpoints is empty]" << endl); return NULL; } } @@ -1235,7 +1235,7 @@ void EndpointManager::updateHashProxyWeighted(bool bStatic) { if(_vRegProxys.size() <= 0) { - TLOGERROR("[EndpointManager::updateHashProxyWeighted _vRegProxys is empty], bStatic:" << bStatic << endl); + TLOGERROR("[EndpointManager::updateHashProxyWeighted vRegProxys is empty, bStatic:" << bStatic << "]" << endl); return ; } @@ -1258,9 +1258,9 @@ void EndpointManager::updateHashProxyWeighted(bool bStatic) _vRegProxys[i]->resetWeightChanged(); } - if(vRegProxys.size() <= 0) + if(vRegProxys.empty()) { - TLOGERROR("[EndpointManager::updateHashProxyWeighted vRegProxys is empty], bStatic:" << bStatic << endl); + TLOGERROR("[EndpointManager::updateHashProxyWeighted vRegProxys is empty, bStatic:" << bStatic << "]" << endl); return ; } @@ -1325,7 +1325,7 @@ void EndpointManager::updateHashProxyWeighted(bool bStatic) } } - TLOGTARS("EndpointManager::updateHashProxyWeighted bStatic:" << bStatic << "|_objName:" << _objName << "|endpoint:" << vRegProxys[i]->endpoint().desc() << "|iWeight:" << vRegProxys[i]->getWeight() << "|iWeightR:" << iWeight << "|iIndex:" << vIndex[i] << endl); + TLOGTARS("EndpointManager::updateHashProxyWeighted bStatic:" << bStatic << ", objName:" << _objName << ", endpoint:" << vRegProxys[i]->endpoint().desc() << ", iWeight:" << vRegProxys[i]->getWeight() << ", iWeightR:" << iWeight << ", iIndex:" << vIndex[i] << endl); } for(size_t i = 0; i < iMaxRouterR; i++) @@ -1363,7 +1363,7 @@ void EndpointManager::updateConHashProxyWeighted(bool bStatic, map Date: Sun, 17 Mar 2024 18:39:40 +0800 Subject: [PATCH 80/81] fix servantprx/adapterprx tars_set_push_callback nullptr protected --- servant/libservant/AdapterProxy.cpp | 9 +++++---- servant/libservant/ServantProxy.cpp | 5 ++++- util/src/tc_epoll_server.cpp | 10 ---------- util/src/tc_thread.cpp | 2 +- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/servant/libservant/AdapterProxy.cpp b/servant/libservant/AdapterProxy.cpp index c61c6d65..1a79784e 100755 --- a/servant/libservant/AdapterProxy.cpp +++ b/servant/libservant/AdapterProxy.cpp @@ -150,9 +150,9 @@ std::shared_ptr AdapterProxy::onOpensslCallback(TC_Transceiver* tran void AdapterProxy::onCloseCallback(TC_Transceiver* trans, TC_Transceiver::CloseReason reason, const string &err) { - if(_objectProxy->getRootServantProxy()->tars_get_push_callback()) + if(auto cb = _objectProxy->getRootServantProxy()->tars_get_push_callback()) { - _objectProxy->getRootServantProxy()->tars_get_push_callback()->onClose(trans->getConnectEndpoint()); + cb->onClose(trans->getConnectEndpoint()); } int millisecond =_objectProxy->reconnect(); @@ -831,8 +831,9 @@ void AdapterProxy::finishInvoke_parallel(shared_ptr & rsp) if (rsp->iRequestId == 0) { + auto cb = _objectProxy->getRootServantProxy()->tars_get_push_callback(); //requestid 为0 是push消息, push callback is null - if (!_objectProxy->getRootServantProxy()->tars_get_push_callback()) + if (!cb) { TLOGERROR("[AdapterProxy::finishInvoke(BasePacket), request id is 0, pushcallback is null, " << _objectProxy->name() << ", " << _trans->getConnectionString() << "]" << endl); throw TarsDecodeException("request id is 0, pushcallback is null, obj: " + _objectProxy->name() + ", desc: " + _trans->getConnectionString()); @@ -845,7 +846,7 @@ void AdapterProxy::finishInvoke_parallel(shared_ptr & rsp) msg->proxy = _objectProxy->getServantProxy(); msg->pObjectProxy = _objectProxy; msg->adapter = this; - msg->callback = _objectProxy->getRootServantProxy()->tars_get_push_callback(); + msg->callback = cb; } else { diff --git a/servant/libservant/ServantProxy.cpp b/servant/libservant/ServantProxy.cpp index cc09b1e0..77a8ea9e 100644 --- a/servant/libservant/ServantProxy.cpp +++ b/servant/libservant/ServantProxy.cpp @@ -851,7 +851,10 @@ void ServantProxy::tars_set_push_callback(const ServantProxyCallbackPtr & cb) { std::lock_guard lock(_mutex); _pushCallback = cb; - cb->setServantPrx(this); + if(_pushCallback) + { + _pushCallback->setServantPrx(this); + } } ServantProxyCallbackPtr ServantProxy::tars_get_push_callback() diff --git a/util/src/tc_epoll_server.cpp b/util/src/tc_epoll_server.cpp index 1f5f6da3..691b1e80 100644 --- a/util/src/tc_epoll_server.cpp +++ b/util/src/tc_epoll_server.cpp @@ -1398,9 +1398,6 @@ TC_EpollServer::BindAdapter::~BindAdapter() void TC_EpollServer::BindAdapter::bind() { - // try - // { - assert(!_s.isValid()); #if TARGET_PLATFORM_WINDOWS @@ -1452,13 +1449,6 @@ void TC_EpollServer::BindAdapter::bind() } } _s.setblock(false); - // } - // catch(exception &ex) - // { - // _s.close(); - // cerr << "bind:" << _ep.toString() << " error:" << ex.what() << endl; - // throw ex; - // } } void TC_EpollServer::BindAdapter::setNetThreads(const vector &netThreads) diff --git a/util/src/tc_thread.cpp b/util/src/tc_thread.cpp index 8ac8d54a..ccf92ba3 100644 --- a/util/src/tc_thread.cpp +++ b/util/src/tc_thread.cpp @@ -123,7 +123,7 @@ void TC_Thread::threadEntry(TC_Thread *pThread) catch (exception &ex) { cerr << std::this_thread::get_id() << "|" << ex.what() << endl; - throw ex; + throw; } catch (...) { From 37e4ec68fbcb085c20f92acca66d4bff9d6d882b Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 20 Mar 2024 09:25:46 +0800 Subject: [PATCH 81/81] fix tars.h cout log --- servant/tup/Tars.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/servant/tup/Tars.h b/servant/tup/Tars.h index 1361694c..dc0279e7 100755 --- a/servant/tup/Tars.h +++ b/servant/tup/Tars.h @@ -2221,9 +2221,6 @@ class TarsOutputStream : public WriterT { write(i->first, 0); write(i->second, 1); - - std::cout << "write:" << i->first << ", " << i->second << std::endl; - } } }