From 52e5152fbef14380be9d7e2c55b33ba8ce1c40de Mon Sep 17 00:00:00 2001 From: edisenwang <114474163@qq.com> Date: Wed, 20 Mar 2024 16:14:13 +0800 Subject: [PATCH 01/44] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8D=8F=E7=A8=8B?= =?UTF-8?q?=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/include/util/tc_coroutine.h | 5 + util/include/util/tc_coroutine_mutex.h | 71 +++++ util/src/tc_coroutine.cpp | 375 +++++++++++++------------ util/src/tc_coroutine_mutex.cpp | 57 ++++ 4 files changed, 326 insertions(+), 182 deletions(-) create mode 100644 util/include/util/tc_coroutine_mutex.h create mode 100644 util/src/tc_coroutine_mutex.cpp diff --git a/util/include/util/tc_coroutine.h b/util/include/util/tc_coroutine.h index 97832153..0d62f5c9 100644 --- a/util/include/util/tc_coroutine.h +++ b/util/include/util/tc_coroutine.h @@ -671,6 +671,11 @@ class TC_CoroutineScheduler * 是否正在运行中 */ bool _ready = false; + + /** + * 解决在使用协程锁时tc_coroutine_mutex.h(TC_CoMutex),可能多线程使用TC_CoroutineScheduler->put造成的_activeCoroQueue队列写冲突 + */ + std::mutex _mutex; }; /** diff --git a/util/include/util/tc_coroutine_mutex.h b/util/include/util/tc_coroutine_mutex.h new file mode 100644 index 00000000..694dc72f --- /dev/null +++ b/util/include/util/tc_coroutine_mutex.h @@ -0,0 +1,71 @@ +#pragma once + +#include +#include +#include +#include "util/tc_coroutine.h" +#include "util/tc_spin_lock.h" + +namespace tars +{ + ///////////////////////////////////////////////// + /** + * @file tc_coroutine_mutex.h + * @brief 协程锁互斥类 + * + * @author edisenwang + */ + ///////////////////////////////////////////////// + + /** + * @brief 协程锁 . + * + * 开启协程后使用 + */ + class TC_CoMutex{ + protected: + struct CoMutexInfo{ + const std::shared_ptr _sched; + uint32_t _coroId; + + CoMutexInfo(const std::shared_ptr sched, uint32_t coroId):_sched(sched), _coroId(coroId){} + }; + + public: + TC_CoMutex(); + + virtual ~TC_CoMutex(); + + /** + * @brief 尝试锁 + * + * @return bool + */ + bool try_lock(); + + /** + * @brief 加锁 + */ + void lock(); + + /** + * @brief 解锁 + */ + void unlock(); + + protected: + + // noncopyable + TC_CoMutex(const TC_CoMutex&) = delete; + void operator=(const TC_CoMutex&) = delete; + + protected: + + TC_SpinLock _slck; + + mutable std::mutex _mutex; + + std::list _list; + }; +} + diff --git a/util/src/tc_coroutine.cpp b/util/src/tc_coroutine.cpp index 46a68832..53c74bca 100755 --- a/util/src/tc_coroutine.cpp +++ b/util/src/tc_coroutine.cpp @@ -495,7 +495,14 @@ void TC_CoroutineScheduler::run() while(!_epoller->isTerminate()) { - if(_activeCoroQueue.empty() && TC_CoroutineInfo::CoroutineHeadEmpty(&_avail) && TC_CoroutineInfo::CoroutineHeadEmpty(&_active)) + bool activeCoroQueue_empty; + + { + std::lock_guard lock(_mutex); + activeCoroQueue_empty = _activeCoroQueue.empty(); + } + + if(activeCoroQueue_empty && TC_CoroutineInfo::CoroutineHeadEmpty(&_avail) && TC_CoroutineInfo::CoroutineHeadEmpty(&_active)) { _epoller->done(1000); } @@ -533,11 +540,11 @@ void TC_CoroutineScheduler::run() switchCoro(coro); } - //没有任何可执行的写成了, 直接退出! - if(_usedSize == 0 && _noCoroutineCallback) - { - _noCoroutineCallback(this); - } + //没有任何可执行的写成了, 直接退出! + if(_usedSize == 0 && _noCoroutineCallback) + { + _noCoroutineCallback(this); + } } destroy(); @@ -547,115 +554,119 @@ void TC_CoroutineScheduler::run() void TC_CoroutineScheduler::yield(bool bFlag) { - //主协程不允许yield - if(_currentCoro->getUid() == 0) - { - return; - } + //主协程不允许yield + if(_currentCoro->getUid() == 0) + { + return; + } - if(bFlag) - { - _needActiveCoroId.push_back(_currentCoro->getUid()); - } + if(bFlag) + { + _needActiveCoroId.push_back(_currentCoro->getUid()); + } - moveToInactive(_currentCoro); - switchCoro(&_mainCoro); + moveToInactive(_currentCoro); + switchCoro(&_mainCoro); } void TC_CoroutineScheduler::sleep(int iSleepTime) { - //主协程不允许sleep - if(_currentCoro->getUid() == 0) - return; + //主协程不允许sleep + if(_currentCoro->getUid() == 0) + return; - int64_t iNow = TNOWMS; - int64_t iTimeout = iNow + (iSleepTime >= 0 ? iSleepTime : -iSleepTime); + int64_t iNow = TNOWMS; + int64_t iTimeout = iNow + (iSleepTime >= 0 ? iSleepTime : -iSleepTime); - _timeoutCoroId.insert(make_pair(iTimeout, _currentCoro->getUid())); + _timeoutCoroId.insert(make_pair(iTimeout, _currentCoro->getUid())); - moveToTimeout(_currentCoro); + moveToTimeout(_currentCoro); - _epoller->postAtTime(iTimeout, [](){}); + _epoller->postAtTime(iTimeout, [](){}); - switchCoro(&_mainCoro); + switchCoro(&_mainCoro); } void TC_CoroutineScheduler::wakeupbyself() { - if(!_needActiveCoroId.empty() && !_epoller->isTerminate()) - { - list::iterator it = _needActiveCoroId.begin(); - while(it != _needActiveCoroId.end()) - { - TC_CoroutineInfo *coro = _all_coro[*it]; + if(!_needActiveCoroId.empty() && !_epoller->isTerminate()) + { + list::iterator it = _needActiveCoroId.begin(); + while(it != _needActiveCoroId.end()) + { + TC_CoroutineInfo *coro = _all_coro[*it]; - assert(coro != NULL); + assert(coro != NULL); - moveToAvail(coro); + moveToAvail(coro); - ++it; - } - _needActiveCoroId.clear(); - } + ++it; + } + _needActiveCoroId.clear(); + } } void TC_CoroutineScheduler::put(uint32_t iCoroId) { - if(!_epoller->isTerminate()) - { - _activeCoroQueue.push_back(iCoroId); + if(!_epoller->isTerminate()) + { + { + std::lock_guard lock(_mutex); + _activeCoroQueue.push_back(iCoroId); + } - _epoller->notify(); - } + _epoller->notify(); + } } void TC_CoroutineScheduler::wakeup() { - if(!_activeCoroQueue.empty() && !_epoller->isTerminate()) - { - deque coroIds; + if(_epoller->isTerminate()) return ; - _activeCoroQueue.swap(coroIds); + deque coroIds; + { + std::lock_guard lock(_mutex); + _activeCoroQueue.swap(coroIds); + } - auto it = coroIds.begin(); + auto it = coroIds.begin(); - auto itEnd = coroIds.end(); + auto itEnd = coroIds.end(); - while(it != itEnd) - { - TC_CoroutineInfo *coro = _all_coro[*it]; + while(it != itEnd) + { + TC_CoroutineInfo *coro = _all_coro[*it]; - assert(coro != NULL); + assert(coro != NULL); - moveToActive(coro); + moveToActive(coro); - ++it; - } - } + ++it; + } } void TC_CoroutineScheduler::wakeupbytimeout() { - if(!_timeoutCoroId.empty() && !_epoller->isTerminate()) - { - int64_t iNow = TNOWMS; - while(true) - { - multimap::iterator it = _timeoutCoroId.begin(); + if(!_timeoutCoroId.empty() && !_epoller->isTerminate()) + { + int64_t iNow = TNOWMS; + while(true) + { + multimap::iterator it = _timeoutCoroId.begin(); - if(it == _timeoutCoroId.end() || it->first > iNow) - break; + if(it == _timeoutCoroId.end() || it->first > iNow) + break; - TC_CoroutineInfo *coro = _all_coro[it->second]; + TC_CoroutineInfo *coro = _all_coro[it->second]; - assert(coro != NULL); + assert(coro != NULL); - moveToActive(coro); + moveToActive(coro); - _timeoutCoroId.erase(it); - } + _timeoutCoroId.erase(it); + } - } + } } void TC_CoroutineScheduler::terminate() @@ -663,30 +674,30 @@ void TC_CoroutineScheduler::terminate() assert(_epoller); _epoller->terminate(); -// -// if(_epoller) -// { -// delete _epoller; -// _epoller = NULL; -// } + // + // if(_epoller) + // { + // delete _epoller; + // _epoller = NULL; + // } } uint32_t TC_CoroutineScheduler::generateId() { - uint32_t i = ++_uniqId; - if(i == 0) { - i = ++_uniqId; - } + uint32_t i = ++_uniqId; + if(i == 0) { + i = ++_uniqId; + } - assert(i <= _poolSize); + assert(i <= _poolSize); - return i; + return i; } void TC_CoroutineScheduler::switchCoro(TC_CoroutineInfo *to) { - //跳转到to协程 - _currentCoro = to; + //跳转到to协程 + _currentCoro = to; transfer_t t = tars_jump_fcontext(to->getCtx(), NULL); @@ -696,175 +707,175 @@ void TC_CoroutineScheduler::switchCoro(TC_CoroutineInfo *to) void TC_CoroutineScheduler::moveToActive(TC_CoroutineInfo *coro) { - if(coro->getStatus() == TC_CoroutineInfo::CORO_INACTIVE || coro->getStatus() == TC_CoroutineInfo::CORO_TIMEOUT) - { - TC_CoroutineInfo::CoroutineDel(coro); - coro->setStatus(TC_CoroutineInfo::CORO_ACTIVE); - TC_CoroutineInfo::CoroutineAddTail(coro, &_active); - } - else - { - assert(false); - } + if(coro->getStatus() == TC_CoroutineInfo::CORO_INACTIVE || coro->getStatus() == TC_CoroutineInfo::CORO_TIMEOUT) + { + TC_CoroutineInfo::CoroutineDel(coro); + coro->setStatus(TC_CoroutineInfo::CORO_ACTIVE); + TC_CoroutineInfo::CoroutineAddTail(coro, &_active); + } + else + { + assert(false); + } } void TC_CoroutineScheduler::moveToAvail(TC_CoroutineInfo *coro) { - if(coro->getStatus() == TC_CoroutineInfo::CORO_INACTIVE) - { - TC_CoroutineInfo::CoroutineDel(coro); - coro->setStatus(TC_CoroutineInfo::CORO_AVAIL); - TC_CoroutineInfo::CoroutineAddTail(coro, &_avail); - } - else - { - assert(false); - } + if(coro->getStatus() == TC_CoroutineInfo::CORO_INACTIVE) + { + TC_CoroutineInfo::CoroutineDel(coro); + coro->setStatus(TC_CoroutineInfo::CORO_AVAIL); + TC_CoroutineInfo::CoroutineAddTail(coro, &_avail); + } + else + { + assert(false); + } } void TC_CoroutineScheduler::moveToInactive(TC_CoroutineInfo *coro) { - if(coro->getStatus() == TC_CoroutineInfo::CORO_ACTIVE || coro->getStatus() == TC_CoroutineInfo::CORO_AVAIL) - { - TC_CoroutineInfo::CoroutineDel(coro); - coro->setStatus(TC_CoroutineInfo::CORO_INACTIVE); - TC_CoroutineInfo::CoroutineAddTail(coro, &_inactive); - } - else - { - assert(false); - } + if(coro->getStatus() == TC_CoroutineInfo::CORO_ACTIVE || coro->getStatus() == TC_CoroutineInfo::CORO_AVAIL) + { + TC_CoroutineInfo::CoroutineDel(coro); + coro->setStatus(TC_CoroutineInfo::CORO_INACTIVE); + TC_CoroutineInfo::CoroutineAddTail(coro, &_inactive); + } + else + { + assert(false); + } } void TC_CoroutineScheduler::moveToTimeout(TC_CoroutineInfo *coro) { - if(coro->getStatus() == TC_CoroutineInfo::CORO_ACTIVE || coro->getStatus() == TC_CoroutineInfo::CORO_AVAIL) - { - TC_CoroutineInfo::CoroutineDel(coro); - coro->setStatus(TC_CoroutineInfo::CORO_TIMEOUT); - TC_CoroutineInfo::CoroutineAddTail(coro, &_timeout); - } - else - { - assert(false); - } + if(coro->getStatus() == TC_CoroutineInfo::CORO_ACTIVE || coro->getStatus() == TC_CoroutineInfo::CORO_AVAIL) + { + TC_CoroutineInfo::CoroutineDel(coro); + coro->setStatus(TC_CoroutineInfo::CORO_TIMEOUT); + TC_CoroutineInfo::CoroutineAddTail(coro, &_timeout); + } + else + { + assert(false); + } } void TC_CoroutineScheduler::moveToFreeList(TC_CoroutineInfo *coro) { - if(coro->getStatus() != TC_CoroutineInfo::CORO_FREE) - { - TC_CoroutineInfo::CoroutineDel(coro); - coro->setStatus(TC_CoroutineInfo::CORO_FREE); - TC_CoroutineInfo::CoroutineAddTail(coro, &_free); - } - else - { - assert(false); - } + if(coro->getStatus() != TC_CoroutineInfo::CORO_FREE) + { + TC_CoroutineInfo::CoroutineDel(coro); + coro->setStatus(TC_CoroutineInfo::CORO_FREE); + TC_CoroutineInfo::CoroutineAddTail(coro, &_free); + } + else + { + assert(false); + } } void TC_CoroutineScheduler::destroy() { - if(_all_coro) - { - //id=0是保留不用的, 给mainCoro作为id用 - assert(_all_coro[0] == NULL); - - for (size_t i = 1; i <= _poolSize; i++) - { - if(_all_coro[i]) - { - stack_traits::deallocate(_all_coro[i]->getStackContext()); - delete _all_coro[i]; - _all_coro[i] = NULL; - } - } - delete [] _all_coro; + if(_all_coro) + { + //id=0是保留不用的, 给mainCoro作为id用 + assert(_all_coro[0] == NULL); + + for (size_t i = 1; i <= _poolSize; i++) + { + if(_all_coro[i]) + { + stack_traits::deallocate(_all_coro[i]->getStackContext()); + delete _all_coro[i]; + _all_coro[i] = NULL; + } + } + delete [] _all_coro; _all_coro = NULL; - } + } } ///////////////////////////////////////////////////////// TC_Coroutine::TC_Coroutine() -: _coroSched(NULL) -, _num(1) -, _maxNum(128) -, _stackSize(128*1024) + : _coroSched(NULL) + , _num(1) + , _maxNum(128) + , _stackSize(128*1024) { } TC_Coroutine::~TC_Coroutine() { - if(isAlive()) - { - terminate(); + if(isAlive()) + { + terminate(); - getThreadControl().join(); - } + getThreadControl().join(); + } } void TC_Coroutine::setCoroInfo(uint32_t iNum, uint32_t iMaxNum, size_t iStackSize) { - _maxNum = (iMaxNum > 0 ? iMaxNum : 1); - _num = (iNum > 0 ? (iNum <= _maxNum ? iNum : _maxNum) : 1); - _stackSize = (iStackSize >= pagesize() ? iStackSize : pagesize()); + _maxNum = (iMaxNum > 0 ? iMaxNum : 1); + _num = (iNum > 0 ? (iNum <= _maxNum ? iNum : _maxNum) : 1); + _stackSize = (iStackSize >= pagesize() ? iStackSize : pagesize()); } void TC_Coroutine::run() { - _coroSched = TC_CoroutineScheduler::create(); + _coroSched = TC_CoroutineScheduler::create(); - initialize(); + initialize(); - handleCoro(); + handleCoro(); - destroy(); + destroy(); -// TC_CoroutineScheduler::reset(); + // TC_CoroutineScheduler::reset(); } void TC_Coroutine::terminate() { - if(_coroSched) - { - _coroSched->terminate(); - } + if(_coroSched) + { + _coroSched->terminate(); + } } void TC_Coroutine::handleCoro() { - _coroSched->setPoolStackSize(_maxNum, _stackSize); + _coroSched->setPoolStackSize(_maxNum, _stackSize); - _coroSched->setNoCoroutineCallback([&](TC_CoroutineScheduler *scheduler){scheduler->terminate();}); + _coroSched->setNoCoroutineCallback([&](TC_CoroutineScheduler *scheduler){scheduler->terminate();}); //把协程创建出来 - for(uint32_t i = 0; i < _num; ++i) - { + for(uint32_t i = 0; i < _num; ++i) + { _coroSched->go(std::bind(&TC_Coroutine::coroEntry, this)); - } + } - _coroSched->run(); + _coroSched->run(); } void TC_Coroutine::coroEntry(TC_Coroutine *pCoro) { - pCoro->handle(); + pCoro->handle(); } uint32_t TC_Coroutine::go(const std::function &coroFunc) { - return _coroSched->go(coroFunc); + return _coroSched->go(coroFunc); } void TC_Coroutine::yield() { - _coroSched->yield(); + _coroSched->yield(); } void TC_Coroutine::sleep(int millseconds) { - _coroSched->sleep(millseconds); + _coroSched->sleep(millseconds); } } diff --git a/util/src/tc_coroutine_mutex.cpp b/util/src/tc_coroutine_mutex.cpp new file mode 100644 index 00000000..804b04a8 --- /dev/null +++ b/util/src/tc_coroutine_mutex.cpp @@ -0,0 +1,57 @@ +#include "util/tc_coroutine_mutex.h" + +namespace tars +{ + TC_CoMutex::TC_CoMutex() + { + } + + TC_CoMutex::~TC_CoMutex() + { + } + + bool TC_CoMutex::try_lock() + { + return _slck.tryLock(); + } + + void TC_CoMutex::lock() + { + if(_slck.tryLock()) + { + return ; + } + else + { + std::shared_ptr sched = TC_CoroutineScheduler::scheduler(); + assert(sched && sched->getCoroutineId() != 0); + { + std::lock_guard lock(_mutex); + //加锁后再检查一次, 如果获取到执行条件则直接退出 + if(_slck.tryLock()) + { + return ; + } + + _list.emplace_back(CoMutexInfo(sched, sched->getCoroutineId())); + } + + sched->yield(false); + } + } + + void TC_CoMutex::unlock() + { + std::lock_guard lock(_mutex); + if(!_list.empty()) + { + CoMutexInfo &info= _list.front(); + info._sched->put(info._coroId); + _list.pop_front(); + } + else + { + _slck.unlock(); + } + } +} From 36574d9633d0015c3e518cd9822fd6d14b4cd167 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Mon, 25 Mar 2024 14:18:02 +0800 Subject: [PATCH 02/44] fix: free applicationCommunicator when application terminate --- servant/libservant/Application.cpp | 9 +++++ servant/libservant/Communicator.cpp | 49 ++++++++++----------------- servant/servant/Communicator.h | 13 ++++--- servant/servant/CommunicatorFactory.h | 4 +++ 4 files changed, 37 insertions(+), 38 deletions(-) diff --git a/servant/libservant/Application.cpp b/servant/libservant/Application.cpp index e7e24578..0c9c7b2f 100644 --- a/servant/libservant/Application.cpp +++ b/servant/libservant/Application.cpp @@ -273,9 +273,18 @@ void Application::terminate() _masterSlaveCheckThread->join(); } + std::this_thread::sleep_for(std::chrono::milliseconds(100)); //稍微休息一下, 让当前处理包能够回复 _epollServer->terminate(); + + //结束application的通信器 + if(_applicationCommunicator && _applicationCommunicator.get() != _communicator.get()) + { + _applicationCommunicator->terminate(); + } + + _epollServer = nullptr; } } diff --git a/servant/libservant/Communicator.cpp b/servant/libservant/Communicator.cpp index 9ab47751..28fa1231 100644 --- a/servant/libservant/Communicator.cpp +++ b/servant/libservant/Communicator.cpp @@ -89,7 +89,7 @@ bool Communicator::isTerminating() map Communicator::getServantProperty(const string &sObj) { - TC_LockT lock(*this); + TC_LockT lock(_recMutex); auto it = _objInfo.find(sObj); if(it != _objInfo.end()) @@ -102,14 +102,14 @@ map Communicator::getServantProperty(const string &sObj) void Communicator::setServantProperty(const string &sObj, const string& name, const string& value) { - TC_LockT lock(*this); + TC_LockT lock(_recMutex); _objInfo[sObj][name] = value; } string Communicator::getServantProperty(const string &sObj, const string& name) { - TC_LockT lock(*this); + TC_LockT lock(_recMutex); auto it = _objInfo.find(sObj); if(it != _objInfo.end()) @@ -165,7 +165,7 @@ shared_ptr Communicator::newClientSSL(const string & objName) void Communicator::setProperty(TC_Config& conf, const string& domain/* = CONFIG_ROOT_PATH*/) { - TC_LockT lock(*this); + TC_LockT lock(_recMutex); conf.getDomainMap(domain, _properties); setTraceParam(); @@ -220,7 +220,7 @@ void Communicator::notifyCommunicatorEpollStart() void Communicator::initialize() { - TC_LockT lock(*this); + TC_LockT lock(_recMutex); //两次保护 if (_initialized) @@ -445,7 +445,7 @@ void Communicator::initialize() void Communicator::setProperty(const map& properties) { - TC_LockT lock(*this); + TC_LockT lock(_recMutex); _properties = properties; @@ -454,7 +454,7 @@ void Communicator::setProperty(const map& properties) void Communicator::setProperty(const string& name, const string& value) { - TC_LockT lock(*this); + TC_LockT lock(_recMutex); _properties[name] = value; @@ -463,7 +463,7 @@ void Communicator::setProperty(const string& name, const string& value) string Communicator::getProperty(const string& name, const string& dft/* = ""*/) { - TC_LockT lock(*this); + TC_LockT lock(_recMutex); map::iterator it = _properties.find(name); @@ -487,12 +487,6 @@ vector> Communicator::getAllCommunicatorEpoll() void Communicator::forEachSchedCommunicatorEpoll(const std::function &)>& func) { -// TC_LockT lock(_schedMutex); -// for(const auto& it : _schedCommunicatorEpoll) -// { -// func(it.second); -// } - for(const auto& it : _schedCommunicatorEpoll) { if(it) @@ -514,12 +508,6 @@ shared_ptr Communicator::createSchedCommunicatorEpoll(size_t _schedCommunicatorEpoll[netThreadSeq] = communicatorEpoll; -// { -// TC_LockT lock(_schedMutex); -// -// _schedCommunicatorEpoll.insert(std::make_pair(netThreadSeq, communicatorEpoll)); -// } - return communicatorEpoll; } @@ -530,14 +518,7 @@ void Communicator::eraseSchedCommunicatorEpoll(size_t netThreadSeq) shared_ptr ce = _schedCommunicatorEpoll[netThreadSeq]; _schedCommunicatorEpoll[netThreadSeq].reset(); -// { -// TC_LockT lock(_schedMutex); -// -// ce = _schedCommunicatorEpoll[netThreadSeq]; -// -// _schedCommunicatorEpoll.erase(netThreadSeq); -// } -// + if(ce) { ce->terminate(); @@ -637,7 +618,7 @@ void Communicator::terminate() if (_terminating) return; - TC_LockT lock(*this); + TC_LockT lock(_recMutex); _terminating = true; @@ -650,7 +631,10 @@ void Communicator::terminate() { _statReport->terminate(); - _statReport->getThreadControl().join(); + if(_statReport->joinable()) + { + _statReport->join(); + } } for (size_t i = 0; i < _communicatorEpoll.size(); ++i) @@ -720,7 +704,10 @@ void Communicator::terminate() } _communicatorEpoll.clear(); - _schedCommunicatorEpoll.clear(); + for(auto it : _schedCommunicatorEpoll) + { + it.reset(); + } } diff --git a/servant/servant/Communicator.h b/servant/servant/Communicator.h index 0d184238..b2742f29 100644 --- a/servant/servant/Communicator.h +++ b/servant/servant/Communicator.h @@ -119,7 +119,7 @@ class TC_OpenSSL; /** * 通信器,用于创建和维护客户端proxy */ -class SVT_DLL_API Communicator : public TC_HandleBase, public TC_ThreadRecMutex +class SVT_DLL_API Communicator : public TC_HandleBase { public: /** @@ -495,6 +495,11 @@ class SVT_DLL_API Communicator : public TC_HandleBase, public TC_ThreadRecMutex */ bool _terminating; + /** + * 通信器用到的rec锁 + */ + TC_ThreadRecMutex _recMutex; + /** * 客户端的属性配置 */ @@ -523,14 +528,8 @@ class SVT_DLL_API Communicator : public TC_HandleBase, public TC_ThreadRecMutex /** * 私有网络线程, 会动态变化 */ -// unordered_map> _schedCommunicatorEpoll; vector> _schedCommunicatorEpoll; //MAX_CLIENT_NOTIFYEVENT_NUM -// /** -// * 操作通信器的锁 -// */ -// TC_SpinLock _schedMutex; - /** * 锁 */ diff --git a/servant/servant/CommunicatorFactory.h b/servant/servant/CommunicatorFactory.h index 0abecef5..5a4dd644 100644 --- a/servant/servant/CommunicatorFactory.h +++ b/servant/servant/CommunicatorFactory.h @@ -81,6 +81,10 @@ class CommunicatorFactory : public TC_Singleton, public TC_ return it->second; } + if(it->second->isTerminating()) + { + it->second = new Communicator(conf); + } string s = ""; it->second->setProperty(conf); From f17041cab296eecfe329051a92428c1e9f879b07 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Mon, 25 Mar 2024 15:52:52 +0800 Subject: [PATCH 03/44] fix tc_port SigInfo use NoDestroyLifetime TC_Singleton fix RemoteTimeLogger not init twice --- servant/libservant/RemoteLogger.cpp | 14 +++++-------- unit-test/rpc/test_close.cpp | 4 ++-- util/include/util/tc_port.h | 6 +++--- util/src/tc_port.cpp | 32 ++++++++++++++--------------- 4 files changed, 26 insertions(+), 30 deletions(-) diff --git a/servant/libservant/RemoteLogger.cpp b/servant/libservant/RemoteLogger.cpp index 00b18d63..97712396 100644 --- a/servant/libservant/RemoteLogger.cpp +++ b/servant/libservant/RemoteLogger.cpp @@ -314,17 +314,9 @@ void RemoteTimeWriteT::operator()(ostream &of, const deque 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; -// } vector v; size_t len = 0; @@ -338,7 +330,6 @@ void RemoteTimeWriteT::operator()(ostream &of, const deque ++it; //每次最多同步len条 -// if(v.size() >= len) if(len > 5*1024*1024 || v.size() > 200) { //>5M 或超过200条 就要传输了! @@ -740,6 +731,11 @@ void RemoteTimeLogger::initTimeLogger(TimeLogger *pTimeLogger,const string &sApp void RemoteTimeLogger::setLogInfo(const CommunicatorPtr &comm, const string &obj, const string &sApp, const string &sServer, const string &sLogpath, const string& setdivision, const bool &bLogStatReport) { + if(_comm) + { + //已经初始化了 + return; + } _app = sApp; _server = sServer; _logpath = sLogpath; diff --git a/unit-test/rpc/test_close.cpp b/unit-test/rpc/test_close.cpp index 515ec80d..9006f74b 100755 --- a/unit-test/rpc/test_close.cpp +++ b/unit-test/rpc/test_close.cpp @@ -50,8 +50,8 @@ TEST_F(HelloTest, prxCloseInCoroutine) prx->tars_close(); - TC_Common::msleep(10); - EXPECT_EQ(HelloImp::_current.size(), 0); + TC_Common::msleep(100); + EXPECT_LE(HelloImp::_current.size(), 2); stopServer(ws); diff --git a/util/include/util/tc_port.h b/util/include/util/tc_port.h index d88d45d6..67558a86 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -3,7 +3,7 @@ #include "util/tc_platform.h" #include "util/tc_ex.h" - +#include "util/tc_singleton.h" #if TARGET_PLATFORM_LINUX || TARGET_PLATFORM_IOS #include @@ -355,7 +355,7 @@ class TC_Port static BOOL WINAPI HandlerRoutine(DWORD dwCtrlType); #endif - struct SigInfo + struct SigInfo : public TC_Singleton { std::mutex _mutex; @@ -364,7 +364,7 @@ class TC_Port std::atomic _callbackId{0}; }; - static shared_ptr _sigInfo; +// static SigInfo *_sigInfo; }; } diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index 604c9bca..042ba8cf 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -861,23 +861,23 @@ int64_t TC_Port::forkExec(const string& sExePath, const string& sPwdPath, const #endif } -shared_ptr TC_Port::_sigInfo = std::make_shared(); +//shared_ptr TC_Port::SigInfo::getInstance() = std::make_shared(); size_t TC_Port::registerSig(int sig, std::function callback) { - std::lock_guard lock(_sigInfo->_mutex); + std::lock_guard lock(SigInfo::getInstance()->_mutex); - auto it = _sigInfo->_callbacks.find(sig); + auto it = SigInfo::getInstance()->_callbacks.find(sig); - if(it == _sigInfo->_callbacks.end()) + if(it == SigInfo::getInstance()->_callbacks.end()) { //没有注册过, 才注册 registerSig(sig); } - size_t id = ++_sigInfo->_callbackId; + size_t id = ++SigInfo::getInstance()->_callbackId; - _sigInfo->_callbacks[sig][id] = callback; + SigInfo::getInstance()->_callbacks[sig][id] = callback; return id; } @@ -885,12 +885,12 @@ size_t TC_Port::registerSig(int sig, std::function callback) void TC_Port::unregisterSig(int sig, size_t id) { //注意_sigInfo是全局静态的, 有可能已经析构了, 需要特殊判断一下! - if(_sigInfo && _sigInfo.use_count() > 0) +// if(SigInfo::getInstance() && SigInfo::getInstance().use_count() > 0) { - std::lock_guard lock(_sigInfo->_mutex); - auto it = _sigInfo->_callbacks.find(sig); + std::lock_guard lock(SigInfo::getInstance()->_mutex); + auto it = SigInfo::getInstance()->_callbacks.find(sig); - if(it != _sigInfo->_callbacks.end()) + if(it != SigInfo::getInstance()->_callbacks.end()) { it->second.erase(id); } @@ -950,10 +950,10 @@ void TC_Port::sighandler( int sig_no ) unordered_map> data; { - std::lock_guard lock(_sigInfo->_mutex); + std::lock_guard lock(SigInfo::getInstance()->_mutex); - auto it = TC_Port::_sigInfo->_callbacks.find(sig_no); - if (it != TC_Port::_sigInfo->_callbacks.end()) + auto it = SigInfo::getInstance()->_callbacks.find(sig_no); + if (it != SigInfo::getInstance()->_callbacks.end()) { data = it->second; } @@ -980,10 +980,10 @@ BOOL WINAPI TC_Port::HandlerRoutine(DWORD dwCtrlType) unordered_map> data; { - std::lock_guard lock(_sigInfo->_mutex); + std::lock_guard lock(SigInfo::getInstance()->_mutex); - auto it = _sigInfo->_callbacks.find(dwCtrlType); - if (it != _sigInfo->_callbacks.end()) + auto it = SigInfo::getInstance()->_callbacks.find(dwCtrlType); + if (it != SigInfo::getInstance()->_callbacks.end()) { data = it->second; } From 764dc84125492f8f86989eafc87f3824c084d5f5 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Mon, 25 Mar 2024 18:03:02 +0800 Subject: [PATCH 04/44] fix destroyApp not call bug --- servant/libservant/Application.cpp | 12 +++++------- unit-test/server/HelloServer.cpp | 1 - unit-test/server/WinServer.cpp | 2 ++ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/servant/libservant/Application.cpp b/servant/libservant/Application.cpp index 0c9c7b2f..2239fa94 100644 --- a/servant/libservant/Application.cpp +++ b/servant/libservant/Application.cpp @@ -161,11 +161,11 @@ Application::Application() Application::~Application() { - if(_epollServer) - { - _epollServer->terminate(); - _epollServer = nullptr; - } +// if(_epollServer) +// { +// _epollServer->terminate(); +// _epollServer = nullptr; +// } #if TARGET_PLATFORM_WINDOWS WSACleanup(); #endif @@ -283,8 +283,6 @@ void Application::terminate() { _applicationCommunicator->terminate(); } - - _epollServer = nullptr; } } diff --git a/unit-test/server/HelloServer.cpp b/unit-test/server/HelloServer.cpp index c565d071..07506980 100755 --- a/unit-test/server/HelloServer.cpp +++ b/unit-test/server/HelloServer.cpp @@ -109,7 +109,6 @@ void HelloServer::destroyApp() delete pushThread; } -// LOG_CONSOLE_DEBUG << endl; // ProfilerStop(); } diff --git a/unit-test/server/WinServer.cpp b/unit-test/server/WinServer.cpp index b99090fe..d9c56389 100644 --- a/unit-test/server/WinServer.cpp +++ b/unit-test/server/WinServer.cpp @@ -28,6 +28,8 @@ WinServer::initialize() void WinServer::destroyApp() { + LOG_CONSOLE_DEBUG << endl; + } void WinServer::run() From 3a87960cfff843a12eeabd38cec6b89f729befc8 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Mon, 25 Mar 2024 18:47:12 +0800 Subject: [PATCH 05/44] fix ssl compiler bug --- servant/libservant/Communicator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servant/libservant/Communicator.cpp b/servant/libservant/Communicator.cpp index 28fa1231..9f70664c 100644 --- a/servant/libservant/Communicator.cpp +++ b/servant/libservant/Communicator.cpp @@ -143,7 +143,7 @@ void Communicator::setTraceParam(const string& name) shared_ptr Communicator::newClientSSL(const string & objName) { #if TARS_SSL - TC_LockT lock(*this); + TC_LockT lock(_recMutex); auto it = _objCtx.find(objName); if(it != _objCtx.end()) From 43a2a0bd8d8ee290b059f956b1cc366e480e5f59 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Mon, 25 Mar 2024 19:19:57 +0800 Subject: [PATCH 06/44] feat: epoll server add destroyApp log --- servant/libservant/Application.cpp | 5 ----- unit-test/server/WinServer.cpp | 1 - util/src/tc_epoll_server.cpp | 1 + 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/servant/libservant/Application.cpp b/servant/libservant/Application.cpp index 2239fa94..78995cee 100644 --- a/servant/libservant/Application.cpp +++ b/servant/libservant/Application.cpp @@ -211,11 +211,6 @@ void reportRspQueue(TC_EpollServer *epollServer) } } -//void heartBeatFunc(const string& adapterName) -//{ -// TARS_KEEPALIVE(adapterName); -//} -// void Application::manualListen() { vector v = getEpollServer()->getBindAdapters(); diff --git a/unit-test/server/WinServer.cpp b/unit-test/server/WinServer.cpp index d9c56389..a010886f 100644 --- a/unit-test/server/WinServer.cpp +++ b/unit-test/server/WinServer.cpp @@ -29,7 +29,6 @@ WinServer::initialize() void WinServer::destroyApp() { LOG_CONSOLE_DEBUG << endl; - } void WinServer::run() diff --git a/util/src/tc_epoll_server.cpp b/util/src/tc_epoll_server.cpp index 691b1e80..07fb7877 100644 --- a/util/src/tc_epoll_server.cpp +++ b/util/src/tc_epoll_server.cpp @@ -2162,6 +2162,7 @@ void TC_EpollServer::waitForShutdown() } catch (exception& ex) { + error(string("destroyApp error:") + ex.what()); } } From b6369d6eb7f1af76dad074ec7005132f06cc1862 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Mon, 25 Mar 2024 20:49:25 +0800 Subject: [PATCH 07/44] fix tc_ex using namespace std outside tars --- util/include/util/tc_ex.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/include/util/tc_ex.h b/util/include/util/tc_ex.h index f2801d19..bc49835f 100644 --- a/util/include/util/tc_ex.h +++ b/util/include/util/tc_ex.h @@ -20,10 +20,11 @@ #include #include +using namespace std; + namespace tars { -using namespace std; ///////////////////////////////////////////////// /** * @file tc_ex.h From 76e131fde1ecf08c022283de3bffff1815459c2b Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 3 Apr 2024 19:40:55 +0800 Subject: [PATCH 08/44] feat: tc_option parseString use static feat: tc_port kill add return value --- util/include/util/tc_option.h | 14 ++++++++------ util/include/util/tc_port.h | 3 ++- util/src/tc_port.cpp | 22 ++++++++++++++-------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/util/include/util/tc_option.h b/util/include/util/tc_option.h index c393b929..8501eedc 100644 --- a/util/include/util/tc_option.h +++ b/util/include/util/tc_option.h @@ -131,6 +131,14 @@ class TC_Option */ vector& getSingle(); + + /** + * @brief 将命令行分割成参数数组, 使用" \t"分割, 如果碰到"则不分割 + * @param input + * @return + */ + static std::vector parseString(const std::string& input); + protected: /** @@ -143,12 +151,6 @@ 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/include/util/tc_port.h b/util/include/util/tc_port.h index 67558a86..e062d097 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -210,8 +210,9 @@ class TC_Port /** * kill某个pid的进程 * @param pid + * @return int, 0: 成功, -1: pid不存在 */ - static void kill(int64_t pid); + static int kill(int64_t pid); /** * 运行一个脚本 diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index 042ba8cf..69295a89 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -275,20 +275,26 @@ string TC_Port::getCwd() return currentDirectory; } -void TC_Port::kill(int64_t pid) +int TC_Port::kill(int64_t pid) { #if TARGET_PLATFORM_WINDOWS HANDLE hProcess = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid); - if (hProcess == NULL) - { - return; - } + if (hProcess == NULL) + { + return -1; + } - ::TerminateProcess(hProcess, 0); + ::TerminateProcess(hProcess, 0); - CloseHandle(hProcess); + CloseHandle(hProcess); + return 0; #else - ::kill(static_cast(pid), SIGKILL); + int ret = ::kill(static_cast(pid), SIGKILL); + if(ret != 0) + { + return -1; + } + return 0; #endif } From 5a8950ae54a02dd8ccc22b4a552a5a83715139e2 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Fri, 5 Apr 2024 12:07:10 +0800 Subject: [PATCH 09/44] feat: tc_port add check pid alive --- util/include/util/tc_port.h | 21 ++++++++++++++------- util/src/tc_port.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/util/include/util/tc_port.h b/util/include/util/tc_port.h index e062d097..b021364e 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -207,13 +207,6 @@ class TC_Port */ static string getCwd(); - /** - * kill某个pid的进程 - * @param pid - * @return int, 0: 成功, -1: pid不存在 - */ - static int kill(int64_t pid); - /** * 运行一个脚本 * @param cmd @@ -247,6 +240,20 @@ class TC_Port static void closeAllFileDescriptors(); #endif + /** + * kill某个pid的进程 + * @param pid + * @return int, 0: 成功, -1: pid不存在 + */ + static int kill(int64_t pid); + + /** + * pid是否存在 + * @param pid + * @return int, 0: pid存在, -1: pid不存在 + */ + static int alive(int64_t pid); + /** * 返回完整命令行参数, 如果pid不存在, 则返回为空 * @param pid diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index 69295a89..61526350 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -290,10 +290,37 @@ int TC_Port::kill(int64_t pid) return 0; #else int ret = ::kill(static_cast(pid), SIGKILL); + if(ret != 0 && errno != ESRCH && errno != ENOENT) + { + return -1; + } + else + { + waitpid(pid, NULL, WNOHANG); + } + + return 0; +#endif +} + +int TC_Port::alive(int64_t pid) +{ +#if TARGET_PLATFORM_WINDOWS + HANDLE hProcess = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid); + if (hProcess == NULL) + { + return -1; + } + + CloseHandle(hProcess); + return 0; +#else + int ret = ::kill(static_cast(pid), 0); if(ret != 0) { return -1; } + return 0; #endif } From 97c7a87f0951ce4358cfe8333b7dee637da1bfea Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Sun, 7 Apr 2024 09:00:30 +0800 Subject: [PATCH 10/44] fix tc_port linux compiler --- util/src/tc_port.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/util/src/tc_port.cpp b/util/src/tc_port.cpp index 61526350..9be859cd 100755 --- a/util/src/tc_port.cpp +++ b/util/src/tc_port.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #else #pragma comment(lib, "ws2_32.lib") From 4b508bf637e4fb0368ae81dcfa2150d815f0aa64 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Mon, 8 Apr 2024 20:38:31 +0800 Subject: [PATCH 11/44] update v3.0.20 --- Changelist-3.x.md | 28 ++++++++++++++++++++++++++++ cmake/Common.cmake | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Changelist-3.x.md b/Changelist-3.x.md index 2c9184ca..af138b2c 100644 --- a/Changelist-3.x.md +++ b/Changelist-3.x.md @@ -1,3 +1,31 @@ +# v3.0.20 20240408 +## en +- fix: tc_ex using namespace std outside tars +- fix: tc_port SigInfo use NoDestroyLifetime TC_Singleton +- fix: RemoteTimeLogger not init twice +- fix: free applicationCommunicator when application terminate +- fix: servantprx/adapterprx tars_set_push_callback nullptr protected +- fix: unit-test use tarsmock +- fix: fix remote log sync bug when log size too big +- fix: communicator _schedCommunicatorEpoll create use array +- fix: tc_port exec out buff size limit +- feat: tc_port add check pid alive +- feat: tc_option parseString use static +- feat: tc_port kill add return value +- feat: tc_port add freopen +- feat: epoll server destroyApp not call bug and destroyApp log +- feat: add tarsmock to simulate tars framework +- feat: tc_port add getCommandLine/getPidsByCmdline +- feat: tc_socket: getLocalHosts support withLoopIp +- feat: tars-tools.cmake add CMAKE_CXX_FLAGS_RELEASE&CMAKE_CXX_FLAGS_DEBUG +- feat: unit-test support TARS_SHARED_PTR +- feat: support build_with_std_shared_ptr for python +- feat: Application add getRemoteConfig +- feat: tc_mysql support mysql 8.0 +- feat: EndpointInfo add vectorEndpointFToStr/strToVectorEndpointF/toNodeEndpointF to support multi network interfaces +- feat: fix tc_socket getLocalHosts support ipv4 +- feat: EndpointInfo add toEndpointFs + # v3.0.19 20240202 ## en diff --git a/cmake/Common.cmake b/cmake/Common.cmake index d6c3c9ae..2bdeed60 100755 --- a/cmake/Common.cmake +++ b/cmake/Common.cmake @@ -1,6 +1,6 @@ -set(TARS_VERSION "3.0.19") +set(TARS_VERSION "3.0.20") add_definitions(-DTARS_VERSION="${TARS_VERSION}") set(CMAKE_VERBOSE_MAKEFILE off) From eed1bf4becc4f20b0d372ac14ba62468dae18900 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 9 Apr 2024 15:45:06 +0800 Subject: [PATCH 12/44] fix tc_loop_queue crash in arm64 --- util/include/util/tc_loop_queue.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util/include/util/tc_loop_queue.h b/util/include/util/tc_loop_queue.h index 27b52cd5..cf189f0e 100644 --- a/util/include/util/tc_loop_queue.h +++ b/util/include/util/tc_loop_queue.h @@ -219,8 +219,10 @@ class TC_LoopQueue T * _p; size_t _iCapacity; size_t _iCapacitySub; - size_t _iBegin; - size_t _iEnd; + std::atomic _iBegin; + std::atomic _iEnd; +// size_t _iBegin; +// size_t _iEnd; }; } From 2880754a790c022b7304df73029d85acbdc07029 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Sun, 14 Apr 2024 19:42:30 +0800 Subject: [PATCH 13/44] fix destroyApp not call bug --- servant/libservant/AdminServant.cpp | 18 ++++----------- unit-test/rpc/test_admin.cpp | 35 ++++++++++++++++++++++++++++- unit-test/server/WinServer.cpp | 2 +- unit-test/server/WinServer.h | 3 +++ 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/servant/libservant/AdminServant.cpp b/servant/libservant/AdminServant.cpp index f024cbfd..108019fb 100644 --- a/servant/libservant/AdminServant.cpp +++ b/servant/libservant/AdminServant.cpp @@ -44,20 +44,10 @@ 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) - { - return; - } - - ::TerminateProcess(hProcess, 0); -#else - kill(getpid(), SIGINT); //通过给自己发信号的方式结束, 避免处理线程结束时自己join自己 - // Application::terminate(); -#endif + std::thread th([=]{ + _application->terminate(); + }); + th.detach(); } string AdminServant::notify(const string &command, CurrentPtr current) diff --git a/unit-test/rpc/test_admin.cpp b/unit-test/rpc/test_admin.cpp index 549cecf0..45d44a9a 100755 --- a/unit-test/rpc/test_admin.cpp +++ b/unit-test/rpc/test_admin.cpp @@ -82,7 +82,7 @@ TEST_F(HelloTest, testAdmin) EXPECT_STREQ(errorcmd.c_str(), ""); string normalcmd = adminFPrx->notify("AdminCmdNormalTest returnMark"); - EXPECT_STREQ(normalcmd.c_str(), "[notify servant object num:1]\n[1]:returnMark AdminCmdNormalTest success!\n"); + EXPECT_STREQ(normalcmd.c_str(), "[notify servant object num:1]\n[1]:return Mark AdminCmdNormalTest success!\n"); string normaldeletecmd = adminFPrx->notify("DeletePrefixCmd"); EXPECT_STREQ(normaldeletecmd.c_str(), "[notify servant object num:1]\n[1]:Delete success!\n"); @@ -91,3 +91,36 @@ TEST_F(HelloTest, testAdmin) tarsMockUtil.stopFramework(); } +TEST_F(HelloTest, testAdminShutdown) +{ + TarsMockUtil tarsMockUtil; + tarsMockUtil.startFramework(); + ConfigImp::setConfigFile("test.conf", "test-content"); + + WinServer ws; + startServer(ws, WIN_CONFIG()); + + CommunicatorPtr c = ws.getApplicationCommunicator(); + + string adminObj = "AdminObj@" + getLocalEndpoint(WIN_CONFIG()).toString(); + + AdminFPrx adminFPrx = c->stringToProxy(adminObj); + + adminFPrx->tars_ping(); + + try + { + adminFPrx->tars_set_timeout(2000)->shutdown(); + TC_Common::msleep(500); + } + catch(exception &ex) + { + LOG_CONSOLE_DEBUG << ex.what() << endl; + } + + EXPECT_EQ(ws._destroyApp, true); + + stopServer(ws); + tarsMockUtil.stopFramework(); + +} \ No newline at end of file diff --git a/unit-test/server/WinServer.cpp b/unit-test/server/WinServer.cpp index a010886f..cd226551 100644 --- a/unit-test/server/WinServer.cpp +++ b/unit-test/server/WinServer.cpp @@ -28,7 +28,7 @@ WinServer::initialize() void WinServer::destroyApp() { - LOG_CONSOLE_DEBUG << endl; + _destroyApp = true; } void WinServer::run() diff --git a/unit-test/server/WinServer.h b/unit-test/server/WinServer.h index 4f7dcb00..1ef9b6a8 100644 --- a/unit-test/server/WinServer.h +++ b/unit-test/server/WinServer.h @@ -31,6 +31,9 @@ class WinServer : public Application, public TC_Thread protected: virtual void run(); +public: + bool _destroyApp = false; + }; //////////////////////////////////////////// From c8b8201273d57f006af805feb05677f991b4e731 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 16 Apr 2024 15:10:15 +0800 Subject: [PATCH 14/44] fix objectproxy crash when msg process finish before log --- servant/libservant/ObjectProxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servant/libservant/ObjectProxy.cpp b/servant/libservant/ObjectProxy.cpp index f7f1dae5..2ad0ec9b 100755 --- a/servant/libservant/ObjectProxy.cpp +++ b/servant/libservant/ObjectProxy.cpp @@ -282,8 +282,8 @@ void ObjectProxy::doInvokeException(ReqMessage * msg) } else { - _communicatorEpoll->pushAsyncThreadQueue(msg); TLOGERROR("[ObjectProxy::doInvokeException " << msg->request.sServantName << ":" << msg->request.sFuncName << ", ret: " << msg->response->iRet << endl); + _communicatorEpoll->pushAsyncThreadQueue(msg); } } else From a396ea844a1d831c788e9958ee0ba1850c54524b Mon Sep 17 00:00:00 2001 From: edisenwang <114474163@qq.com> Date: Sat, 20 Apr 2024 15:34:11 +0800 Subject: [PATCH 15/44] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E5=BC=95=E8=B5=B7=E7=9A=84=E5=A0=86=E5=86=85=E5=AD=98=E6=B3=84?= =?UTF-8?q?=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/src/tc_gzip.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/src/tc_gzip.cpp b/util/src/tc_gzip.cpp index a77b090a..2f0f441b 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 + 1]; + char *out = new char[destLen + 1 + 8]; stream.next_out = (Bytef *)out; stream.avail_out = destLen; From 8b0d9143f30c4bf5705139135e27c27e3d73d91b Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Mon, 22 Apr 2024 11:48:17 +0800 Subject: [PATCH 16/44] servant prx suppport keepAliveCallback --- servant/libservant/AdapterProxy.cpp | 39 +++++++++++++++++------------ servant/servant/AppProtocol.h | 7 ++++++ servant/servant/ServantProxy.h | 2 ++ 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/servant/libservant/AdapterProxy.cpp b/servant/libservant/AdapterProxy.cpp index 1a79784e..769b6d71 100755 --- a/servant/libservant/AdapterProxy.cpp +++ b/servant/libservant/AdapterProxy.cpp @@ -1055,28 +1055,35 @@ void AdapterProxy::doKeepAlive() TLOGTARS("[AdapterProxy::doKeepAlive, " << _objectProxy->name() << ", " << _trans->getConnectionString() << "]" << endl); ReqMessage *msg = new ReqMessage(); -// ServantProxyCallbackPtr callback = new PingCallback(); - ServantProxyCallbackPtr callback (new PingCallback()); - callback->setServantPrx(_objectProxy->getServantProxy()); - msg->init(ReqMessage::ASYNC_CALL, _objectProxy->getServantProxy()); - msg->callback = callback; + if(_objectProxy->getRootServantProxy()->tars_get_protocol().keepAliveCallback) + { + _objectProxy->getRootServantProxy()->tars_get_protocol().keepAliveCallback(_objectProxy->getServantProxy()); + } + else + { + msg->init(ReqMessage::ASYNC_CALL, _objectProxy->getServantProxy()); + + ServantProxyCallbackPtr callback(new PingCallback()); + callback->setServantPrx(_objectProxy->getServantProxy()); - msg->request.iVersion = TARSVERSION; - msg->request.cPacketType = TARSNORMAL; - msg->request.sFuncName = "tars_ping"; - msg->request.sServantName = _objectProxy->name(); + msg->callback = callback; - msg->request.iTimeout = ServantProxy::DEFAULT_ASYNCTIMEOUT; + msg->request.iVersion = TARSVERSION; + msg->request.cPacketType = TARSNORMAL; + msg->request.sFuncName = "tars_ping"; + msg->request.sServantName = _objectProxy->name(); + msg->request.iTimeout = ServantProxy::DEFAULT_ASYNCTIMEOUT; - msg->proxy = _objectProxy->getServantProxy(); - msg->response->iRet = TARSSERVERUNKNOWNERR; + msg->proxy = _objectProxy->getServantProxy(); + msg->response->iRet = TARSSERVERUNKNOWNERR; - //调用发起时间 - msg->iBeginTime = TNOWMS; - msg->pObjectProxy = _objectProxy; + //调用发起时间 + msg->iBeginTime = TNOWMS; + msg->pObjectProxy = _objectProxy; - invoke(msg); + invoke(msg); + } } diff --git a/servant/servant/AppProtocol.h b/servant/servant/AppProtocol.h index 3b6692c8..ee2a24dd 100644 --- a/servant/servant/AppProtocol.h +++ b/servant/servant/AppProtocol.h @@ -25,6 +25,7 @@ #include "tup/tup.h" #include "servant/BaseF.h" #include "util/tc_network_buffer.h" +#include "servant/Global.h" using namespace std; using namespace tup; @@ -319,6 +320,12 @@ class ProxyProtocol request_protocol requestFunc; response_protocol responseFunc; + + /** + * 开启openalive, 如果keepAliveCallback未设置则直接发包, 如果keepAliveCallback设置, 则回调(不再发tars_ping) + * 如果是非tars协议如果开启openalive, 则需要设置keepAliveCallback, 自己发包 + */ + std::function keepAliveCallback; }; ////////////////////////////////////////////////////////////////////// diff --git a/servant/servant/ServantProxy.h b/servant/servant/ServantProxy.h index 90b8fba4..e0599e98 100644 --- a/servant/servant/ServantProxy.h +++ b/servant/servant/ServantProxy.h @@ -1476,6 +1476,8 @@ class ServantProxy : public TC_HandleBase, public TC_ThreadMutex * 对应通信内部的moduleName */ string _moduleName; + + }; } #endif From e96546f23f82bcdb63b7bad9102fd84fa98af719 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Mon, 22 Apr 2024 16:54:42 +0800 Subject: [PATCH 17/44] fix doKeepAlive for servant proxy --- servant/libservant/CommunicatorEpoll.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servant/libservant/CommunicatorEpoll.cpp b/servant/libservant/CommunicatorEpoll.cpp index bf9eed71..54a0d17a 100755 --- a/servant/libservant/CommunicatorEpoll.cpp +++ b/servant/libservant/CommunicatorEpoll.cpp @@ -453,7 +453,7 @@ void CommunicatorEpoll::doKeepAlive() for(size_t i = 0; i < getObjNum(); ++i) { - if(getObjectProxy(i)->getServantProxy()->tars_open_keepalive()) + if(getObjectProxy(i)->getRootServantProxy()->tars_open_keepalive()) { getObjectProxy(i)->doKeepAlive(); } From 68531876e937776b8a8a65339d4bb1df190b8b00 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 21 May 2024 13:34:36 +0800 Subject: [PATCH 18/44] fix tc_socket getLocalHosts bug in linux --- util/src/tc_socket.cpp | 81 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/util/src/tc_socket.cpp b/util/src/tc_socket.cpp index 79fe975b..6a7d1c37 100755 --- a/util/src/tc_socket.cpp +++ b/util/src/tc_socket.cpp @@ -893,6 +893,86 @@ void TC_Socket::createPipe(int fds[2], bool bBlock) THROW_EXCEPTION_SYSCODE(TC_Socket_Exception, "[TC_Socket::createPipe] error"); } +#if TARGET_PLATFORM_LINUX||TARGET_PLATFORM_IOS + +vector TC_Socket::getLocalHosts(int domain, bool withLoopIp) +{ + 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) + { + char sAddr[INET_ADDRSTRLEN] = "\0"; + + 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) + { + inet_ntop(AF_INET, &(*addr).sin_addr, sAddr, sizeof(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))) + { + inet_ntop(AF_INET6, &(*addr).sin6_addr, sAddr, sizeof(sAddr)); + } + } + else + { + continue; + } + + if(withLoopIp || (TC_Port::strcasecmp(sAddr,"127.0.0.1") != 0 && TC_Port::strcasecmp(sAddr, "::1") != 0)) + { + result.push_back(sAddr); + } + } + + free(ifc.ifc_buf); + + return result; +} +#else + vector TC_Socket::getLocalHosts(int domain, bool withLoopIp) { vector hosts; @@ -937,6 +1017,7 @@ vector TC_Socket::getLocalHosts(int domain, bool withLoopIp) return hosts; } +#endif bool TC_Socket::isPending() { From 37534fabf2ff7248144635122feac0b413918a67 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 11 Jun 2024 22:33:11 +0800 Subject: [PATCH 19/44] fix mac TC_Socket::getLocalHosts bug --- util/src/tc_socket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/src/tc_socket.cpp b/util/src/tc_socket.cpp index 6a7d1c37..af5b58c6 100755 --- a/util/src/tc_socket.cpp +++ b/util/src/tc_socket.cpp @@ -893,7 +893,7 @@ void TC_Socket::createPipe(int fds[2], bool bBlock) THROW_EXCEPTION_SYSCODE(TC_Socket_Exception, "[TC_Socket::createPipe] error"); } -#if TARGET_PLATFORM_LINUX||TARGET_PLATFORM_IOS +#if TARGET_PLATFORM_LINUX vector TC_Socket::getLocalHosts(int domain, bool withLoopIp) { From 5deae596045f7c2bc0953bf76be09c26f25907e5 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 18 Jun 2024 15:22:02 +0800 Subject: [PATCH 20/44] fix tars2cpp compiler warning when field in struct is float or double --- tools/tars2cpp/tars2cpp.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/tars2cpp/tars2cpp.cpp b/tools/tars2cpp/tars2cpp.cpp index 5c714f67..2b9a34ba 100755 --- a/tools/tars2cpp/tars2cpp.cpp +++ b/tools/tars2cpp/tars2cpp.cpp @@ -362,14 +362,25 @@ string Tars2Cpp::writeTo(const TypeIdPtr& pPtr) const if (mPtr || vPtr) { - s << TAB << "if (" << pPtr->getId() << ".size() > 0)" << endl; + s << TAB << "if (!" << pPtr->getId() << ".empty())" << endl; } else { //bool类型, 都传输, 为了避免之前调整bool缺省值的bug if(!(bPtr && bPtr->kind() == Builtin::KindBool)) { - s << TAB << "if (" << pPtr->getId() << " != " << sDefault << ")" << endl; + if(bPtr->kind() == Builtin::KindFloat) + { + s << TAB << "if (!tars::TC_Common::equal(" << pPtr->getId() << ", (float)" << sDefault << "))" << endl; + } + else if(bPtr->kind() == Builtin::KindDouble) + { + s << TAB << "if (!tars::TC_Common::equal(" << pPtr->getId() << ", (double)" << sDefault << "))" << endl; + } + else + { + s << TAB << "if (" << pPtr->getId() << " != " << sDefault << ")" << endl; + } } else { From 96b055218ce67aa947684050711835ed52b7b4fa Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 20 Jun 2024 14:17:15 +0800 Subject: [PATCH 21/44] fix tarsnode create ts use import from assert, no require --- tools/tars2node/gen_proxy_ts.cpp | 2 +- tools/tars2node/gen_server_ts.cpp | 2 +- tools/tars2node/gen_ts.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/tars2node/gen_proxy_ts.cpp b/tools/tars2node/gen_proxy_ts.cpp index 79e2e47b..faee9edd 100644 --- a/tools/tars2node/gen_proxy_ts.cpp +++ b/tools/tars2node/gen_proxy_ts.cpp @@ -434,7 +434,7 @@ bool CodeGenerator::generateTSProxy(const ContextPtr &cPtr) sstr << "/// " << endl; if (bNeedAssert) { - sstr << TAB << "import assert = require(\"assert\");" << endl; + sstr << TAB << "import assert from \"assert\";" << endl; } if (bNeedStream) { diff --git a/tools/tars2node/gen_server_ts.cpp b/tools/tars2node/gen_server_ts.cpp index f0317a84..8681ea0b 100644 --- a/tools/tars2node/gen_server_ts.cpp +++ b/tools/tars2node/gen_server_ts.cpp @@ -464,7 +464,7 @@ bool CodeGenerator::generateTSServer(const ContextPtr &pPtr) str << "/// " << endl; if (bNeedAssert) { - str << TAB << "import assert = require(\"assert\");" << endl; + str << TAB << "import assert from \"assert\";" << endl; } if (bNeedStream) { diff --git a/tools/tars2node/gen_ts.cpp b/tools/tars2node/gen_ts.cpp index ac54f985..a2669e6b 100644 --- a/tools/tars2node/gen_ts.cpp +++ b/tools/tars2node/gen_ts.cpp @@ -407,7 +407,7 @@ void CodeGenerator::generateTS(const ContextPtr &pPtr) ostringstream ostr; if (bNeedAssert) { - ostr << "import assert = require(\"assert\");" << endl; + ostr << "import assert from \"assert\";" << endl; } if (bNeedStream) { From d1d5b76b14646bda1495b0e957a1fafd683b7fa5 Mon Sep 17 00:00:00 2001 From: BeyondWUXF <46481385+BeyondWUXF@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:21:11 +0800 Subject: [PATCH 22/44] Update Tars.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tars文件生成的结构体支持列表初始化构造,方便使用const &生成对象 --- servant/tup/Tars.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/servant/tup/Tars.h b/servant/tup/Tars.h index dc0279e7..4c01e559 100755 --- a/servant/tup/Tars.h +++ b/servant/tup/Tars.h @@ -360,7 +360,7 @@ namespace tars ////////////////////////////////////////////////////////////////// struct TarsStructBase { -protected: +public: TarsStructBase() {} virtual ~TarsStructBase() {} @@ -2367,4 +2367,4 @@ class TarsOutputStream : public WriterT #include "tup/TarsDisplayer.h" #endif -#endif \ No newline at end of file +#endif From 690dfa95ad79429b6ba0deda272802103159426d Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Sun, 28 Jul 2024 15:17:22 +0800 Subject: [PATCH 23/44] fix tars mock remove log --- mock/LogImp.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/mock/LogImp.cpp b/mock/LogImp.cpp index 2197b0f0..b3d887be 100755 --- a/mock/LogImp.cpp +++ b/mock/LogImp.cpp @@ -418,8 +418,6 @@ void LogImp::logger(const string &app, const string &server, const string &file, void LogImp::loggerbyInfo(const LogInfo & info,const vector & buffer,tars::TarsCurrentPtr current) { - LOG_CONSOLE_DEBUG << info.writeToJsonString() << endl; - TC_DayLogger &dl = g_globe.getLogger(info,current->getIp()); //记录日志 From ceb15410c6c933471efb51fea4b83254bfb3b219 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 1 Aug 2024 17:05:13 +0800 Subject: [PATCH 24/44] feat: tc_file copyFile support symlink, tc_port add stat --- unit-test/util/test_tc_file.cpp | 5 +++ util/include/util/tc_port.h | 10 +++++- util/src/tc_file.cpp | 62 +++++++++++++++++++++++---------- util/src/tc_port.cpp | 9 +++++ 4 files changed, 66 insertions(+), 20 deletions(-) diff --git a/unit-test/util/test_tc_file.cpp b/unit-test/util/test_tc_file.cpp index 7a75f856..f988b2d2 100644 --- a/unit-test/util/test_tc_file.cpp +++ b/unit-test/util/test_tc_file.cpp @@ -167,3 +167,8 @@ TEST_F(UtilFileTest, join) } + +TEST_F(UtilFileTest, copy) +{ + TC_File::copyFile("WsiServer/libvips-cpp.so", "WsiServer/libvips-cpp.so.tmp", true); +} diff --git a/util/include/util/tc_port.h b/util/include/util/tc_port.h index b021364e..ec33f4f8 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -136,7 +136,15 @@ class TC_Port #endif /** - * 查看文件属性 + * 查看文件属性(如果不是link, 则看到的是文件本身的属性) + * @param path + * @param buf + * @return + */ + static int stat(const char * path, stat_t * buf); + + /** + * 查看文件属性(如果是link, 这看到指向的文件) * @param path * @param buf * @return diff --git a/util/src/tc_file.cpp b/util/src/tc_file.cpp index a5e78586..b51d26f8 100644 --- a/util/src/tc_file.cpp +++ b/util/src/tc_file.cpp @@ -667,9 +667,9 @@ void TC_File::copyFile(const string &sExistFile, const string &sNewFile,bool bRe TC_File::listDirectory(sExistFile,tf, false); for(size_t i = 0; i Date: Thu, 1 Aug 2024 17:22:18 +0800 Subject: [PATCH 25/44] fix TC_File::copyFile in windows not support symlink --- util/src/tc_file.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/src/tc_file.cpp b/util/src/tc_file.cpp index b51d26f8..caf4a7be 100644 --- a/util/src/tc_file.cpp +++ b/util/src/tc_file.cpp @@ -678,7 +678,7 @@ void TC_File::copyFile(const string &sExistFile, const string &sNewFile,bool bRe else { if(bRemove) std::remove(sNewFile.c_str()); - +#if TARGET_PLATFORM_IOS || TARGET_PLATFORM_LINUX TC_Port::stat_t statbuf; if (TC_Port::lstat(sExistFile.c_str(), &statbuf) != 0) { @@ -701,6 +701,7 @@ void TC_File::copyFile(const string &sExistFile, const string &sNewFile,bool bRe } } else +#endif { std::ifstream fin(sExistFile.c_str(), ios::binary); if (!fin) From 7992aaff9c4793bf0bd851663ba150501203220f Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Sun, 4 Aug 2024 21:02:21 +0800 Subject: [PATCH 26/44] optimize ObjectProxy logs --- servant/libservant/ObjectProxy.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/servant/libservant/ObjectProxy.cpp b/servant/libservant/ObjectProxy.cpp index 2ad0ec9b..d9adf492 100755 --- a/servant/libservant/ObjectProxy.cpp +++ b/servant/libservant/ObjectProxy.cpp @@ -110,7 +110,7 @@ int ObjectProxy::loadLocator() void ObjectProxy::invoke(ReqMessage * msg) { - TLOGTARS("[ObjectProxy::invoke, objname:" << _name << ", begin...]" << endl); + TLOGTARS("[ObjectProxy::invoke, servant:" << _servantProxy->tars_full_name() << ", func:"<< msg->request.sFuncName << ", begin...]" << endl); //选择一个远程服务的Adapter来调用 AdapterProxy * pAdapterProxy = NULL; @@ -124,14 +124,14 @@ void ObjectProxy::invoke(ReqMessage * msg) assert(bRet); //把数据缓存在obj里面 - TLOGTARS("[ObjectProxy::invoke, objname:" << _name << ", select adapter proxy not valid (have not invoke reg)]" << endl); + TLOGTARS("[ObjectProxy::invoke, objname:" << _name << ", func:" << msg->request.sFuncName << ", select adapter proxy not valid (have not invoke reg)]" << endl); return; } if(!pAdapterProxy) { - TLOGERROR("[ObjectProxy::invoke, objname:"<< _name << ", selectAdapterProxy is null]"<request.sFuncName << ", selectAdapterProxy is null]"<response->iRet = TARSADAPTERNULL; @@ -150,7 +150,7 @@ void ObjectProxy::invoke(ReqMessage * msg) assert(bRet); //把数据缓存在obj里面 - TLOGTARS("[ObjectProxy::invoke, " << _name << ", select adapter proxy not connected (have not invoke reg)]" << endl); + TLOGTARS("[ObjectProxy::invoke, " << _name << ", func:"<< msg->request.sFuncName << ", select adapter proxy not connected (have not invoke reg)]" << endl); return; } From a4556deb2399a7e77cb04507bc9d00cc31587704 Mon Sep 17 00:00:00 2001 From: BeyondWUXF <46481385+BeyondWUXF@users.noreply.github.com> Date: Fri, 9 Aug 2024 18:31:45 +0800 Subject: [PATCH 27/44] Update tc_timeout_queue_new.h dataIter --- util/include/util/tc_timeout_queue_new.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/include/util/tc_timeout_queue_new.h b/util/include/util/tc_timeout_queue_new.h index 6d5f7753..733bfdf3 100644 --- a/util/include/util/tc_timeout_queue_new.h +++ b/util/include/util/tc_timeout_queue_new.h @@ -309,7 +309,7 @@ template void TC_TimeoutQueueNew::timeout(data_functor &df) if(_time.end() == it || it->first>iNow) break; - ptr=it->second->second.ptr; + ptr=it->second.dataIter->second.ptr; if(!it->second.dataIter->second.hasSend) { _send.erase(it->second.dataIter->second.sendIter); From 35e3a345c2abf9beac3d546daf91a95e1ba6ce11 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Fri, 23 Aug 2024 14:50:01 +0800 Subject: [PATCH 28/44] fix tc_json when double/float isinf or isnan --- util/src/tc_json.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/util/src/tc_json.cpp b/util/src/tc_json.cpp index ff99c952..e5236a4f 100755 --- a/util/src/tc_json.cpp +++ b/util/src/tc_json.cpp @@ -694,7 +694,18 @@ void TC_Json::writeNum(const JsonValueNumPtr & p, string& ostr) } else if (!p->isInt) { - ss << TC_Common::tostr(p->value) ; + if(std::isinf(p->value)) + { + ss << "null"; + } + else if(std::isnan(p->value)) + { + ss << "null"; + } + else + { + ss << TC_Common::tostr(p->value); + } } else { From 970a383f15467f16c2075bf1c233f0639a1a6760 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Sat, 31 Aug 2024 08:53:03 +0800 Subject: [PATCH 29/44] feat: add serial com trans support --- util/include/util/tc_serialport.h | 317 ++++++++++++++++++++++ util/src/tc_serialport.cpp | 425 ++++++++++++++++++++++++++++++ 2 files changed, 742 insertions(+) create mode 100644 util/include/util/tc_serialport.h create mode 100644 util/src/tc_serialport.cpp diff --git a/util/include/util/tc_serialport.h b/util/include/util/tc_serialport.h new file mode 100644 index 00000000..65e53873 --- /dev/null +++ b/util/include/util/tc_serialport.h @@ -0,0 +1,317 @@ +// +// Created by jarod on 2023/8/22. +// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include "util/tc_ex.h" +#include "util/tc_epoller.h" +#include "util/tc_network_buffer.h" + +namespace tars +{ + +/** + * 类说明 + * - 异步串口读写类, 方便的异步读写串口 + * - TC_SerialPortGroup: 管理一组串口, 背后有一个线程来完成串口的读写 + * - TC_SerialPort: 异步串口读写, 由TC_SerialPortGroup负责管理它的生命周期 + * 使用说明 + * TC_SerialPortGroup serialPortGroup; + * serialPortGroup.initialize(); + * + * TC_SerialPortGroup::Options options; + * options.portName = .... + * + * shared_ptr serialPort = serialPortGroup.create(options); + * + * //定义一个协议解析器 +TC_NetWorkBuffer::PACKET_TYPE parser(TC_NetWorkBuffer&buff, TC_SerialPort*) +{ + const char *p = buff.mergeBuffers(); + + const char *pos = TC_Port::strnstr(p, "\r\n", buff.getBufferLength()); + + if(pos == NULL) + { + return TC_NetWorkBuffer::PACKET_LESS; + } + + string out(p, pos); + + //得到一个完整的串口输出类 + + return TC_NetWorkBuffer::PACKET_FULL; +} + + * //设置读取串口后, 数据的解析器 + * serialPort->setParserCallback(std::bind(parser, std::placeholders::_1, std::placeholders::_2)); + * //发送数据 + * serialPort->sendRequest(...); + * //在协议解析器中获取读取到的数据 + */ + +/** + * 串口异常 + */ +class TC_SerialPortException : public TC_Exception +{ +public: + TC_SerialPortException(const string & buffer) + : TC_Exception(buffer) + { + } +}; + +class TC_SerialPort; +class TC_SerialPortGroup; + +/** +* 异步串口通信类 +*/ +class TC_SerialPort +{ +public: + //协议解析器 + using onparser_callback = std::function; + + struct Options + { + string portName; //串口地址 + speed_t baudIn; //输入比特率 + speed_t baudOut; //输出比特率 + tcflag_t cflags = 0; //串口通信表示位 + }; + + friend class TC_SerialPortGroup; + + /** + * 构造 + */ + TC_SerialPort(const Options & options, TC_SerialPortGroup *serialPortGroup); + + /** + * 析构 + */ + ~TC_SerialPort(); + + /** + * 获取options + * @return + */ + const Options & options() + { + return _options; + } + + /** + * @brief 异步发送buffer + * @sendRequest + * @param string & sBuffer + * @param bool header, 是否把数据插入到队列头部, 默认数据都在尾部的! + */ + void sendRequest(const string & sBuffer, bool header = false); + + /** + * @brief 异步发送buffer(尽量使用这个函数, 减少一次内存copy) + * @sendRequest + * @param string & sBuffer + * @param bool header, 是否把数据插入到队列头部, 默认数据都在尾部的! + */ + void sendRequest(const shared_ptr & buff, bool header = false); + +protected: + /** + * sendRequest返回值 + */ + enum ReturnStatus + { + eRetError = -1, + eRetOk = 0, + eRetFull = 1, + eRetNotSend = 2, + }; + + /** + * 添加一个发送buffer + * @param reqBuffer + * @param header, 是否添加到头部 + * + */ + void addSendReqBuffer(const shared_ptr & reqBuffer, bool header = false); + + bool handleCloseImp(const shared_ptr & data); + + bool handleInputImp(const shared_ptr & data); + + bool handleOutputImp(const shared_ptr & data); + + /** + * 实际写串口数据 + * @param buff + * @return + */ + ReturnStatus writeBuffer(const shared_ptr & buff); + + /** + * 发送请求 + */ + void doRequest(); + + /** + * 发送数据 + * @param buf + * @param len + * @param flag + * @return + */ + int send(const void *buf, uint32_t len); + + /** + * 读取数据 + * @param buf + * @param len + * @param flag + * @return + */ + int recv(void *buf, uint32_t len); + + /** + * 协议解析器 + * @param buff + * @return + */ + int doProtocolAnalysis(TC_NetWorkBuffer *buff); + + /** + * + */ + void onRequestCallback(); + + /** + * 是否有效 + * @return + */ + bool isValid() + { + return _serialFd != -1; + } + + /** + * 初始化串口 + */ + void initialize(const TC_SerialPort::onparser_callback & onparser); + + /** + * 关闭串口句柄 + */ + void close(); + +protected: + + /** + * 串口管理组 + */ + TC_SerialPortGroup *_serialPortGroup = NULL; + + /** + * 串口参数 + */ + Options _options; + + std::mutex _mutex; + std::condition_variable _cond; + + /** + * 串口句柄 + */ + int _serialFd = -1; + + /** + * 数据队列, 注意, 不要用deque, 因为后面要删除迭代器, 可能失效 + */ + list, bool>> _messages; + + /** + * epollInfo + */ + shared_ptr _epollInfo; + + /* + * 发送buffer + */ + TC_NetWorkBuffer _sendBuffer; + + /* + * 接收buffer + */ + TC_NetWorkBuffer _recvBuffer; + + /** + * 协议解析器 + */ + onparser_callback _onParserCallback; + +}; + + +class TC_SerialPortGroup +{ +public: + /** + * 初始化 + */ + void initialize(); + + /** + * 创建某个串口 + * @param options + * @return + */ + shared_ptr create(const TC_SerialPort::Options & options, const TC_SerialPort::onparser_callback & onparser); + + /** + * 删除串口 + * @param sp + */ + void erase(const shared_ptr & sp); + + /** + * 获取epoller + * @return + */ + TC_Epoller & getEpoller() + { + return _epoller; + } + + /** + * 结束 + */ + void terminate(); + + +protected: + void run(); + +protected: + /** + * epoller对象 + */ + TC_Epoller _epoller; + + std::mutex _mutex; + + map> _serialPorts; + + std::thread *_th = NULL; +}; + +} + diff --git a/util/src/tc_serialport.cpp b/util/src/tc_serialport.cpp new file mode 100644 index 00000000..71125cea --- /dev/null +++ b/util/src/tc_serialport.cpp @@ -0,0 +1,425 @@ +// +// Created by jarod on 2023/8/22. +// + +#include "util/tc_serialport.h" + +namespace tars +{ + +static const int BUFFER_SIZE = 8 * 1024; + +static const int MAX_BUFFER_SIZE = 64 * 1024; + +void TC_SerialPortGroup::initialize() +{ + if (_th) + { + throw TC_SerialPortException("serial port group has initialize."); + } + + _th = new std::thread(std::bind(&TC_SerialPortGroup::run, this)); + + _epoller.create(1024); +} + +shared_ptr TC_SerialPortGroup::create(const TC_SerialPort::Options & options, const TC_SerialPort::onparser_callback & onparser) +{ + std::lock_guard lock(_mutex); + if (_serialPorts.find(options.portName) != _serialPorts.end()) + { + throw TC_SerialPortException("serial port: `" + options.portName + "` has initialize."); + } + + shared_ptr sp = std::make_shared(options, this); + + _serialPorts[options.portName] = sp; + + sp->initialize(onparser); + + return sp; +} + +void TC_SerialPortGroup::erase(const shared_ptr & sp) +{ + std::lock_guard lock(_mutex); + + _serialPorts.erase(sp->options().portName); +} + +void TC_SerialPortGroup::run() +{ + _epoller.idle([&] + { + + std::lock_guard lock(_mutex); + for (auto e: _serialPorts) + { + e.second->doRequest(); + } + }); + + _epoller.loop(); +} + +void TC_SerialPortGroup::terminate() +{ + if (!_th) + { + return; + } + _epoller.terminate(); + _th->join(); + { + std::lock_guard lock(_mutex); + _serialPorts.clear(); + } + delete _th; + _th = NULL; + +} + +////////////////////////////////////////////////////////////// +TC_SerialPort::TC_SerialPort(const Options & options, TC_SerialPortGroup *serialPortGroup) + : _serialPortGroup(serialPortGroup), _options(options), _sendBuffer(NULL), _recvBuffer(NULL) +{ +} + +TC_SerialPort::~TC_SerialPort() +{ + close(); +} + +void TC_SerialPort::close() +{ + if (_serialFd >= 0) + { + ::close(_serialFd); + _serialFd = -1; + } +} + +void TC_SerialPort::initialize(const TC_SerialPort::onparser_callback & onparser) +{ + if (_serialFd >= 0) + { + throw TC_SerialPortException("open serial port: " + _options.portName + " has initialized."); + } + + _serialFd = open(_options.portName.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK); + if (_serialFd == -1) + { + throw TC_SerialPortException("Failed to open serial port: " + _options.portName); + } + + struct termios serialSettings; + bzero(&serialSettings, sizeof(serialSettings)); + + tcgetattr(_serialFd, &serialSettings); + + cfsetispeed(&serialSettings, _options.baudIn); + cfsetospeed(&serialSettings, _options.baudOut); + serialSettings.c_cflag = _options.cflags; + + int ret = tcsetattr(_serialFd, TCSANOW, &serialSettings); + if (ret != 0) + { + throw TC_SerialPortException("Failed to set serial port: " + _options.portName); + } + tcflush(_serialFd, TCIOFLUSH); + + _onParserCallback = onparser; + + _epollInfo = _serialPortGroup->getEpoller().createEpollInfo(_serialFd); + + map callbacks; + + callbacks[EPOLLIN] = std::bind(&TC_SerialPort::handleInputImp, this, std::placeholders::_1); + callbacks[EPOLLOUT] = std::bind(&TC_SerialPort::handleOutputImp, this, std::placeholders::_1); + callbacks[EPOLLERR] = std::bind(&TC_SerialPort::handleCloseImp, this, std::placeholders::_1); + + _epollInfo->registerCallback(callbacks, EPOLLIN | EPOLLOUT); +} + +void TC_SerialPort::sendRequest(const string & sBuffer, bool header) +{ + if (sBuffer.empty()) + return; + + shared_ptr buff = std::make_shared(); + + buff->addBuffer(sBuffer); + + addSendReqBuffer(buff, header); +} + +void TC_SerialPort::sendRequest(const shared_ptr & buff, bool header) +{ + if (buff && buff->empty()) + return; + + addSendReqBuffer(buff, header); +} + +void TC_SerialPort::addSendReqBuffer(const shared_ptr & reqBuffer, bool header) +{ + std::lock_guard lock(_mutex); + + if (header) + { + _messages.push_front(std::make_pair(reqBuffer, false)); + } + else + { + _messages.push_back(std::make_pair(reqBuffer, false)); + } + + //发送消息, 唤醒网络线程 + _serialPortGroup->getEpoller().notify(); +} + +int TC_SerialPort::doProtocolAnalysis(TC_NetWorkBuffer *buff) +{ + TC_NetWorkBuffer::PACKET_TYPE ret; + + int packetCount = 0; + + int ioriginal = 0; + int isurplus = 0; + try + { + do + { + ioriginal = buff->getBufferLength(); + ret = _onParserCallback(*buff, this); + isurplus = buff->getBufferLength(); + + if (ret == TC_NetWorkBuffer::PACKET_FULL || ret == TC_NetWorkBuffer::PACKET_FULL_CLOSE) + { + ++packetCount; + } + + // 当收到完整包时,解析完包后,buffer没movehead,则报错 + if (ret == TC_NetWorkBuffer::PACKET_FULL && ioriginal == isurplus) + { + ret = TC_NetWorkBuffer::PACKET_ERR; + string err = "parser buffer movehead error"; + throw TC_SerialPortException(err); + } + + } + while (ret == TC_NetWorkBuffer::PACKET_FULL); + } + catch (exception & ex) + { + throw TC_SerialPortException("parser decode error:" + string(ex.what())); + } + catch (...) + { + throw TC_SerialPortException("parser decode error"); + } + + if (ret == TC_NetWorkBuffer::PACKET_ERR) + { + string err = "parser decode error"; + throw TC_SerialPortException("parser decode error"); + } + + return packetCount; +} + +bool TC_SerialPort::handleCloseImp(const shared_ptr & epollInfo) +{ + close(); + return false; +} + +bool TC_SerialPort::handleInputImp(const shared_ptr & epollInfo) +{ + //串口读取数据 + + int iRet = 0; +// int64_t now = TNOWMS; + + do + { + size_t expansion = std::max(std::min(_recvBuffer.getBufferLength(), (size_t) MAX_BUFFER_SIZE), (size_t) BUFFER_SIZE); + auto data = _recvBuffer.getOrCreateBuffer(BUFFER_SIZE / 2, expansion); + + uint32_t left = (uint32_t) data->left(); + + if ((iRet = this->recv((void *) data->free(), left)) > 0) + { + data->addWriteIdx(iRet); + + _recvBuffer.addLength(iRet); + + //解析协议 + _onParserCallback(_recvBuffer, this); + + //接收的数据小于buffer大小, 内核会再次通知你 + if (iRet < (int) left) + { + break; + } + } + } + while (iRet > 0); + + if (iRet == 0) + { + close(); + throw TC_SerialPortException("peer close connection"); + } + + return true; +} + +void TC_SerialPort::onRequestCallback() +{ + //串口发送数据 + for (;;) + { + decltype(_messages)::iterator it; + + { + std::lock_guard lock(_mutex); + if (_messages.empty()) + { + return; + } + + it = _messages.begin(); + } + + ReturnStatus iRet = writeBuffer(it->first); + if (iRet == eRetError) + { + return; + } + + if (iRet != eRetNotSend) + { + std::lock_guard lock(_mutex); + + _messages.erase(it); + } + + //数据还不能发送 or 发送buffer已经满了 直接返回, 暂时不要再发送了! + if (iRet == eRetNotSend || iRet == eRetFull) + { + return; + } + + return; + } +} + +bool TC_SerialPort::handleOutputImp(const shared_ptr & data) +{ + doRequest(); + return true; +} + +TC_SerialPort::ReturnStatus TC_SerialPort::writeBuffer(const shared_ptr & buff) +{ + //空数据 直接返回成功 + if (buff->empty()) + { + return eRetOk; + } + + // assert(_sendBuffer.empty()); + //buf不为空, 表示之前的数据还没发送完, 直接返回失败, 等buffer可写了,epoll会通知写事件 + if (!_sendBuffer.empty()) + { + //不应该运行到这里 + return eRetNotSend; + } + + _sendBuffer.addBuffer(buff); + + do + { + auto data = _sendBuffer.getBufferPointer(); + + int iRet = this->send(data.first, (uint32_t) data.second); + if (iRet < 0) + { + if (!isValid()) + { + _sendBuffer.clearBuffers(); + return eRetError; + } + else + { + return eRetFull; + } + } + + _sendBuffer.moveHeader(iRet); +// assert(iRet != 0); + } + while (!_sendBuffer.empty()); + + return eRetOk; +} + +void TC_SerialPort::doRequest() +{ + //buf不为空,先发送buffer的内容 + while (!_sendBuffer.empty()) + { + auto data = _sendBuffer.getBufferPointer(); + assert(data.first != NULL && data.second != 0); + + int iRet = this->send(data.first, (uint32_t) data.second); + + if (iRet <= 0) + { + return; + } + + _sendBuffer.moveHeader(iRet); + } + + if (_sendBuffer.empty()) + { + onRequestCallback(); + } +} + +int TC_SerialPort::send(const void *buf, uint32_t len) +{ + int iRet = ::write(_serialFd, (const char *) buf, len); +// LOG_CONSOLE_DEBUG << this << ", send, fd:" << _serialFd << ", iRet:" << iRet << ", len:" << len << endl; + + if (iRet < 0 && !TC_Socket::isPending()) + { + int nerr = TC_Exception::getSystemCode(); + string err = "send error, errno:" + TC_Common::tostr(nerr) + "," + TC_Exception::parseError(nerr); + close(); + throw TC_SerialPortException("TC_SerialPort::send, fd:" + TC_Common::tostr(_serialFd) + ", error:" + err); + } + + return iRet; +} + +int TC_SerialPort::recv(void *buf, uint32_t len) +{ + int iRet = ::read(_serialFd, (char *) buf, len); + +// LOG_CONSOLE_DEBUG << this << ", recv, fd:" << _serialFd << ", iRet:" << iRet << ", " << string((const char *)buf, iRet) << endl; + + if ((iRet < 0 && !TC_Socket::isPending())) + { + int nerr = TC_Exception::getSystemCode(); + string err = "recv error, errno:" + TC_Common::tostr(nerr) + "," + TC_Exception::parseError(nerr); + close(); + throw TC_SerialPortException("TC_SerialPort::recv, fd:" + TC_Common::tostr(_serialFd) + ", error:" + err); + } + + return iRet; +} + +} From 5efade0b727bc66957ab09695dc233b3a1c0b1cf Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Mon, 2 Sep 2024 09:05:00 +0800 Subject: [PATCH 30/44] TC_SerialPorts only support linux/mac --- util/include/util/tc_serialport.h | 4 ++++ util/src/tc_serialport.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/util/include/util/tc_serialport.h b/util/include/util/tc_serialport.h index 65e53873..a1ad7386 100644 --- a/util/include/util/tc_serialport.h +++ b/util/include/util/tc_serialport.h @@ -10,10 +10,13 @@ #include #include #include +#include "util/tc_platform.h" #include "util/tc_ex.h" #include "util/tc_epoller.h" #include "util/tc_network_buffer.h" +#if TARGET_PLATFORM_LINUX || TARGET_PLATFORM_IOS + namespace tars { @@ -315,3 +318,4 @@ class TC_SerialPortGroup } +#endif diff --git a/util/src/tc_serialport.cpp b/util/src/tc_serialport.cpp index 71125cea..4f3a4481 100644 --- a/util/src/tc_serialport.cpp +++ b/util/src/tc_serialport.cpp @@ -4,6 +4,8 @@ #include "util/tc_serialport.h" +#if TARGET_PLATFORM_LINUX || TARGET_PLATFORM_IOS + namespace tars { @@ -423,3 +425,5 @@ int TC_SerialPort::recv(void *buf, uint32_t len) } } + +#endif From dd84c3fa11890cd4721e1971cef6e28f934dda25 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Fri, 13 Sep 2024 22:00:26 +0800 Subject: [PATCH 31/44] fix tc_serialport compiler bug in windows --- util/include/util/tc_serialport.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/include/util/tc_serialport.h b/util/include/util/tc_serialport.h index a1ad7386..63307228 100644 --- a/util/include/util/tc_serialport.h +++ b/util/include/util/tc_serialport.h @@ -4,19 +4,19 @@ #pragma once +#include "util/tc_platform.h" + +#if TARGET_PLATFORM_LINUX || TARGET_PLATFORM_IOS + #include #include #include -#include #include #include -#include "util/tc_platform.h" #include "util/tc_ex.h" #include "util/tc_epoller.h" #include "util/tc_network_buffer.h" -#if TARGET_PLATFORM_LINUX || TARGET_PLATFORM_IOS - namespace tars { From bccdeef530d0a9bd4a8cf124806c60817c166332 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 18 Sep 2024 14:34:37 +0800 Subject: [PATCH 32/44] feat: tc_mysql init add connecttimeout/readwritetimeout --- util/include/util/tc_mysql.h | 8 ++++---- util/src/tc_mysql.cpp | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/util/include/util/tc_mysql.h b/util/include/util/tc_mysql.h index 6e8b2433..4ed154ba 100644 --- a/util/include/util/tc_mysql.h +++ b/util/include/util/tc_mysql.h @@ -95,13 +95,13 @@ struct TC_DBConf int _flag; /** - * 连接超时 + * 连接超时(秒) * Port */ int _connectTimeout; /** - * 读写超时 + * 读写超时(秒) * Port */ int _writeReadTimeout; @@ -209,7 +209,7 @@ class TC_Mysql * @param iFlag 客户端标识 * @param iFlag Client Identity */ - TC_Mysql(const string& sHost, const string& sUser = "", const string& sPasswd = "", const string& sDatabase = "", const string &sCharSet = "", int port = 0, int iFlag = 0); + TC_Mysql(const string& sHost, const string& sUser = "", const string& sPasswd = "", const string& sDatabase = "", const string &sCharSet = "", int port = 0, int iFlag = 0, int connectTimeout = 10, int writeReadTimeout = 0); /** * @brief 构造函数. @@ -245,7 +245,7 @@ class TC_Mysql * @return 无 * @return none */ - void init(const string& sHost, const string& sUser = "", const string& sPasswd = "", const string& sDatabase = "", const string &sCharSet = "", int port = 0, int iFlag = 0); + void init(const string& sHost, const string& sUser = "", const string& sPasswd = "", const string& sDatabase = "", const string &sCharSet = "", int port = 0, int iFlag = 0, int connectTimeout = 10, int writeReadTimeout = 0); /** * @brief 初始化. diff --git a/util/src/tc_mysql.cpp b/util/src/tc_mysql.cpp index ff88d59a..dc1bd130 100644 --- a/util/src/tc_mysql.cpp +++ b/util/src/tc_mysql.cpp @@ -32,10 +32,10 @@ TC_Mysql::TC_Mysql() _pstMql = mysql_init(NULL); } -TC_Mysql::TC_Mysql(const string& sHost, const string& sUser, const string& sPasswd, const string& sDatabase, const string &sCharSet, int port, int iFlag) +TC_Mysql::TC_Mysql(const string& sHost, const string& sUser, const string& sPasswd, const string& sDatabase, const string &sCharSet, int port, int iFlag, int connectTimeout, int writeReadTimeout) :_bConnected(false) { - init(sHost, sUser, sPasswd, sDatabase, sCharSet, port, iFlag); + init(sHost, sUser, sPasswd, sDatabase, sCharSet, port, iFlag, connectTimeout, writeReadTimeout); _pstMql = mysql_init(NULL); } @@ -57,7 +57,7 @@ TC_Mysql::~TC_Mysql() } } -void TC_Mysql::init(const string& sHost, const string& sUser, const string& sPasswd, const string& sDatabase, const string &sCharSet, int port, int iFlag) +void TC_Mysql::init(const string& sHost, const string& sUser, const string& sPasswd, const string& sDatabase, const string &sCharSet, int port, int iFlag, int connectTimeout, int writeReadTimeout) { _dbConf._host = sHost; _dbConf._user = sUser; @@ -66,6 +66,8 @@ void TC_Mysql::init(const string& sHost, const string& sUser, const string& sPas _dbConf._charset = sCharSet; _dbConf._port = port; _dbConf._flag = iFlag; + _dbConf._writeReadTimeout = writeReadTimeout; + _dbConf._connectTimeout = connectTimeout; } void TC_Mysql::init(const TC_DBConf& tcDBConf) @@ -526,7 +528,7 @@ void TC_Mysql::execute(const string& sSql) if (iRet != 0) { - throw TC_Mysql_Exception("[TC_Mysql::execute]: mysql_query: [ " + sSql+" ] :" + string(mysql_error(_pstMql))); + throw TC_Mysql_Exception("[TC_Mysql::execute]: mysql_query: [ " + sSql+" ] :" + string(mysql_error(_pstMql)) + ", errno:" + TC_Common::tostr(iRet)); } } From ef05606ace85455d1f3ed0eafda8b6294cab8bc9 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 19 Sep 2024 10:48:29 +0800 Subject: [PATCH 33/44] fix tc_json writeValue, when p is null --- util/src/tc_json.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/src/tc_json.cpp b/util/src/tc_json.cpp index e5236a4f..be1f0f68 100755 --- a/util/src/tc_json.cpp +++ b/util/src/tc_json.cpp @@ -621,6 +621,9 @@ void TC_Json::writeValue(const JsonValuePtr & p, string& ostr, bool withSpace) case eJsonTypeBoolean: writeBoolean(JsonValueBooleanPtr::dynamicCast(p), ostr); break; + case eJsonTypeNull: + ostr += "null"; + break; default: assert(false); } From 1ffec75c9b21414da76c939d987e2b170bc79436 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 23 Oct 2024 19:42:49 +0800 Subject: [PATCH 34/44] compiler with shared library --- mock/CMakeLists.txt | 11 ++++++++++- servant/libservant/CMakeLists.txt | 14 +++++++++++++- tools/tarsparse/CMakeLists.txt | 13 +++++++++++-- util/src/CMakeLists.txt | 24 +++++++++++++++++++++++- 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/mock/CMakeLists.txt b/mock/CMakeLists.txt index a29ebdbf..cfe1eaef 100755 --- a/mock/CMakeLists.txt +++ b/mock/CMakeLists.txt @@ -1,10 +1,19 @@ include_directories(../) file(GLOB_RECURSE SRC_FILES *.cpp) -add_library(tarsmock ${SRC_FILES}) +add_library(tarsmock STATIC ${SRC_FILES}) +add_library(tarsmock_shared SHARED ${SRC_FILES}) +target_link_libraries(tarsmock_shared tarsservant_shared tarsutil_shared) add_dependencies(tarsmock tarsservant) +add_dependencies(tarsmock_shared tarsservant) install(DIRECTORY . DESTINATION include/mock FILES_MATCHING PATTERN "*.h") install(TARGETS tarsmock RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) +install(TARGETS tarsmock_shared RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + +if (WIN32) + install(FILES $ DESTINATION bin) +endif() + diff --git a/servant/libservant/CMakeLists.txt b/servant/libservant/CMakeLists.txt index 31b80ac5..3e46dcd0 100755 --- a/servant/libservant/CMakeLists.txt +++ b/servant/libservant/CMakeLists.txt @@ -8,10 +8,22 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) aux_source_directory(. DIR_SRCS) -add_library(tarsservant ${DIR_SRCS}) +add_library(tarsservant STATIC ${DIR_SRCS}) add_dependencies(tarsservant COPY-SERVENT-TARS) install(TARGETS tarsservant LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + +add_library(tarsservant_shared SHARED ${DIR_SRCS}) +target_compile_definitions(tarsservant_shared PRIVATE SVT_DLL_EXPORT UTIL_USE_DLL) +target_link_libraries(tarsservant_shared tarsutil_shared tarsparse_shared) + +add_dependencies(tarsservant_shared COPY-SERVENT-TARS) +install(TARGETS tarsservant_shared + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) +if (WIN32) + install(FILES $ DESTINATION bin) +endif() diff --git a/tools/tarsparse/CMakeLists.txt b/tools/tarsparse/CMakeLists.txt index d9f7788e..ec25bf81 100644 --- a/tools/tarsparse/CMakeLists.txt +++ b/tools/tarsparse/CMakeLists.txt @@ -28,15 +28,24 @@ foreach(LEC_YACC_SRC ${DEPENDS_LEC_YACC_SRC_LIST}) endforeach() -add_library(${TARGETNAME} ${DIR_SRCS} ${DEPENDS_SRC_LIST}) +add_library(${TARGETNAME} STATIC ${DIR_SRCS} ${DEPENDS_SRC_LIST}) +add_library(${TARGETNAME}_shared SHARED ${DIR_SRCS} ${DEPENDS_SRC_LIST}) if(UNIX) add_dependencies(${TARGETNAME} COPY-LEX-YACC) endif(UNIX) -install(TARGETS tarsparse +install(TARGETS ${TARGETNAME} LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) +install(TARGETS ${TARGETNAME}_shared + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) + +if (WIN32) + install(FILES $ DESTINATION bin) +endif() + FILE(GLOB HEADERS "*.h") install(FILES ${HEADERS} DESTINATION include/tarsparse) \ No newline at end of file diff --git a/util/src/CMakeLists.txt b/util/src/CMakeLists.txt index 091af25d..31dcdf7f 100644 --- a/util/src/CMakeLists.txt +++ b/util/src/CMakeLists.txt @@ -24,13 +24,35 @@ message("----------------------------------------------------") list(APPEND DIR_SRCS ${JUMP_SRC}) list(APPEND DIR_SRCS ${MAKE_SRC}) -add_library(tarsutil ${DIR_SRCS}) +add_library(tarsutil STATIC ${DIR_SRCS}) +add_library(tarsutil_shared SHARED ${DIR_SRCS}) add_dependencies(tarsutil thirdparty) +target_link_libraries(tarsutil_shared mysqlclient) +target_compile_definitions(tarsutil_shared PRIVATE UTIL_DLL_EXPORT) + +if (TARS_SSL) + if (WIN32) + #windows动态编译需添加依赖库 + target_link_libraries(tarsutil_shared ${LIB_SSL}.lib ${LIB_CRYPTO}.lib Crypt32) + #else () + #linux动态编译未验证,暂时屏蔽 + #target_link_libraries(${LIB_TAF_UTIL} ${LIB_SSL}.a ${LIB_CRYPTO}.a) + endif () +endif() +add_dependencies(tarsutil_shared thirdparty) + install(TARGETS tarsutil LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) +install(TARGETS tarsutil_shared + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) +if (WIN32) + install(FILES $ DESTINATION bin) +endif() + IF(WIN32) install(DIRECTORY epoll_windows/sys DESTINATION include) From 2fa4b37edc6a7767efdf5736b1c9eedee640cabc Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Wed, 23 Oct 2024 20:25:15 +0800 Subject: [PATCH 35/44] fix linux compiler bug for so library compiler --- tools/tarsgrammar/tars.tab.cpp | 1497 ++++++++++++++++++-------------- tools/tarsparse/tars.lex.cpp | 79 +- tools/tarsparse/tars.tab.cpp | 1497 ++++++++++++++++++-------------- tools/tarsparse/tars.tab.hpp | 80 +- util/src/CMakeLists.txt | 2 +- 5 files changed, 1787 insertions(+), 1368 deletions(-) diff --git a/tools/tarsgrammar/tars.tab.cpp b/tools/tarsgrammar/tars.tab.cpp index 4647924b..30a4b213 100644 --- a/tools/tarsgrammar/tars.tab.cpp +++ b/tools/tarsgrammar/tars.tab.cpp @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.7.6. */ +/* A Bison parser, made by GNU Bison 3.5.1. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -16,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 @@ -34,10 +34,6 @@ /* 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. @@ -45,11 +41,14 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -/* Identify Bison output, and Bison version. */ -#define YYBISON 30706 +/* Undocumented macros, especially those whose name start with YY_, + are private implementation details. Do not rely on them. */ + +/* Identify Bison output. */ +#define YYBISON 1 -/* Bison version string. */ -#define YYBISON_VERSION "3.7.6" +/* Bison version. */ +#define YYBISON_VERSION "3.5.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -67,7 +66,7 @@ /* First part of user prologue. */ -#line 17 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" +#line 17 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" #include #include @@ -81,7 +80,7 @@ using namespace std; #define YYDEBUG 1 #define YYINITDEPTH 10000 -#line 85 "tars.tab.cpp" +#line 84 "tars.tab.cpp" # ifndef YY_CAST # ifdef __cplusplus @@ -104,102 +103,78 @@ using namespace std; # endif # 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; +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Use api.header.include to #include this header + instead of duplicating it here. */ +#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 + +/* 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); + +#endif /* !YY_YY_TARS_TAB_HPP_INCLUDED */ @@ -240,18 +215,6 @@ typedef int_least16_t yytype_int16; typedef short yytype_int16; #endif -/* 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 - #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 \ @@ -311,7 +274,6 @@ typedef int yytype_uint16; #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) - /* Stored state numbers (used for stacks). */ typedef yytype_uint8 yy_state_t; @@ -330,7 +292,6 @@ typedef int yy_state_fast_t; # endif #endif - #ifndef YY_ATTRIBUTE_PURE # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) @@ -349,9 +310,9 @@ typedef int yy_state_fast_t; /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YY_USE(E) ((void) (E)) +# define YYUSE(E) ((void) (E)) #else -# define YY_USE(E) /* empty */ +# define YYUSE(E) /* empty */ #endif #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ @@ -388,7 +349,7 @@ typedef int yy_state_fast_t; #define YY_ASSERT(E) ((void) (0 && (E))) -#if !defined yyoverflow +#if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -453,7 +414,8 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif -#endif /* !defined yyoverflow */ +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + #if (! defined yyoverflow \ && (! defined __cplusplus \ @@ -529,16 +491,14 @@ union yyalloc /* YYNSTATES -- Number of states. */ #define YYNSTATES 199 -/* YYMAXUTOK -- Last valid token kind. */ +#define YYUNDEFTOK 2 #define YYMAXUTOK 288 /* 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) +#define YYTRANSLATE(YYX) \ + (0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM as returned by yylex. */ @@ -596,45 +556,32 @@ static const yytype_int16 yyrline[] = }; #endif -/** 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; - +#if YYDEBUG || YYERROR_VERBOSE || 0 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "\"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 + "$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 }; - -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_int16 yytoknum[] = @@ -645,7 +592,7 @@ static const yytype_int16 yytoknum[] = 285, 286, 287, 288, 59, 123, 125, 44, 61, 91, 93, 41, 42, 58, 60, 62 }; -#endif +# endif #define YYPACT_NINF (-146) @@ -721,9 +668,9 @@ static const yytype_int16 yypgoto[] = }; /* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_uint8 yydefgoto[] = +static const yytype_int16 yydefgoto[] = { - 0, 8, 9, 76, 80, 10, 11, 77, 12, 123, + -1, 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, @@ -920,10 +867,10 @@ static const yytype_int8 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 @@ -949,9 +896,10 @@ enum { YYENOMEM = -2 }; } \ while (0) -/* Backward compatibility with an undocumented macro. - Use YYerror or YYUNDEF. */ -#define YYERRCODE YYUNDEF +/* Error token number */ +#define YYTERROR 1 +#define YYERRCODE 256 + /* Enable debugging if requested. */ @@ -969,18 +917,18 @@ 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, Kind, Value, Location) \ +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Kind, Value); \ + Type, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) @@ -991,19 +939,18 @@ do { \ `-----------------------------------*/ static void -yy_symbol_value_print (FILE *yyo, - yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) +yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) { FILE *yyoutput = yyo; - YY_USE (yyoutput); + YYUSE (yyoutput); if (!yyvaluep) return; # ifdef YYPRINT - if (yykind < YYNTOKENS) - YYPRINT (yyo, yytoknum[yykind], *yyvaluep); + if (yytype < YYNTOKENS) + YYPRINT (yyo, yytoknum[yytype], *yyvaluep); # endif YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YY_USE (yykind); + YYUSE (yytype); YY_IGNORE_MAYBE_UNINITIALIZED_END } @@ -1013,13 +960,12 @@ yy_symbol_value_print (FILE *yyo, `---------------------------*/ static void -yy_symbol_print (FILE *yyo, - yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) +yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) { YYFPRINTF (yyo, "%s %s (", - yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); - yy_symbol_value_print (yyo, yykind, yyvaluep); + yy_symbol_value_print (yyo, yytype, yyvaluep); YYFPRINTF (yyo, ")"); } @@ -1052,8 +998,7 @@ do { \ `------------------------------------------------*/ static void -yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, - int yyrule) +yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, int yyrule) { int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; @@ -1065,8 +1010,9 @@ yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, - YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), - &yyvsp[(yyi + 1) - (yynrhs)]); + yystos[+yyssp[yyi + 1 - yynrhs]], + &yyvsp[(yyi + 1) - (yynrhs)] + ); YYFPRINTF (stderr, "\n"); } } @@ -1081,8 +1027,8 @@ do { \ multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ -# define YYDPRINTF(Args) ((void) 0) -# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ @@ -1105,30 +1051,259 @@ int yydebug; #endif +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S))) +# else +/* Return the length of YYSTR. */ +static YYPTRDIFF_T +yystrlen (const char *yystr) +{ + YYPTRDIFF_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 YYPTRDIFF_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYPTRDIFF_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; + else + goto append; + + append: + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + if (yyres) + return yystpcpy (yyres, yystr) - yyres; + else + return yystrlen (yystr); +} +# 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 (YYPTRDIFF_T *yymsg_alloc, char **yymsg, + yy_state_t *yyssp, int yytoken) +{ + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat: reported tokens (one for the "unexpected", + one per "expected"). */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Actual size of YYARG. */ + int yycount = 0; + /* Cumulated lengths of YYARG. */ + YYPTRDIFF_T yysize = 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]; + YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + yysize = yysize0; + 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]; + { + YYPTRDIFF_T yysize1 + = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else + return 2; + } + } + } + } + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + default: /* Avoid compiler warnings. */ + 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_ + } + + { + /* Don't count the "%s"s in the final size, but reserve room for + the terminator. */ + YYPTRDIFF_T yysize1 = yysize + (yystrlen (yyformat) - 2 * yycount) + 1; + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else + return 2; + } + + 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, - yysymbol_kind_t yykind, YYSTYPE *yyvaluep) +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) { - YY_USE (yyvaluep); + YYUSE (yyvaluep); if (!yymsg) yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YY_USE (yykind); + YYUSE (yytype); YY_IGNORE_MAYBE_UNINITIALIZED_END } -/* Lookahead token kind. */ + + +/* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ @@ -1137,8 +1312,6 @@ YYSTYPE yylval; int yynerrs; - - /*----------. | yyparse. | `----------*/ @@ -1146,36 +1319,43 @@ int yynerrs; int yyparse (void) { - yy_state_fast_t yystate = 0; + yy_state_fast_t yystate; /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus = 0; + int yyerrstatus; - /* Refer to the stacks through separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. - /* Their size. */ - YYPTRDIFF_T yystacksize = YYINITDEPTH; + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ - /* The state stack: array, bottom, top. */ + /* The state stack. */ yy_state_t yyssa[YYINITDEPTH]; - yy_state_t *yyss = yyssa; - yy_state_t *yyssp = yyss; + yy_state_t *yyss; + yy_state_t *yyssp; - /* The semantic value stack: array, bottom, top. */ + /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp = yyvs; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYPTRDIFF_T yystacksize; int yyn; - /* The return value of yyparse. */ int yyresult; - /* Lookahead symbol kind. */ - yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; /* 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; + YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf; +#endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) @@ -1183,8 +1363,15 @@ 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; @@ -1207,7 +1394,6 @@ yyparse (void) 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 @@ -1253,7 +1439,7 @@ yyparse (void) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } @@ -1292,29 +1478,18 @@ yyparse (void) /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { - YYDPRINTF ((stderr, "Reading a token\n")); + YYDPRINTF ((stderr, "Reading a token: ")); yychar = yylex (); } if (yychar <= YYEOF) { - yychar = YYEOF; - yytoken = YYSYMBOL_YYEOF; + yychar = yytoken = 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); @@ -1383,93 +1558,93 @@ yyparse (void) YY_REDUCE_PRINT (yyn); switch (yyn) { - case 3: /* $@1: %empty */ -#line 75 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 3: +#line 75 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1391 "tars.tab.cpp" +#line 1566 "tars.tab.cpp" break; - case 5: /* $@2: %empty */ -#line 79 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 5: +#line 79 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyerrok; } -#line 1399 "tars.tab.cpp" +#line 1574 "tars.tab.cpp" break; - case 7: /* definitions: definition */ -#line 84 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 7: +#line 84 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } -#line 1407 "tars.tab.cpp" +#line 1582 "tars.tab.cpp" break; - case 8: /* definitions: %empty */ -#line 88 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 8: +#line 88 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1414 "tars.tab.cpp" +#line 1589 "tars.tab.cpp" break; - case 9: /* definition: namespace_def */ -#line 96 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 9: +#line 96 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || NamespacePtr::dynamicCast(yyvsp[0])); } -#line 1422 "tars.tab.cpp" +#line 1597 "tars.tab.cpp" break; - case 10: /* definition: interface_def */ -#line 100 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 10: +#line 100 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || InterfacePtr::dynamicCast(yyvsp[0])); } -#line 1430 "tars.tab.cpp" +#line 1605 "tars.tab.cpp" break; - case 11: /* definition: struct_def */ -#line 104 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 11: +#line 104 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || StructPtr::dynamicCast(yyvsp[0])); } -#line 1438 "tars.tab.cpp" +#line 1613 "tars.tab.cpp" break; - case 12: /* definition: key_def */ -#line 108 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 12: +#line 108 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1445 "tars.tab.cpp" +#line 1620 "tars.tab.cpp" break; - case 13: /* definition: enum_def */ -#line 111 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 13: +#line 111 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || EnumPtr::dynamicCast(yyvsp[0])); } -#line 1453 "tars.tab.cpp" +#line 1628 "tars.tab.cpp" break; - case 14: /* definition: const_def */ -#line 115 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 14: +#line 115 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || ConstPtr::dynamicCast(yyvsp[0])); } -#line 1461 "tars.tab.cpp" +#line 1636 "tars.tab.cpp" break; - case 15: /* @3: %empty */ -#line 124 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 15: +#line 124 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } -#line 1469 "tars.tab.cpp" +#line 1644 "tars.tab.cpp" break; - case 16: /* enum_def: enum_id @3 '{' enumerator_list '}' */ -#line 128 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 16: +#line 128 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1483,11 +1658,11 @@ yyparse (void) yyval = yyvsp[-3]; } -#line 1487 "tars.tab.cpp" +#line 1662 "tars.tab.cpp" break; - case 17: /* enum_id: TARS_ENUM TARS_IDENTIFIER */ -#line 147 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 17: +#line 147 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { NamespacePtr c = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!c) @@ -1500,36 +1675,36 @@ yyparse (void) yyval = e; } -#line 1504 "tars.tab.cpp" +#line 1679 "tars.tab.cpp" break; - case 18: /* enum_id: TARS_ENUM keyword */ -#line 160 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 18: +#line 160 "/mnt/data/heer/ruanshudong/frameworkPro/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]; } -#line 1514 "tars.tab.cpp" +#line 1689 "tars.tab.cpp" break; - case 19: /* enumerator_list: enumerator ',' enumerator_list */ -#line 171 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 19: +#line 171 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[-1]; } -#line 1522 "tars.tab.cpp" +#line 1697 "tars.tab.cpp" break; - case 20: /* enumerator_list: enumerator */ -#line 175 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 20: +#line 175 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1529 "tars.tab.cpp" +#line 1704 "tars.tab.cpp" break; - case 21: /* enumerator: TARS_IDENTIFIER */ -#line 183 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 21: +#line 183 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1540,20 +1715,20 @@ yyparse (void) e->addMember(tPtr); yyval = e; } -#line 1544 "tars.tab.cpp" +#line 1719 "tars.tab.cpp" break; - case 22: /* enumerator: keyword */ -#line 194 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 22: +#line 194 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumerator"); } -#line 1553 "tars.tab.cpp" +#line 1728 "tars.tab.cpp" break; - case 23: /* enumerator: TARS_IDENTIFIER '=' const_initializer */ -#line 199 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 23: +#line 199 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -1566,18 +1741,18 @@ yyparse (void) e->addMember(tPtr); yyval = e; } -#line 1570 "tars.tab.cpp" +#line 1745 "tars.tab.cpp" break; - case 24: /* enumerator: %empty */ -#line 212 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 24: +#line 212 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1577 "tars.tab.cpp" +#line 1752 "tars.tab.cpp" break; - case 25: /* @4: %empty */ -#line 220 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 25: +#line 220 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ContainerPtr c = g_parse->currentContainer(); @@ -1592,11 +1767,11 @@ yyparse (void) yyval = 0; } } -#line 1596 "tars.tab.cpp" +#line 1771 "tars.tab.cpp" break; - case 26: /* namespace_def: TARS_NAMESPACE TARS_IDENTIFIER @4 '{' definitions '}' */ -#line 235 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 26: +#line 235 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1608,11 +1783,11 @@ yyparse (void) yyval = 0; } } -#line 1612 "tars.tab.cpp" +#line 1787 "tars.tab.cpp" break; - case 27: /* $@5: %empty */ -#line 253 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 27: +#line 253 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-1]); StructPtr sp = StructPtr::dynamicCast(g_parse->findUserType(ident->v)); @@ -1623,18 +1798,18 @@ yyparse (void) g_parse->setKeyStruct(sp); } -#line 1627 "tars.tab.cpp" +#line 1802 "tars.tab.cpp" break; - case 28: /* key_def: TARS_KEY '[' scoped_name ',' $@5 key_members ']' */ -#line 264 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 28: +#line 264 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1634 "tars.tab.cpp" +#line 1809 "tars.tab.cpp" break; - case 29: /* key_members: TARS_IDENTIFIER */ -#line 272 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 29: +#line 272 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1647,11 +1822,11 @@ yyparse (void) yyval = 0; } } -#line 1651 "tars.tab.cpp" +#line 1826 "tars.tab.cpp" break; - case 30: /* key_members: key_members ',' TARS_IDENTIFIER */ -#line 285 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 30: +#line 285 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1664,11 +1839,11 @@ yyparse (void) yyval = 0; } } -#line 1668 "tars.tab.cpp" +#line 1843 "tars.tab.cpp" break; - case 31: /* @6: %empty */ -#line 304 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 31: +#line 304 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1685,11 +1860,11 @@ yyparse (void) yyval = 0; } } -#line 1689 "tars.tab.cpp" +#line 1864 "tars.tab.cpp" break; - case 32: /* interface_def: interface_id @6 '{' interface_exports '}' */ -#line 321 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 32: +#line 321 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1701,58 +1876,58 @@ yyparse (void) yyval = 0; } } -#line 1705 "tars.tab.cpp" +#line 1880 "tars.tab.cpp" break; - case 33: /* interface_id: TARS_INTERFACE TARS_IDENTIFIER */ -#line 338 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 33: +#line 338 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } -#line 1713 "tars.tab.cpp" +#line 1888 "tars.tab.cpp" break; - case 34: /* interface_id: TARS_INTERFACE keyword */ -#line 342 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 34: +#line 342 "/mnt/data/heer/ruanshudong/frameworkPro/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]; } -#line 1723 "tars.tab.cpp" +#line 1898 "tars.tab.cpp" break; - case 35: /* interface_exports: interface_export ';' interface_exports */ -#line 353 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 35: +#line 353 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1730 "tars.tab.cpp" +#line 1905 "tars.tab.cpp" break; - case 36: /* interface_exports: error ';' interface_exports */ -#line 356 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 36: +#line 356 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1737 "tars.tab.cpp" +#line 1912 "tars.tab.cpp" break; - case 37: /* interface_exports: interface_export */ -#line 359 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 37: +#line 359 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } -#line 1745 "tars.tab.cpp" +#line 1920 "tars.tab.cpp" break; - case 38: /* interface_exports: %empty */ -#line 363 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 38: +#line 363 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1752 "tars.tab.cpp" +#line 1927 "tars.tab.cpp" break; - case 40: /* operation: operation_preamble parameters ')' */ -#line 377 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 40: +#line 377 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1764,11 +1939,11 @@ yyparse (void) yyval = 0; } } -#line 1768 "tars.tab.cpp" +#line 1943 "tars.tab.cpp" break; - case 41: /* operation_preamble: return_type TARS_OP */ -#line 394 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 41: +#line 394 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1792,26 +1967,26 @@ yyparse (void) yyval = 0; } } -#line 1796 "tars.tab.cpp" +#line 1971 "tars.tab.cpp" break; - case 43: /* return_type: TARS_VOID */ -#line 424 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 43: +#line 424 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = 0; } -#line 1804 "tars.tab.cpp" +#line 1979 "tars.tab.cpp" break; - case 44: /* parameters: %empty */ -#line 434 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 44: +#line 434 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1811 "tars.tab.cpp" +#line 1986 "tars.tab.cpp" break; - case 45: /* parameters: type_id */ -#line 437 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 45: +#line 437 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1822,11 +1997,11 @@ yyparse (void) op->createParamDecl(tsp, false, false); } } -#line 1826 "tars.tab.cpp" +#line 2001 "tars.tab.cpp" break; - case 46: /* parameters: parameters ',' type_id */ -#line 448 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 46: +#line 448 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1837,11 +2012,11 @@ yyparse (void) op->createParamDecl(tsp, false, false); } } -#line 1841 "tars.tab.cpp" +#line 2016 "tars.tab.cpp" break; - case 47: /* parameters: out_qualifier type_id */ -#line 459 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 47: +#line 459 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1853,11 +2028,11 @@ yyparse (void) op->createParamDecl(tsp, isOutParam->v, false); } } -#line 1857 "tars.tab.cpp" +#line 2032 "tars.tab.cpp" break; - case 48: /* parameters: parameters ',' out_qualifier type_id */ -#line 471 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 48: +#line 471 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1869,11 +2044,11 @@ yyparse (void) op->createParamDecl(tsp, isOutParam->v, false); } } -#line 1873 "tars.tab.cpp" +#line 2048 "tars.tab.cpp" break; - case 49: /* parameters: routekey_qualifier type_id */ -#line 483 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 49: +#line 483 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1885,11 +2060,11 @@ yyparse (void) op->createParamDecl(tsp, false, isRouteKeyParam->v); } } -#line 1889 "tars.tab.cpp" +#line 2064 "tars.tab.cpp" break; - case 50: /* parameters: parameters ',' routekey_qualifier type_id */ -#line 495 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 50: +#line 495 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1901,47 +2076,47 @@ yyparse (void) op->createParamDecl(tsp, false, isRouteKeyParam->v); } } -#line 1905 "tars.tab.cpp" +#line 2080 "tars.tab.cpp" break; - case 51: /* parameters: out_qualifier */ -#line 507 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 51: +#line 507 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("'out' must be defined with a type"); } -#line 1913 "tars.tab.cpp" +#line 2088 "tars.tab.cpp" break; - case 52: /* parameters: routekey_qualifier */ -#line 511 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 52: +#line 511 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("'routekey' must be defined with a type"); } -#line 1921 "tars.tab.cpp" +#line 2096 "tars.tab.cpp" break; - case 53: /* routekey_qualifier: TARS_ROUTE_KEY */ -#line 520 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 53: +#line 520 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr routekey = new BoolGrammar; routekey->v = true; yyval = GrammarBasePtr::dynamicCast(routekey); } -#line 1931 "tars.tab.cpp" +#line 2106 "tars.tab.cpp" break; - case 54: /* out_qualifier: TARS_OUT */ -#line 531 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 54: +#line 531 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr out = new BoolGrammar; out->v = true; yyval = GrammarBasePtr::dynamicCast(out); } -#line 1941 "tars.tab.cpp" +#line 2116 "tars.tab.cpp" break; - case 55: /* @7: %empty */ -#line 542 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 55: +#line 542 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); @@ -1963,11 +2138,11 @@ yyparse (void) g_parse->error("struct '" + ident->v + "' must definition in namespace"); } } -#line 1967 "tars.tab.cpp" +#line 2142 "tars.tab.cpp" break; - case 56: /* struct_def: struct_id @7 '{' struct_exports '}' */ -#line 564 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 56: +#line 564 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1982,68 +2157,68 @@ yyparse (void) g_parse->error("struct `" + st->getSid() + "' must have at least one member"); } } -#line 1986 "tars.tab.cpp" +#line 2161 "tars.tab.cpp" break; - case 57: /* struct_id: TARS_STRUCT TARS_IDENTIFIER */ -#line 584 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 57: +#line 584 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } -#line 1994 "tars.tab.cpp" +#line 2169 "tars.tab.cpp" break; - case 58: /* struct_id: TARS_STRUCT keyword */ -#line 588 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 58: +#line 588 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as struct name"); } -#line 2004 "tars.tab.cpp" +#line 2179 "tars.tab.cpp" break; - case 59: /* struct_id: TARS_STRUCT error */ -#line 594 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 59: +#line 594 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("abstract declarator '' used as declaration"); } -#line 2012 "tars.tab.cpp" +#line 2187 "tars.tab.cpp" break; - case 60: /* struct_exports: data_member ';' struct_exports */ -#line 603 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 60: +#line 603 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2020 "tars.tab.cpp" +#line 2195 "tars.tab.cpp" break; - case 61: /* struct_exports: data_member */ -#line 607 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 61: +#line 607 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("';' missing after definition"); } -#line 2028 "tars.tab.cpp" +#line 2203 "tars.tab.cpp" break; - case 62: /* struct_exports: %empty */ -#line 611 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 62: +#line 611 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2035 "tars.tab.cpp" +#line 2210 "tars.tab.cpp" break; - case 63: /* data_member: struct_type_id */ -#line 621 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 63: +#line 621 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } -#line 2043 "tars.tab.cpp" +#line 2218 "tars.tab.cpp" break; - case 64: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id */ -#line 630 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 64: +#line 630 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2061,11 +2236,11 @@ yyparse (void) yyval = 0; } } -#line 2065 "tars.tab.cpp" +#line 2240 "tars.tab.cpp" break; - case 65: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id '=' const_initializer */ -#line 648 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 65: +#line 648 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2087,11 +2262,11 @@ yyparse (void) yyval = 0; } } -#line 2091 "tars.tab.cpp" +#line 2266 "tars.tab.cpp" break; - case 66: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id '=' const_initializer */ -#line 670 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 66: +#line 670 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2113,11 +2288,11 @@ yyparse (void) yyval = 0; } } -#line 2117 "tars.tab.cpp" +#line 2292 "tars.tab.cpp" break; - case 67: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id */ -#line 692 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 67: +#line 692 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2134,43 +2309,43 @@ yyparse (void) yyval = 0; } } -#line 2138 "tars.tab.cpp" +#line 2313 "tars.tab.cpp" break; - case 68: /* struct_type_id: TARS_REQUIRE type_id */ -#line 709 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 68: +#line 709 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } -#line 2146 "tars.tab.cpp" +#line 2321 "tars.tab.cpp" break; - case 69: /* struct_type_id: TARS_OPTIONAL type_id */ -#line 713 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 69: +#line 713 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } -#line 2154 "tars.tab.cpp" +#line 2329 "tars.tab.cpp" break; - case 70: /* struct_type_id: TARS_CONST_INTEGER type_id */ -#line 717 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 70: +#line 717 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'require' or 'optional'"); } -#line 2162 "tars.tab.cpp" +#line 2337 "tars.tab.cpp" break; - case 71: /* struct_type_id: type_id */ -#line 721 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 71: +#line 721 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag' or 'require' or 'optional'"); } -#line 2170 "tars.tab.cpp" +#line 2345 "tars.tab.cpp" break; - case 72: /* const_initializer: TARS_CONST_INTEGER */ -#line 730 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 72: +#line 730 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { IntergerGrammarPtr intVal = IntergerGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2180,11 +2355,11 @@ yyparse (void) c->v = sstr.str(); yyval = c; } -#line 2184 "tars.tab.cpp" +#line 2359 "tars.tab.cpp" break; - case 73: /* const_initializer: TARS_CONST_FLOAT */ -#line 740 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 73: +#line 740 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { FloatGrammarPtr floatVal = FloatGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2194,11 +2369,11 @@ yyparse (void) c->v = sstr.str(); yyval = c; } -#line 2198 "tars.tab.cpp" +#line 2373 "tars.tab.cpp" break; - case 74: /* const_initializer: TARS_STRING_LITERAL */ -#line 750 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 74: +#line 750 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2206,11 +2381,11 @@ yyparse (void) c->v = ident->v; yyval = c; } -#line 2210 "tars.tab.cpp" +#line 2385 "tars.tab.cpp" break; - case 75: /* const_initializer: TARS_FALSE */ -#line 758 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 75: +#line 758 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2218,11 +2393,11 @@ yyparse (void) c->v = ident->v; yyval = c; } -#line 2222 "tars.tab.cpp" +#line 2397 "tars.tab.cpp" break; - case 76: /* const_initializer: TARS_TRUE */ -#line 766 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 76: +#line 766 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2230,11 +2405,11 @@ yyparse (void) c->v = ident->v; yyval = c; } -#line 2234 "tars.tab.cpp" +#line 2409 "tars.tab.cpp" break; - case 77: /* const_initializer: TARS_IDENTIFIER */ -#line 774 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 77: +#line 774 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2247,11 +2422,11 @@ yyparse (void) c->v = ident->v; yyval = c; } -#line 2251 "tars.tab.cpp" +#line 2426 "tars.tab.cpp" break; - case 78: /* const_initializer: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 787 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 78: +#line 787 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2266,11 +2441,11 @@ yyparse (void) c->v = scoped->v + "::" + ident->v; yyval = c; } -#line 2270 "tars.tab.cpp" +#line 2445 "tars.tab.cpp" break; - case 79: /* const_def: TARS_CONST type_id '=' const_initializer */ -#line 807 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 79: +#line 807 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!np) @@ -2283,11 +2458,11 @@ yyparse (void) ConstPtr cPtr = np->createConst(t, c); yyval = cPtr; } -#line 2287 "tars.tab.cpp" +#line 2462 "tars.tab.cpp" break; - case 80: /* type_id: type TARS_IDENTIFIER */ -#line 825 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 80: +#line 825 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2296,11 +2471,11 @@ yyparse (void) yyval = GrammarBasePtr::dynamicCast(typeIdPtr); } -#line 2300 "tars.tab.cpp" +#line 2475 "tars.tab.cpp" break; - case 81: /* type_id: type TARS_IDENTIFIER '[' TARS_CONST_INTEGER ']' */ -#line 834 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 81: +#line 834 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-4])); IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast(yyvsp[-1]); @@ -2310,11 +2485,11 @@ yyparse (void) TypeIdPtr typeIdPtr = new TypeId(type, ident->v); yyval = GrammarBasePtr::dynamicCast(typeIdPtr); } -#line 2314 "tars.tab.cpp" +#line 2489 "tars.tab.cpp" break; - case 82: /* type_id: type '*' TARS_IDENTIFIER */ -#line 844 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 82: +#line 844 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-2])); //IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast($4); @@ -2324,11 +2499,11 @@ yyparse (void) TypeIdPtr typeIdPtr = new TypeId(type, ident->v); yyval = GrammarBasePtr::dynamicCast(typeIdPtr); } -#line 2328 "tars.tab.cpp" +#line 2503 "tars.tab.cpp" break; - case 83: /* type_id: type TARS_IDENTIFIER ':' TARS_CONST_INTEGER */ -#line 854 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 83: +#line 854 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-3]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2337,36 +2512,36 @@ yyparse (void) g_parse->checkArrayVaid(type,iPtrSize->v); yyval = GrammarBasePtr::dynamicCast(typeIdPtr); } -#line 2341 "tars.tab.cpp" +#line 2516 "tars.tab.cpp" break; - case 84: /* type_id: type keyword */ -#line 863 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 84: +#line 863 "/mnt/data/heer/ruanshudong/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"); } -#line 2350 "tars.tab.cpp" +#line 2525 "tars.tab.cpp" break; - case 85: /* type_id: type */ -#line 868 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 85: +#line 868 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("missing data member name"); } -#line 2358 "tars.tab.cpp" +#line 2533 "tars.tab.cpp" break; - case 86: /* type_id: error */ -#line 872 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 86: +#line 872 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("unkown type"); } -#line 2366 "tars.tab.cpp" +#line 2541 "tars.tab.cpp" break; - case 87: /* type: type_no ':' TARS_CONST_INTEGER */ -#line 881 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 87: +#line 881 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-2]); @@ -2375,131 +2550,131 @@ yyparse (void) type->setArray(iPtrSize->v); yyval = type; } -#line 2379 "tars.tab.cpp" +#line 2554 "tars.tab.cpp" break; - case 88: /* type: type_no */ -#line 890 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 88: +#line 890 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } -#line 2387 "tars.tab.cpp" +#line 2562 "tars.tab.cpp" break; - case 89: /* type: type_no ':' error */ -#line 894 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 89: +#line 894 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("array missing size"); } -#line 2395 "tars.tab.cpp" +#line 2570 "tars.tab.cpp" break; - case 90: /* type_no: TARS_BOOL */ -#line 903 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 90: +#line 903 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindBool); } -#line 2403 "tars.tab.cpp" +#line 2578 "tars.tab.cpp" break; - case 91: /* type_no: TARS_BYTE */ -#line 907 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 91: +#line 907 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindByte); } -#line 2411 "tars.tab.cpp" +#line 2586 "tars.tab.cpp" break; - case 92: /* type_no: TARS_UNSIGNED TARS_BYTE */ -#line 911 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 92: +#line 911 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort,true); } -#line 2419 "tars.tab.cpp" +#line 2594 "tars.tab.cpp" break; - case 93: /* type_no: TARS_SHORT */ -#line 915 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 93: +#line 915 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort); } -#line 2427 "tars.tab.cpp" +#line 2602 "tars.tab.cpp" break; - case 94: /* type_no: TARS_UNSIGNED TARS_SHORT */ -#line 919 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 94: +#line 919 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt,true); } -#line 2435 "tars.tab.cpp" +#line 2610 "tars.tab.cpp" break; - case 95: /* type_no: TARS_INT */ -#line 923 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 95: +#line 923 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt); } -#line 2443 "tars.tab.cpp" +#line 2618 "tars.tab.cpp" break; - case 96: /* type_no: TARS_UNSIGNED TARS_INT */ -#line 927 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 96: +#line 927 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong,true); } -#line 2451 "tars.tab.cpp" +#line 2626 "tars.tab.cpp" break; - case 97: /* type_no: TARS_LONG */ -#line 931 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 97: +#line 931 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong); } -#line 2459 "tars.tab.cpp" +#line 2634 "tars.tab.cpp" break; - case 98: /* type_no: TARS_FLOAT */ -#line 935 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 98: +#line 935 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindFloat); } -#line 2467 "tars.tab.cpp" +#line 2642 "tars.tab.cpp" break; - case 99: /* type_no: TARS_DOUBLE */ -#line 939 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 99: +#line 939 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindDouble); } -#line 2475 "tars.tab.cpp" +#line 2650 "tars.tab.cpp" break; - case 100: /* type_no: TARS_STRING */ -#line 943 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 100: +#line 943 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindString); } -#line 2483 "tars.tab.cpp" +#line 2658 "tars.tab.cpp" break; - case 101: /* type_no: vector */ -#line 947 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 101: +#line 947 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } -#line 2491 "tars.tab.cpp" +#line 2666 "tars.tab.cpp" break; - case 102: /* type_no: map */ -#line 951 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 102: +#line 951 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } -#line 2499 "tars.tab.cpp" +#line 2674 "tars.tab.cpp" break; - case 103: /* type_no: scoped_name */ -#line 955 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 103: +#line 955 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypePtr sp = g_parse->findUserType(ident->v); @@ -2512,76 +2687,76 @@ yyparse (void) g_parse->error("'" + ident->v + "' undefined!"); } } -#line 2516 "tars.tab.cpp" +#line 2691 "tars.tab.cpp" break; - case 104: /* vector: TARS_VECTOR '<' type '>' */ -#line 973 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 104: +#line 973 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createVector(TypePtr::dynamicCast(yyvsp[-1]))); } -#line 2524 "tars.tab.cpp" +#line 2699 "tars.tab.cpp" break; - case 105: /* vector: TARS_VECTOR '<' error */ -#line 977 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 105: +#line 977 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector error"); } -#line 2532 "tars.tab.cpp" +#line 2707 "tars.tab.cpp" break; - case 106: /* vector: TARS_VECTOR '<' type error */ -#line 981 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 106: +#line 981 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing '>'"); } -#line 2540 "tars.tab.cpp" +#line 2715 "tars.tab.cpp" break; - case 107: /* vector: TARS_VECTOR error */ -#line 985 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 107: +#line 985 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing type"); } -#line 2548 "tars.tab.cpp" +#line 2723 "tars.tab.cpp" break; - case 108: /* map: TARS_MAP '<' type ',' type '>' */ -#line 994 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 108: +#line 994 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createMap(TypePtr::dynamicCast(yyvsp[-3]), TypePtr::dynamicCast(yyvsp[-1]))); } -#line 2556 "tars.tab.cpp" +#line 2731 "tars.tab.cpp" break; - case 109: /* map: TARS_MAP '<' error */ -#line 998 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 109: +#line 998 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("map error"); } -#line 2564 "tars.tab.cpp" +#line 2739 "tars.tab.cpp" break; - case 110: /* scoped_name: TARS_IDENTIFIER */ -#line 1007 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 110: +#line 1007 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2571 "tars.tab.cpp" +#line 2746 "tars.tab.cpp" break; - case 111: /* scoped_name: TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1010 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 111: +#line 1010 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ident->v = "::" + ident->v; yyval = GrammarBasePtr::dynamicCast(ident); } -#line 2581 "tars.tab.cpp" +#line 2756 "tars.tab.cpp" break; - case 112: /* scoped_name: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1016 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 112: +#line 1016 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2589,186 +2764,186 @@ yyparse (void) scoped->v += ident->v; yyval = GrammarBasePtr::dynamicCast(scoped); } -#line 2593 "tars.tab.cpp" +#line 2768 "tars.tab.cpp" break; - case 113: /* keyword: TARS_STRUCT */ -#line 1029 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 113: +#line 1029 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2600 "tars.tab.cpp" +#line 2775 "tars.tab.cpp" break; - case 114: /* keyword: TARS_VOID */ -#line 1032 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 114: +#line 1032 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2607 "tars.tab.cpp" +#line 2782 "tars.tab.cpp" break; - case 115: /* keyword: TARS_BOOL */ -#line 1035 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 115: +#line 1035 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2614 "tars.tab.cpp" +#line 2789 "tars.tab.cpp" break; - case 116: /* keyword: TARS_BYTE */ -#line 1038 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 116: +#line 1038 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2621 "tars.tab.cpp" +#line 2796 "tars.tab.cpp" break; - case 117: /* keyword: TARS_SHORT */ -#line 1041 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 117: +#line 1041 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2628 "tars.tab.cpp" +#line 2803 "tars.tab.cpp" break; - case 118: /* keyword: TARS_INT */ -#line 1044 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 118: +#line 1044 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2635 "tars.tab.cpp" +#line 2810 "tars.tab.cpp" break; - case 119: /* keyword: TARS_FLOAT */ -#line 1047 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 119: +#line 1047 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2642 "tars.tab.cpp" +#line 2817 "tars.tab.cpp" break; - case 120: /* keyword: TARS_DOUBLE */ -#line 1050 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 120: +#line 1050 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2649 "tars.tab.cpp" +#line 2824 "tars.tab.cpp" break; - case 121: /* keyword: TARS_STRING */ -#line 1053 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 121: +#line 1053 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2656 "tars.tab.cpp" +#line 2831 "tars.tab.cpp" break; - case 122: /* keyword: TARS_VECTOR */ -#line 1056 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 122: +#line 1056 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2663 "tars.tab.cpp" +#line 2838 "tars.tab.cpp" break; - case 123: /* keyword: TARS_KEY */ -#line 1059 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 123: +#line 1059 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2670 "tars.tab.cpp" +#line 2845 "tars.tab.cpp" break; - case 124: /* keyword: TARS_MAP */ -#line 1062 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 124: +#line 1062 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2677 "tars.tab.cpp" +#line 2852 "tars.tab.cpp" break; - case 125: /* keyword: TARS_NAMESPACE */ -#line 1065 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 125: +#line 1065 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2684 "tars.tab.cpp" +#line 2859 "tars.tab.cpp" break; - case 126: /* keyword: TARS_INTERFACE */ -#line 1068 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 126: +#line 1068 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2691 "tars.tab.cpp" +#line 2866 "tars.tab.cpp" break; - case 127: /* keyword: TARS_OUT */ -#line 1071 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 127: +#line 1071 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2698 "tars.tab.cpp" +#line 2873 "tars.tab.cpp" break; - case 128: /* keyword: TARS_REQUIRE */ -#line 1074 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 128: +#line 1074 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2705 "tars.tab.cpp" +#line 2880 "tars.tab.cpp" break; - case 129: /* keyword: TARS_OPTIONAL */ -#line 1077 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 129: +#line 1077 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2712 "tars.tab.cpp" +#line 2887 "tars.tab.cpp" break; - case 130: /* keyword: TARS_CONST_INTEGER */ -#line 1080 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 130: +#line 1080 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2719 "tars.tab.cpp" +#line 2894 "tars.tab.cpp" break; - case 131: /* keyword: TARS_CONST_FLOAT */ -#line 1083 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 131: +#line 1083 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2726 "tars.tab.cpp" +#line 2901 "tars.tab.cpp" break; - case 132: /* keyword: TARS_FALSE */ -#line 1086 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 132: +#line 1086 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2733 "tars.tab.cpp" +#line 2908 "tars.tab.cpp" break; - case 133: /* keyword: TARS_TRUE */ -#line 1089 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 133: +#line 1089 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2740 "tars.tab.cpp" +#line 2915 "tars.tab.cpp" break; - case 134: /* keyword: TARS_STRING_LITERAL */ -#line 1092 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 134: +#line 1092 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2747 "tars.tab.cpp" +#line 2922 "tars.tab.cpp" break; - case 135: /* keyword: TARS_CONST */ -#line 1095 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 135: +#line 1095 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2754 "tars.tab.cpp" +#line 2929 "tars.tab.cpp" break; - case 136: /* keyword: TARS_ENUM */ -#line 1098 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 136: +#line 1098 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2761 "tars.tab.cpp" +#line 2936 "tars.tab.cpp" break; - case 137: /* keyword: TARS_UNSIGNED */ -#line 1101 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 137: +#line 1101 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2768 "tars.tab.cpp" +#line 2943 "tars.tab.cpp" break; -#line 2772 "tars.tab.cpp" +#line 2947 "tars.tab.cpp" default: break; } @@ -2783,10 +2958,11 @@ 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 ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; + YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; @@ -2810,14 +2986,50 @@ yyparse (void) yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); + yytoken = yychar == YYEMPTY ? 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 = YY_CAST (char *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, 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 @@ -2866,14 +3078,13 @@ 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 += YYSYMBOL_YYerror; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) @@ -2887,7 +3098,7 @@ yyparse (void) yydestruct ("Error: popping", - YY_ACCESSING_SYMBOL (yystate), yyvsp); + yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -2899,7 +3110,7 @@ yyparse (void) /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -2921,20 +3132,20 @@ yyparse (void) goto yyreturn; -#if !defined yyoverflow +#if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; - goto yyreturn; + /* Fall through. */ #endif -/*-------------------------------------------------------. -| yyreturn -- parsing is finished, clean up and return. | -`-------------------------------------------------------*/ +/*-----------------------------------------------------. +| yyreturn -- parsing is finished, return the result. | +`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -2951,18 +3162,20 @@ yyparse (void) while (yyssp != yyss) { yydestruct ("Cleanup: popping", - YY_ACCESSING_SYMBOL (+*yyssp), yyvsp); + yystos[+*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 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" +#line 1105 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" diff --git a/tools/tarsparse/tars.lex.cpp b/tools/tarsparse/tars.lex.cpp index e7cd6524..08a169e3 100644 --- a/tools/tarsparse/tars.lex.cpp +++ b/tools/tarsparse/tars.lex.cpp @@ -1,6 +1,6 @@ -#line 1 "tars.lex.cpp" +#line 2 "tars.lex.cpp" -#line 3 "tars.lex.cpp" +#line 4 "tars.lex.cpp" #define YY_INT_ALIGNED short int @@ -47,7 +47,6 @@ 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; @@ -156,7 +155,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef size_t yy_size_t; #endif -extern yy_size_t yyleng; +extern int yyleng; extern FILE *yyin, *yyout; @@ -173,7 +172,7 @@ extern FILE *yyin, *yyout; */ #define YY_LESS_LINENO(n) \ do { \ - yy_size_t yyl;\ + int yyl;\ for ( yyl = n; yyl < yyleng; ++yyl )\ if ( yytext[yyl] == '\n' )\ --yylineno;\ @@ -218,7 +217,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - yy_size_t yy_n_chars; + int 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 @@ -287,8 +286,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 yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ -yy_size_t yyleng; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int yyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = NULL; @@ -315,7 +314,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, yy_size_t len ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); void *yyalloc ( yy_size_t ); void *yyrealloc ( void *, yy_size_t ); @@ -368,7 +367,7 @@ static void yynoreturn yy_fatal_error ( const char* msg ); */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ - yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyleng = (int) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; @@ -511,7 +510,7 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 1 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" /** * Tencent is pleased to support the open source community by making Tars available. * @@ -527,7 +526,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/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 20 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" #include #include #include @@ -598,7 +597,7 @@ FILE *yyget_out ( void ); void yyset_out ( FILE * _out_str ); - yy_size_t yyget_leng ( void ); + int yyget_leng ( void ); char *yyget_text ( void ); @@ -667,7 +666,7 @@ static int input ( void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - yy_size_t n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -776,7 +775,7 @@ YY_DECL } { -#line 67 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 67 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" #line 782 "tars.lex.cpp" @@ -827,7 +826,7 @@ YY_DECL if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { - yy_size_t yyl; + int yyl; for ( yyl = 0; yyl < yyleng; ++yyl ) if ( yytext[yyl] == '\n' ) @@ -848,12 +847,12 @@ YY_DECL case 1: YY_RULE_SETUP -#line 69 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 69 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { BEGIN(INCL); } YY_BREAK case 2: YY_RULE_SETUP -#line 71 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 71 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { if ( include_file_stack_ptr >= MAX_INCLUDE_DEPTH ) { @@ -886,7 +885,7 @@ YY_RULE_SETUP YY_BREAK case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INCL): -#line 101 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 101 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { --include_file_stack_ptr; if ( include_file_stack_ptr < 0 ) @@ -905,14 +904,14 @@ case YY_STATE_EOF(INCL): YY_BREAK case 3: YY_RULE_SETUP -#line 117 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 117 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { return TARS_SCOPE_DELIMITER; } YY_BREAK case 4: YY_RULE_SETUP -#line 121 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 121 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { // C++ comment bool e = false; @@ -933,7 +932,7 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 139 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 139 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { // C comment bool e = false; @@ -984,7 +983,7 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 187 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 187 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { StringGrammarPtr ident = new StringGrammar; ident->v = yytext; @@ -995,7 +994,7 @@ YY_RULE_SETUP case 7: /* rule 7 can match eol */ YY_RULE_SETUP -#line 194 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 194 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { StringGrammarPtr ident = new StringGrammar; ident->v = yytext; @@ -1008,7 +1007,7 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 204 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 204 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { StringGrammarPtr str = new StringGrammar; bool e = false; @@ -1123,7 +1122,7 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 316 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 316 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { errno = 0; IntergerGrammarPtr ptr = new IntergerGrammar; @@ -1148,7 +1147,7 @@ YY_RULE_SETUP YY_BREAK case 10: YY_RULE_SETUP -#line 338 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 338 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { errno = 0; FloatGrammarPtr ptr = new FloatGrammar; @@ -1183,7 +1182,7 @@ YY_RULE_SETUP case 11: /* rule 11 can match eol */ YY_RULE_SETUP -#line 369 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 369 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { if(yytext[0] == '\n') { @@ -1193,7 +1192,7 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 376 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 376 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" { if(yytext[0] < 32 || yytext[0] > 126) { @@ -1212,7 +1211,7 @@ YY_RULE_SETUP YY_BREAK case 13: YY_RULE_SETUP -#line 392 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 392 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" ECHO; YY_BREAK #line 1218 "tars.lex.cpp" @@ -1400,7 +1399,7 @@ static int yy_get_next_buffer (void) else { - yy_size_t num_to_read = + int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -1414,7 +1413,7 @@ static int yy_get_next_buffer (void) if ( b->yy_is_our_buffer ) { - yy_size_t new_size = b->yy_buf_size * 2; + int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -1472,7 +1471,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. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + int 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 ) @@ -1561,7 +1560,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. */ - yy_size_t number_to_move = (yy_n_chars) + 2; + int 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 = @@ -1616,7 +1615,7 @@ static int yy_get_next_buffer (void) else { /* need more input */ - yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) @@ -1990,12 +1989,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, yy_size_t _yybytes_len ) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) { YY_BUFFER_STATE b; char *buf; yy_size_t n; - yy_size_t i; + int i; /* Get memory for full buffer, including space for trailing EOB's. */ n = (yy_size_t) (_yybytes_len + 2); @@ -2037,7 +2036,7 @@ static void yynoreturn yy_fatal_error (const char* msg ) do \ { \ /* Undo effects of setting up yytext. */ \ - yy_size_t yyless_macro_arg = (n); \ + int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = (yy_hold_char); \ (yy_c_buf_p) = yytext + yyless_macro_arg; \ @@ -2077,7 +2076,7 @@ FILE *yyget_out (void) /** Get the length of the current token. * */ -yy_size_t yyget_leng (void) +int yyget_leng (void) { return yyleng; } @@ -2230,7 +2229,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 392 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.l" +#line 392 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.l" diff --git a/tools/tarsparse/tars.tab.cpp b/tools/tarsparse/tars.tab.cpp index 4647924b..30a4b213 100644 --- a/tools/tarsparse/tars.tab.cpp +++ b/tools/tarsparse/tars.tab.cpp @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.7.6. */ +/* A Bison parser, made by GNU Bison 3.5.1. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -16,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 @@ -34,10 +34,6 @@ /* 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. @@ -45,11 +41,14 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -/* Identify Bison output, and Bison version. */ -#define YYBISON 30706 +/* Undocumented macros, especially those whose name start with YY_, + are private implementation details. Do not rely on them. */ + +/* Identify Bison output. */ +#define YYBISON 1 -/* Bison version string. */ -#define YYBISON_VERSION "3.7.6" +/* Bison version. */ +#define YYBISON_VERSION "3.5.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -67,7 +66,7 @@ /* First part of user prologue. */ -#line 17 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" +#line 17 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" #include #include @@ -81,7 +80,7 @@ using namespace std; #define YYDEBUG 1 #define YYINITDEPTH 10000 -#line 85 "tars.tab.cpp" +#line 84 "tars.tab.cpp" # ifndef YY_CAST # ifdef __cplusplus @@ -104,102 +103,78 @@ using namespace std; # endif # 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; +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Use api.header.include to #include this header + instead of duplicating it here. */ +#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 + +/* 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); + +#endif /* !YY_YY_TARS_TAB_HPP_INCLUDED */ @@ -240,18 +215,6 @@ typedef int_least16_t yytype_int16; typedef short yytype_int16; #endif -/* 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 - #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 \ @@ -311,7 +274,6 @@ typedef int yytype_uint16; #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) - /* Stored state numbers (used for stacks). */ typedef yytype_uint8 yy_state_t; @@ -330,7 +292,6 @@ typedef int yy_state_fast_t; # endif #endif - #ifndef YY_ATTRIBUTE_PURE # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) @@ -349,9 +310,9 @@ typedef int yy_state_fast_t; /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YY_USE(E) ((void) (E)) +# define YYUSE(E) ((void) (E)) #else -# define YY_USE(E) /* empty */ +# define YYUSE(E) /* empty */ #endif #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ @@ -388,7 +349,7 @@ typedef int yy_state_fast_t; #define YY_ASSERT(E) ((void) (0 && (E))) -#if !defined yyoverflow +#if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -453,7 +414,8 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif -#endif /* !defined yyoverflow */ +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + #if (! defined yyoverflow \ && (! defined __cplusplus \ @@ -529,16 +491,14 @@ union yyalloc /* YYNSTATES -- Number of states. */ #define YYNSTATES 199 -/* YYMAXUTOK -- Last valid token kind. */ +#define YYUNDEFTOK 2 #define YYMAXUTOK 288 /* 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) +#define YYTRANSLATE(YYX) \ + (0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM as returned by yylex. */ @@ -596,45 +556,32 @@ static const yytype_int16 yyrline[] = }; #endif -/** 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; - +#if YYDEBUG || YYERROR_VERBOSE || 0 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "\"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 + "$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 }; - -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_int16 yytoknum[] = @@ -645,7 +592,7 @@ static const yytype_int16 yytoknum[] = 285, 286, 287, 288, 59, 123, 125, 44, 61, 91, 93, 41, 42, 58, 60, 62 }; -#endif +# endif #define YYPACT_NINF (-146) @@ -721,9 +668,9 @@ static const yytype_int16 yypgoto[] = }; /* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_uint8 yydefgoto[] = +static const yytype_int16 yydefgoto[] = { - 0, 8, 9, 76, 80, 10, 11, 77, 12, 123, + -1, 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, @@ -920,10 +867,10 @@ static const yytype_int8 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 @@ -949,9 +896,10 @@ enum { YYENOMEM = -2 }; } \ while (0) -/* Backward compatibility with an undocumented macro. - Use YYerror or YYUNDEF. */ -#define YYERRCODE YYUNDEF +/* Error token number */ +#define YYTERROR 1 +#define YYERRCODE 256 + /* Enable debugging if requested. */ @@ -969,18 +917,18 @@ 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, Kind, Value, Location) \ +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Kind, Value); \ + Type, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) @@ -991,19 +939,18 @@ do { \ `-----------------------------------*/ static void -yy_symbol_value_print (FILE *yyo, - yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) +yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) { FILE *yyoutput = yyo; - YY_USE (yyoutput); + YYUSE (yyoutput); if (!yyvaluep) return; # ifdef YYPRINT - if (yykind < YYNTOKENS) - YYPRINT (yyo, yytoknum[yykind], *yyvaluep); + if (yytype < YYNTOKENS) + YYPRINT (yyo, yytoknum[yytype], *yyvaluep); # endif YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YY_USE (yykind); + YYUSE (yytype); YY_IGNORE_MAYBE_UNINITIALIZED_END } @@ -1013,13 +960,12 @@ yy_symbol_value_print (FILE *yyo, `---------------------------*/ static void -yy_symbol_print (FILE *yyo, - yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) +yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) { YYFPRINTF (yyo, "%s %s (", - yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); - yy_symbol_value_print (yyo, yykind, yyvaluep); + yy_symbol_value_print (yyo, yytype, yyvaluep); YYFPRINTF (yyo, ")"); } @@ -1052,8 +998,7 @@ do { \ `------------------------------------------------*/ static void -yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, - int yyrule) +yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, int yyrule) { int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; @@ -1065,8 +1010,9 @@ yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, - YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), - &yyvsp[(yyi + 1) - (yynrhs)]); + yystos[+yyssp[yyi + 1 - yynrhs]], + &yyvsp[(yyi + 1) - (yynrhs)] + ); YYFPRINTF (stderr, "\n"); } } @@ -1081,8 +1027,8 @@ do { \ multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ -# define YYDPRINTF(Args) ((void) 0) -# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ @@ -1105,30 +1051,259 @@ int yydebug; #endif +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S))) +# else +/* Return the length of YYSTR. */ +static YYPTRDIFF_T +yystrlen (const char *yystr) +{ + YYPTRDIFF_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 YYPTRDIFF_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYPTRDIFF_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; + else + goto append; + + append: + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + if (yyres) + return yystpcpy (yyres, yystr) - yyres; + else + return yystrlen (yystr); +} +# 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 (YYPTRDIFF_T *yymsg_alloc, char **yymsg, + yy_state_t *yyssp, int yytoken) +{ + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat: reported tokens (one for the "unexpected", + one per "expected"). */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Actual size of YYARG. */ + int yycount = 0; + /* Cumulated lengths of YYARG. */ + YYPTRDIFF_T yysize = 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]; + YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + yysize = yysize0; + 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]; + { + YYPTRDIFF_T yysize1 + = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else + return 2; + } + } + } + } + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + default: /* Avoid compiler warnings. */ + 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_ + } + + { + /* Don't count the "%s"s in the final size, but reserve room for + the terminator. */ + YYPTRDIFF_T yysize1 = yysize + (yystrlen (yyformat) - 2 * yycount) + 1; + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else + return 2; + } + + 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, - yysymbol_kind_t yykind, YYSTYPE *yyvaluep) +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) { - YY_USE (yyvaluep); + YYUSE (yyvaluep); if (!yymsg) yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YY_USE (yykind); + YYUSE (yytype); YY_IGNORE_MAYBE_UNINITIALIZED_END } -/* Lookahead token kind. */ + + +/* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ @@ -1137,8 +1312,6 @@ YYSTYPE yylval; int yynerrs; - - /*----------. | yyparse. | `----------*/ @@ -1146,36 +1319,43 @@ int yynerrs; int yyparse (void) { - yy_state_fast_t yystate = 0; + yy_state_fast_t yystate; /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus = 0; + int yyerrstatus; - /* Refer to the stacks through separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. - /* Their size. */ - YYPTRDIFF_T yystacksize = YYINITDEPTH; + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ - /* The state stack: array, bottom, top. */ + /* The state stack. */ yy_state_t yyssa[YYINITDEPTH]; - yy_state_t *yyss = yyssa; - yy_state_t *yyssp = yyss; + yy_state_t *yyss; + yy_state_t *yyssp; - /* The semantic value stack: array, bottom, top. */ + /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp = yyvs; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYPTRDIFF_T yystacksize; int yyn; - /* The return value of yyparse. */ int yyresult; - /* Lookahead symbol kind. */ - yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; /* 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; + YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf; +#endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) @@ -1183,8 +1363,15 @@ 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; @@ -1207,7 +1394,6 @@ yyparse (void) 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 @@ -1253,7 +1439,7 @@ yyparse (void) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } @@ -1292,29 +1478,18 @@ yyparse (void) /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { - YYDPRINTF ((stderr, "Reading a token\n")); + YYDPRINTF ((stderr, "Reading a token: ")); yychar = yylex (); } if (yychar <= YYEOF) { - yychar = YYEOF; - yytoken = YYSYMBOL_YYEOF; + yychar = yytoken = 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); @@ -1383,93 +1558,93 @@ yyparse (void) YY_REDUCE_PRINT (yyn); switch (yyn) { - case 3: /* $@1: %empty */ -#line 75 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 3: +#line 75 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1391 "tars.tab.cpp" +#line 1566 "tars.tab.cpp" break; - case 5: /* $@2: %empty */ -#line 79 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 5: +#line 79 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyerrok; } -#line 1399 "tars.tab.cpp" +#line 1574 "tars.tab.cpp" break; - case 7: /* definitions: definition */ -#line 84 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 7: +#line 84 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } -#line 1407 "tars.tab.cpp" +#line 1582 "tars.tab.cpp" break; - case 8: /* definitions: %empty */ -#line 88 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 8: +#line 88 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1414 "tars.tab.cpp" +#line 1589 "tars.tab.cpp" break; - case 9: /* definition: namespace_def */ -#line 96 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 9: +#line 96 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || NamespacePtr::dynamicCast(yyvsp[0])); } -#line 1422 "tars.tab.cpp" +#line 1597 "tars.tab.cpp" break; - case 10: /* definition: interface_def */ -#line 100 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 10: +#line 100 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || InterfacePtr::dynamicCast(yyvsp[0])); } -#line 1430 "tars.tab.cpp" +#line 1605 "tars.tab.cpp" break; - case 11: /* definition: struct_def */ -#line 104 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 11: +#line 104 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || StructPtr::dynamicCast(yyvsp[0])); } -#line 1438 "tars.tab.cpp" +#line 1613 "tars.tab.cpp" break; - case 12: /* definition: key_def */ -#line 108 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 12: +#line 108 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1445 "tars.tab.cpp" +#line 1620 "tars.tab.cpp" break; - case 13: /* definition: enum_def */ -#line 111 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 13: +#line 111 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || EnumPtr::dynamicCast(yyvsp[0])); } -#line 1453 "tars.tab.cpp" +#line 1628 "tars.tab.cpp" break; - case 14: /* definition: const_def */ -#line 115 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 14: +#line 115 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { assert(yyvsp[0] == 0 || ConstPtr::dynamicCast(yyvsp[0])); } -#line 1461 "tars.tab.cpp" +#line 1636 "tars.tab.cpp" break; - case 15: /* @3: %empty */ -#line 124 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 15: +#line 124 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } -#line 1469 "tars.tab.cpp" +#line 1644 "tars.tab.cpp" break; - case 16: /* enum_def: enum_id @3 '{' enumerator_list '}' */ -#line 128 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 16: +#line 128 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1483,11 +1658,11 @@ yyparse (void) yyval = yyvsp[-3]; } -#line 1487 "tars.tab.cpp" +#line 1662 "tars.tab.cpp" break; - case 17: /* enum_id: TARS_ENUM TARS_IDENTIFIER */ -#line 147 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 17: +#line 147 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { NamespacePtr c = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!c) @@ -1500,36 +1675,36 @@ yyparse (void) yyval = e; } -#line 1504 "tars.tab.cpp" +#line 1679 "tars.tab.cpp" break; - case 18: /* enum_id: TARS_ENUM keyword */ -#line 160 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 18: +#line 160 "/mnt/data/heer/ruanshudong/frameworkPro/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]; } -#line 1514 "tars.tab.cpp" +#line 1689 "tars.tab.cpp" break; - case 19: /* enumerator_list: enumerator ',' enumerator_list */ -#line 171 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 19: +#line 171 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[-1]; } -#line 1522 "tars.tab.cpp" +#line 1697 "tars.tab.cpp" break; - case 20: /* enumerator_list: enumerator */ -#line 175 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 20: +#line 175 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1529 "tars.tab.cpp" +#line 1704 "tars.tab.cpp" break; - case 21: /* enumerator: TARS_IDENTIFIER */ -#line 183 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 21: +#line 183 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1540,20 +1715,20 @@ yyparse (void) e->addMember(tPtr); yyval = e; } -#line 1544 "tars.tab.cpp" +#line 1719 "tars.tab.cpp" break; - case 22: /* enumerator: keyword */ -#line 194 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 22: +#line 194 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as enumerator"); } -#line 1553 "tars.tab.cpp" +#line 1728 "tars.tab.cpp" break; - case 23: /* enumerator: TARS_IDENTIFIER '=' const_initializer */ -#line 199 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 23: +#line 199 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(g_parse->createBuiltin(Builtin::KindLong)); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -1566,18 +1741,18 @@ yyparse (void) e->addMember(tPtr); yyval = e; } -#line 1570 "tars.tab.cpp" +#line 1745 "tars.tab.cpp" break; - case 24: /* enumerator: %empty */ -#line 212 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 24: +#line 212 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1577 "tars.tab.cpp" +#line 1752 "tars.tab.cpp" break; - case 25: /* @4: %empty */ -#line 220 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 25: +#line 220 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ContainerPtr c = g_parse->currentContainer(); @@ -1592,11 +1767,11 @@ yyparse (void) yyval = 0; } } -#line 1596 "tars.tab.cpp" +#line 1771 "tars.tab.cpp" break; - case 26: /* namespace_def: TARS_NAMESPACE TARS_IDENTIFIER @4 '{' definitions '}' */ -#line 235 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 26: +#line 235 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1608,11 +1783,11 @@ yyparse (void) yyval = 0; } } -#line 1612 "tars.tab.cpp" +#line 1787 "tars.tab.cpp" break; - case 27: /* $@5: %empty */ -#line 253 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 27: +#line 253 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-1]); StructPtr sp = StructPtr::dynamicCast(g_parse->findUserType(ident->v)); @@ -1623,18 +1798,18 @@ yyparse (void) g_parse->setKeyStruct(sp); } -#line 1627 "tars.tab.cpp" +#line 1802 "tars.tab.cpp" break; - case 28: /* key_def: TARS_KEY '[' scoped_name ',' $@5 key_members ']' */ -#line 264 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 28: +#line 264 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1634 "tars.tab.cpp" +#line 1809 "tars.tab.cpp" break; - case 29: /* key_members: TARS_IDENTIFIER */ -#line 272 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 29: +#line 272 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1647,11 +1822,11 @@ yyparse (void) yyval = 0; } } -#line 1651 "tars.tab.cpp" +#line 1826 "tars.tab.cpp" break; - case 30: /* key_members: key_members ',' TARS_IDENTIFIER */ -#line 285 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 30: +#line 285 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); StructPtr np = g_parse->getKeyStruct(); @@ -1664,11 +1839,11 @@ yyparse (void) yyval = 0; } } -#line 1668 "tars.tab.cpp" +#line 1843 "tars.tab.cpp" break; - case 31: /* @6: %empty */ -#line 304 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 31: +#line 304 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1685,11 +1860,11 @@ yyparse (void) yyval = 0; } } -#line 1689 "tars.tab.cpp" +#line 1864 "tars.tab.cpp" break; - case 32: /* interface_def: interface_id @6 '{' interface_exports '}' */ -#line 321 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 32: +#line 321 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1701,58 +1876,58 @@ yyparse (void) yyval = 0; } } -#line 1705 "tars.tab.cpp" +#line 1880 "tars.tab.cpp" break; - case 33: /* interface_id: TARS_INTERFACE TARS_IDENTIFIER */ -#line 338 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 33: +#line 338 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } -#line 1713 "tars.tab.cpp" +#line 1888 "tars.tab.cpp" break; - case 34: /* interface_id: TARS_INTERFACE keyword */ -#line 342 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 34: +#line 342 "/mnt/data/heer/ruanshudong/frameworkPro/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]; } -#line 1723 "tars.tab.cpp" +#line 1898 "tars.tab.cpp" break; - case 35: /* interface_exports: interface_export ';' interface_exports */ -#line 353 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 35: +#line 353 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1730 "tars.tab.cpp" +#line 1905 "tars.tab.cpp" break; - case 36: /* interface_exports: error ';' interface_exports */ -#line 356 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 36: +#line 356 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1737 "tars.tab.cpp" +#line 1912 "tars.tab.cpp" break; - case 37: /* interface_exports: interface_export */ -#line 359 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 37: +#line 359 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("`;' missing after definition"); } -#line 1745 "tars.tab.cpp" +#line 1920 "tars.tab.cpp" break; - case 38: /* interface_exports: %empty */ -#line 363 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 38: +#line 363 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1752 "tars.tab.cpp" +#line 1927 "tars.tab.cpp" break; - case 40: /* operation: operation_preamble parameters ')' */ -#line 377 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 40: +#line 377 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-2]) { @@ -1764,11 +1939,11 @@ yyparse (void) yyval = 0; } } -#line 1768 "tars.tab.cpp" +#line 1943 "tars.tab.cpp" break; - case 41: /* operation_preamble: return_type TARS_OP */ -#line 394 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 41: +#line 394 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -1792,26 +1967,26 @@ yyparse (void) yyval = 0; } } -#line 1796 "tars.tab.cpp" +#line 1971 "tars.tab.cpp" break; - case 43: /* return_type: TARS_VOID */ -#line 424 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 43: +#line 424 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = 0; } -#line 1804 "tars.tab.cpp" +#line 1979 "tars.tab.cpp" break; - case 44: /* parameters: %empty */ -#line 434 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 44: +#line 434 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 1811 "tars.tab.cpp" +#line 1986 "tars.tab.cpp" break; - case 45: /* parameters: type_id */ -#line 437 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 45: +#line 437 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1822,11 +1997,11 @@ yyparse (void) op->createParamDecl(tsp, false, false); } } -#line 1826 "tars.tab.cpp" +#line 2001 "tars.tab.cpp" break; - case 46: /* parameters: parameters ',' type_id */ -#line 448 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 46: +#line 448 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1837,11 +2012,11 @@ yyparse (void) op->createParamDecl(tsp, false, false); } } -#line 1841 "tars.tab.cpp" +#line 2016 "tars.tab.cpp" break; - case 47: /* parameters: out_qualifier type_id */ -#line 459 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 47: +#line 459 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1853,11 +2028,11 @@ yyparse (void) op->createParamDecl(tsp, isOutParam->v, false); } } -#line 1857 "tars.tab.cpp" +#line 2032 "tars.tab.cpp" break; - case 48: /* parameters: parameters ',' out_qualifier type_id */ -#line 471 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 48: +#line 471 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isOutParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1869,11 +2044,11 @@ yyparse (void) op->createParamDecl(tsp, isOutParam->v, false); } } -#line 1873 "tars.tab.cpp" +#line 2048 "tars.tab.cpp" break; - case 49: /* parameters: routekey_qualifier type_id */ -#line 483 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 49: +#line 483 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1885,11 +2060,11 @@ yyparse (void) op->createParamDecl(tsp, false, isRouteKeyParam->v); } } -#line 1889 "tars.tab.cpp" +#line 2064 "tars.tab.cpp" break; - case 50: /* parameters: parameters ',' routekey_qualifier type_id */ -#line 495 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 50: +#line 495 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr isRouteKeyParam = BoolGrammarPtr::dynamicCast(yyvsp[-1]); TypeIdPtr tsp = TypeIdPtr::dynamicCast(yyvsp[0]); @@ -1901,47 +2076,47 @@ yyparse (void) op->createParamDecl(tsp, false, isRouteKeyParam->v); } } -#line 1905 "tars.tab.cpp" +#line 2080 "tars.tab.cpp" break; - case 51: /* parameters: out_qualifier */ -#line 507 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 51: +#line 507 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("'out' must be defined with a type"); } -#line 1913 "tars.tab.cpp" +#line 2088 "tars.tab.cpp" break; - case 52: /* parameters: routekey_qualifier */ -#line 511 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 52: +#line 511 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("'routekey' must be defined with a type"); } -#line 1921 "tars.tab.cpp" +#line 2096 "tars.tab.cpp" break; - case 53: /* routekey_qualifier: TARS_ROUTE_KEY */ -#line 520 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 53: +#line 520 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr routekey = new BoolGrammar; routekey->v = true; yyval = GrammarBasePtr::dynamicCast(routekey); } -#line 1931 "tars.tab.cpp" +#line 2106 "tars.tab.cpp" break; - case 54: /* out_qualifier: TARS_OUT */ -#line 531 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 54: +#line 531 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { BoolGrammarPtr out = new BoolGrammar; out->v = true; yyval = GrammarBasePtr::dynamicCast(out); } -#line 1941 "tars.tab.cpp" +#line 2116 "tars.tab.cpp" break; - case 55: /* @7: %empty */ -#line 542 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 55: +#line 542 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); @@ -1963,11 +2138,11 @@ yyparse (void) g_parse->error("struct '" + ident->v + "' must definition in namespace"); } } -#line 1967 "tars.tab.cpp" +#line 2142 "tars.tab.cpp" break; - case 56: /* struct_def: struct_id @7 '{' struct_exports '}' */ -#line 564 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 56: +#line 564 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { if(yyvsp[-3]) { @@ -1982,68 +2157,68 @@ yyparse (void) g_parse->error("struct `" + st->getSid() + "' must have at least one member"); } } -#line 1986 "tars.tab.cpp" +#line 2161 "tars.tab.cpp" break; - case 57: /* struct_id: TARS_STRUCT TARS_IDENTIFIER */ -#line 584 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 57: +#line 584 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } -#line 1994 "tars.tab.cpp" +#line 2169 "tars.tab.cpp" break; - case 58: /* struct_id: TARS_STRUCT keyword */ -#line 588 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 58: +#line 588 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); g_parse->error("keyword `" + ident->v + "' cannot be used as struct name"); } -#line 2004 "tars.tab.cpp" +#line 2179 "tars.tab.cpp" break; - case 59: /* struct_id: TARS_STRUCT error */ -#line 594 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 59: +#line 594 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("abstract declarator '' used as declaration"); } -#line 2012 "tars.tab.cpp" +#line 2187 "tars.tab.cpp" break; - case 60: /* struct_exports: data_member ';' struct_exports */ -#line 603 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 60: +#line 603 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2020 "tars.tab.cpp" +#line 2195 "tars.tab.cpp" break; - case 61: /* struct_exports: data_member */ -#line 607 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 61: +#line 607 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("';' missing after definition"); } -#line 2028 "tars.tab.cpp" +#line 2203 "tars.tab.cpp" break; - case 62: /* struct_exports: %empty */ -#line 611 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 62: +#line 611 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2035 "tars.tab.cpp" +#line 2210 "tars.tab.cpp" break; - case 63: /* data_member: struct_type_id */ -#line 621 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 63: +#line 621 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } -#line 2043 "tars.tab.cpp" +#line 2218 "tars.tab.cpp" break; - case 64: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id */ -#line 630 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 64: +#line 630 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2061,11 +2236,11 @@ yyparse (void) yyval = 0; } } -#line 2065 "tars.tab.cpp" +#line 2240 "tars.tab.cpp" break; - case 65: /* struct_type_id: TARS_CONST_INTEGER TARS_REQUIRE type_id '=' const_initializer */ -#line 648 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 65: +#line 648 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2087,11 +2262,11 @@ yyparse (void) yyval = 0; } } -#line 2091 "tars.tab.cpp" +#line 2266 "tars.tab.cpp" break; - case 66: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id '=' const_initializer */ -#line 670 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 66: +#line 670 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2113,11 +2288,11 @@ yyparse (void) yyval = 0; } } -#line 2117 "tars.tab.cpp" +#line 2292 "tars.tab.cpp" break; - case 67: /* struct_type_id: TARS_CONST_INTEGER TARS_OPTIONAL type_id */ -#line 692 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 67: +#line 692 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StructPtr np = StructPtr::dynamicCast(g_parse->currentContainer()); if(np) @@ -2134,43 +2309,43 @@ yyparse (void) yyval = 0; } } -#line 2138 "tars.tab.cpp" +#line 2313 "tars.tab.cpp" break; - case 68: /* struct_type_id: TARS_REQUIRE type_id */ -#line 709 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 68: +#line 709 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } -#line 2146 "tars.tab.cpp" +#line 2321 "tars.tab.cpp" break; - case 69: /* struct_type_id: TARS_OPTIONAL type_id */ -#line 713 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 69: +#line 713 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag'"); } -#line 2154 "tars.tab.cpp" +#line 2329 "tars.tab.cpp" break; - case 70: /* struct_type_id: TARS_CONST_INTEGER type_id */ -#line 717 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 70: +#line 717 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'require' or 'optional'"); } -#line 2162 "tars.tab.cpp" +#line 2337 "tars.tab.cpp" break; - case 71: /* struct_type_id: type_id */ -#line 721 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 71: +#line 721 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("struct member need 'tag' or 'require' or 'optional'"); } -#line 2170 "tars.tab.cpp" +#line 2345 "tars.tab.cpp" break; - case 72: /* const_initializer: TARS_CONST_INTEGER */ -#line 730 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 72: +#line 730 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { IntergerGrammarPtr intVal = IntergerGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2180,11 +2355,11 @@ yyparse (void) c->v = sstr.str(); yyval = c; } -#line 2184 "tars.tab.cpp" +#line 2359 "tars.tab.cpp" break; - case 73: /* const_initializer: TARS_CONST_FLOAT */ -#line 740 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 73: +#line 740 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { FloatGrammarPtr floatVal = FloatGrammarPtr::dynamicCast(yyvsp[0]); ostringstream sstr; @@ -2194,11 +2369,11 @@ yyparse (void) c->v = sstr.str(); yyval = c; } -#line 2198 "tars.tab.cpp" +#line 2373 "tars.tab.cpp" break; - case 74: /* const_initializer: TARS_STRING_LITERAL */ -#line 750 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 74: +#line 750 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2206,11 +2381,11 @@ yyparse (void) c->v = ident->v; yyval = c; } -#line 2210 "tars.tab.cpp" +#line 2385 "tars.tab.cpp" break; - case 75: /* const_initializer: TARS_FALSE */ -#line 758 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 75: +#line 758 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2218,11 +2393,11 @@ yyparse (void) c->v = ident->v; yyval = c; } -#line 2222 "tars.tab.cpp" +#line 2397 "tars.tab.cpp" break; - case 76: /* const_initializer: TARS_TRUE */ -#line 766 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 76: +#line 766 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ConstGrammarPtr c = new ConstGrammar(); @@ -2230,11 +2405,11 @@ yyparse (void) c->v = ident->v; yyval = c; } -#line 2234 "tars.tab.cpp" +#line 2409 "tars.tab.cpp" break; - case 77: /* const_initializer: TARS_IDENTIFIER */ -#line 774 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 77: +#line 774 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2247,11 +2422,11 @@ yyparse (void) c->v = ident->v; yyval = c; } -#line 2251 "tars.tab.cpp" +#line 2426 "tars.tab.cpp" break; - case 78: /* const_initializer: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 787 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 78: +#line 787 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2266,11 +2441,11 @@ yyparse (void) c->v = scoped->v + "::" + ident->v; yyval = c; } -#line 2270 "tars.tab.cpp" +#line 2445 "tars.tab.cpp" break; - case 79: /* const_def: TARS_CONST type_id '=' const_initializer */ -#line 807 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 79: +#line 807 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { NamespacePtr np = NamespacePtr::dynamicCast(g_parse->currentContainer()); if(!np) @@ -2283,11 +2458,11 @@ yyparse (void) ConstPtr cPtr = np->createConst(t, c); yyval = cPtr; } -#line 2287 "tars.tab.cpp" +#line 2462 "tars.tab.cpp" break; - case 80: /* type_id: type TARS_IDENTIFIER */ -#line 825 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 80: +#line 825 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2296,11 +2471,11 @@ yyparse (void) yyval = GrammarBasePtr::dynamicCast(typeIdPtr); } -#line 2300 "tars.tab.cpp" +#line 2475 "tars.tab.cpp" break; - case 81: /* type_id: type TARS_IDENTIFIER '[' TARS_CONST_INTEGER ']' */ -#line 834 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 81: +#line 834 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-4])); IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast(yyvsp[-1]); @@ -2310,11 +2485,11 @@ yyparse (void) TypeIdPtr typeIdPtr = new TypeId(type, ident->v); yyval = GrammarBasePtr::dynamicCast(typeIdPtr); } -#line 2314 "tars.tab.cpp" +#line 2489 "tars.tab.cpp" break; - case 82: /* type_id: type '*' TARS_IDENTIFIER */ -#line 844 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 82: +#line 844 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = g_parse->createVector(TypePtr::dynamicCast(yyvsp[-2])); //IntergerGrammarPtr iPtrSize = IntergerGrammarPtr::dynamicCast($4); @@ -2324,11 +2499,11 @@ yyparse (void) TypeIdPtr typeIdPtr = new TypeId(type, ident->v); yyval = GrammarBasePtr::dynamicCast(typeIdPtr); } -#line 2328 "tars.tab.cpp" +#line 2503 "tars.tab.cpp" break; - case 83: /* type_id: type TARS_IDENTIFIER ':' TARS_CONST_INTEGER */ -#line 854 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 83: +#line 854 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-3]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[-2]); @@ -2337,36 +2512,36 @@ yyparse (void) g_parse->checkArrayVaid(type,iPtrSize->v); yyval = GrammarBasePtr::dynamicCast(typeIdPtr); } -#line 2341 "tars.tab.cpp" +#line 2516 "tars.tab.cpp" break; - case 84: /* type_id: type keyword */ -#line 863 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 84: +#line 863 "/mnt/data/heer/ruanshudong/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"); } -#line 2350 "tars.tab.cpp" +#line 2525 "tars.tab.cpp" break; - case 85: /* type_id: type */ -#line 868 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 85: +#line 868 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("missing data member name"); } -#line 2358 "tars.tab.cpp" +#line 2533 "tars.tab.cpp" break; - case 86: /* type_id: error */ -#line 872 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 86: +#line 872 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("unkown type"); } -#line 2366 "tars.tab.cpp" +#line 2541 "tars.tab.cpp" break; - case 87: /* type: type_no ':' TARS_CONST_INTEGER */ -#line 881 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 87: +#line 881 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { TypePtr type = TypePtr::dynamicCast(yyvsp[-2]); @@ -2375,131 +2550,131 @@ yyparse (void) type->setArray(iPtrSize->v); yyval = type; } -#line 2379 "tars.tab.cpp" +#line 2554 "tars.tab.cpp" break; - case 88: /* type: type_no */ -#line 890 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 88: +#line 890 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = yyvsp[0]; } -#line 2387 "tars.tab.cpp" +#line 2562 "tars.tab.cpp" break; - case 89: /* type: type_no ':' error */ -#line 894 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 89: +#line 894 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("array missing size"); } -#line 2395 "tars.tab.cpp" +#line 2570 "tars.tab.cpp" break; - case 90: /* type_no: TARS_BOOL */ -#line 903 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 90: +#line 903 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindBool); } -#line 2403 "tars.tab.cpp" +#line 2578 "tars.tab.cpp" break; - case 91: /* type_no: TARS_BYTE */ -#line 907 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 91: +#line 907 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindByte); } -#line 2411 "tars.tab.cpp" +#line 2586 "tars.tab.cpp" break; - case 92: /* type_no: TARS_UNSIGNED TARS_BYTE */ -#line 911 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 92: +#line 911 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort,true); } -#line 2419 "tars.tab.cpp" +#line 2594 "tars.tab.cpp" break; - case 93: /* type_no: TARS_SHORT */ -#line 915 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 93: +#line 915 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindShort); } -#line 2427 "tars.tab.cpp" +#line 2602 "tars.tab.cpp" break; - case 94: /* type_no: TARS_UNSIGNED TARS_SHORT */ -#line 919 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 94: +#line 919 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt,true); } -#line 2435 "tars.tab.cpp" +#line 2610 "tars.tab.cpp" break; - case 95: /* type_no: TARS_INT */ -#line 923 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 95: +#line 923 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindInt); } -#line 2443 "tars.tab.cpp" +#line 2618 "tars.tab.cpp" break; - case 96: /* type_no: TARS_UNSIGNED TARS_INT */ -#line 927 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 96: +#line 927 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong,true); } -#line 2451 "tars.tab.cpp" +#line 2626 "tars.tab.cpp" break; - case 97: /* type_no: TARS_LONG */ -#line 931 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 97: +#line 931 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindLong); } -#line 2459 "tars.tab.cpp" +#line 2634 "tars.tab.cpp" break; - case 98: /* type_no: TARS_FLOAT */ -#line 935 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 98: +#line 935 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindFloat); } -#line 2467 "tars.tab.cpp" +#line 2642 "tars.tab.cpp" break; - case 99: /* type_no: TARS_DOUBLE */ -#line 939 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 99: +#line 939 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindDouble); } -#line 2475 "tars.tab.cpp" +#line 2650 "tars.tab.cpp" break; - case 100: /* type_no: TARS_STRING */ -#line 943 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 100: +#line 943 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = g_parse->createBuiltin(Builtin::KindString); } -#line 2483 "tars.tab.cpp" +#line 2658 "tars.tab.cpp" break; - case 101: /* type_no: vector */ -#line 947 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 101: +#line 947 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } -#line 2491 "tars.tab.cpp" +#line 2666 "tars.tab.cpp" break; - case 102: /* type_no: map */ -#line 951 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 102: +#line 951 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(yyvsp[0]); } -#line 2499 "tars.tab.cpp" +#line 2674 "tars.tab.cpp" break; - case 103: /* type_no: scoped_name */ -#line 955 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 103: +#line 955 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); TypePtr sp = g_parse->findUserType(ident->v); @@ -2512,76 +2687,76 @@ yyparse (void) g_parse->error("'" + ident->v + "' undefined!"); } } -#line 2516 "tars.tab.cpp" +#line 2691 "tars.tab.cpp" break; - case 104: /* vector: TARS_VECTOR '<' type '>' */ -#line 973 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 104: +#line 973 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createVector(TypePtr::dynamicCast(yyvsp[-1]))); } -#line 2524 "tars.tab.cpp" +#line 2699 "tars.tab.cpp" break; - case 105: /* vector: TARS_VECTOR '<' error */ -#line 977 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 105: +#line 977 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector error"); } -#line 2532 "tars.tab.cpp" +#line 2707 "tars.tab.cpp" break; - case 106: /* vector: TARS_VECTOR '<' type error */ -#line 981 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 106: +#line 981 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing '>'"); } -#line 2540 "tars.tab.cpp" +#line 2715 "tars.tab.cpp" break; - case 107: /* vector: TARS_VECTOR error */ -#line 985 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 107: +#line 985 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("vector missing type"); } -#line 2548 "tars.tab.cpp" +#line 2723 "tars.tab.cpp" break; - case 108: /* map: TARS_MAP '<' type ',' type '>' */ -#line 994 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 108: +#line 994 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { yyval = GrammarBasePtr::dynamicCast(g_parse->createMap(TypePtr::dynamicCast(yyvsp[-3]), TypePtr::dynamicCast(yyvsp[-1]))); } -#line 2556 "tars.tab.cpp" +#line 2731 "tars.tab.cpp" break; - case 109: /* map: TARS_MAP '<' error */ -#line 998 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 109: +#line 998 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { g_parse->error("map error"); } -#line 2564 "tars.tab.cpp" +#line 2739 "tars.tab.cpp" break; - case 110: /* scoped_name: TARS_IDENTIFIER */ -#line 1007 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 110: +#line 1007 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2571 "tars.tab.cpp" +#line 2746 "tars.tab.cpp" break; - case 111: /* scoped_name: TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1010 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 111: +#line 1010 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); ident->v = "::" + ident->v; yyval = GrammarBasePtr::dynamicCast(ident); } -#line 2581 "tars.tab.cpp" +#line 2756 "tars.tab.cpp" break; - case 112: /* scoped_name: scoped_name TARS_SCOPE_DELIMITER TARS_IDENTIFIER */ -#line 1016 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 112: +#line 1016 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { StringGrammarPtr scoped = StringGrammarPtr::dynamicCast(yyvsp[-2]); StringGrammarPtr ident = StringGrammarPtr::dynamicCast(yyvsp[0]); @@ -2589,186 +2764,186 @@ yyparse (void) scoped->v += ident->v; yyval = GrammarBasePtr::dynamicCast(scoped); } -#line 2593 "tars.tab.cpp" +#line 2768 "tars.tab.cpp" break; - case 113: /* keyword: TARS_STRUCT */ -#line 1029 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 113: +#line 1029 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2600 "tars.tab.cpp" +#line 2775 "tars.tab.cpp" break; - case 114: /* keyword: TARS_VOID */ -#line 1032 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 114: +#line 1032 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2607 "tars.tab.cpp" +#line 2782 "tars.tab.cpp" break; - case 115: /* keyword: TARS_BOOL */ -#line 1035 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 115: +#line 1035 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2614 "tars.tab.cpp" +#line 2789 "tars.tab.cpp" break; - case 116: /* keyword: TARS_BYTE */ -#line 1038 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 116: +#line 1038 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2621 "tars.tab.cpp" +#line 2796 "tars.tab.cpp" break; - case 117: /* keyword: TARS_SHORT */ -#line 1041 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 117: +#line 1041 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2628 "tars.tab.cpp" +#line 2803 "tars.tab.cpp" break; - case 118: /* keyword: TARS_INT */ -#line 1044 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 118: +#line 1044 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2635 "tars.tab.cpp" +#line 2810 "tars.tab.cpp" break; - case 119: /* keyword: TARS_FLOAT */ -#line 1047 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 119: +#line 1047 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2642 "tars.tab.cpp" +#line 2817 "tars.tab.cpp" break; - case 120: /* keyword: TARS_DOUBLE */ -#line 1050 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 120: +#line 1050 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2649 "tars.tab.cpp" +#line 2824 "tars.tab.cpp" break; - case 121: /* keyword: TARS_STRING */ -#line 1053 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 121: +#line 1053 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2656 "tars.tab.cpp" +#line 2831 "tars.tab.cpp" break; - case 122: /* keyword: TARS_VECTOR */ -#line 1056 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 122: +#line 1056 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2663 "tars.tab.cpp" +#line 2838 "tars.tab.cpp" break; - case 123: /* keyword: TARS_KEY */ -#line 1059 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 123: +#line 1059 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2670 "tars.tab.cpp" +#line 2845 "tars.tab.cpp" break; - case 124: /* keyword: TARS_MAP */ -#line 1062 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 124: +#line 1062 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2677 "tars.tab.cpp" +#line 2852 "tars.tab.cpp" break; - case 125: /* keyword: TARS_NAMESPACE */ -#line 1065 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 125: +#line 1065 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2684 "tars.tab.cpp" +#line 2859 "tars.tab.cpp" break; - case 126: /* keyword: TARS_INTERFACE */ -#line 1068 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 126: +#line 1068 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2691 "tars.tab.cpp" +#line 2866 "tars.tab.cpp" break; - case 127: /* keyword: TARS_OUT */ -#line 1071 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 127: +#line 1071 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2698 "tars.tab.cpp" +#line 2873 "tars.tab.cpp" break; - case 128: /* keyword: TARS_REQUIRE */ -#line 1074 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 128: +#line 1074 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2705 "tars.tab.cpp" +#line 2880 "tars.tab.cpp" break; - case 129: /* keyword: TARS_OPTIONAL */ -#line 1077 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 129: +#line 1077 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2712 "tars.tab.cpp" +#line 2887 "tars.tab.cpp" break; - case 130: /* keyword: TARS_CONST_INTEGER */ -#line 1080 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 130: +#line 1080 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2719 "tars.tab.cpp" +#line 2894 "tars.tab.cpp" break; - case 131: /* keyword: TARS_CONST_FLOAT */ -#line 1083 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 131: +#line 1083 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2726 "tars.tab.cpp" +#line 2901 "tars.tab.cpp" break; - case 132: /* keyword: TARS_FALSE */ -#line 1086 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 132: +#line 1086 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2733 "tars.tab.cpp" +#line 2908 "tars.tab.cpp" break; - case 133: /* keyword: TARS_TRUE */ -#line 1089 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 133: +#line 1089 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2740 "tars.tab.cpp" +#line 2915 "tars.tab.cpp" break; - case 134: /* keyword: TARS_STRING_LITERAL */ -#line 1092 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 134: +#line 1092 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2747 "tars.tab.cpp" +#line 2922 "tars.tab.cpp" break; - case 135: /* keyword: TARS_CONST */ -#line 1095 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 135: +#line 1095 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2754 "tars.tab.cpp" +#line 2929 "tars.tab.cpp" break; - case 136: /* keyword: TARS_ENUM */ -#line 1098 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 136: +#line 1098 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2761 "tars.tab.cpp" +#line 2936 "tars.tab.cpp" break; - case 137: /* keyword: TARS_UNSIGNED */ -#line 1101 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" + case 137: +#line 1101 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" { } -#line 2768 "tars.tab.cpp" +#line 2943 "tars.tab.cpp" break; -#line 2772 "tars.tab.cpp" +#line 2947 "tars.tab.cpp" default: break; } @@ -2783,10 +2958,11 @@ 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 ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; + YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; @@ -2810,14 +2986,50 @@ yyparse (void) yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); + yytoken = yychar == YYEMPTY ? 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 = YY_CAST (char *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, 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 @@ -2866,14 +3078,13 @@ 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 += YYSYMBOL_YYerror; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) @@ -2887,7 +3098,7 @@ yyparse (void) yydestruct ("Error: popping", - YY_ACCESSING_SYMBOL (yystate), yyvsp); + yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -2899,7 +3110,7 @@ yyparse (void) /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -2921,20 +3132,20 @@ yyparse (void) goto yyreturn; -#if !defined yyoverflow +#if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; - goto yyreturn; + /* Fall through. */ #endif -/*-------------------------------------------------------. -| yyreturn -- parsing is finished, clean up and return. | -`-------------------------------------------------------*/ +/*-----------------------------------------------------. +| yyreturn -- parsing is finished, return the result. | +`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -2951,18 +3162,20 @@ yyparse (void) while (yyssp != yyss) { yydestruct ("Cleanup: popping", - YY_ACCESSING_SYMBOL (+*yyssp), yyvsp); + yystos[+*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 "/Volumes/MyData/centos/boat/boat-code/tarscpp/tools/tarsgrammar/tars.y" +#line 1105 "/mnt/data/heer/ruanshudong/frameworkPro/tarscpp/tools/tarsgrammar/tars.y" diff --git a/tools/tarsparse/tars.tab.hpp b/tools/tarsparse/tars.tab.hpp index 7a3f80ae..901fc7c0 100644 --- a/tools/tarsparse/tars.tab.hpp +++ b/tools/tarsparse/tars.tab.hpp @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.7.6. */ +/* A Bison parser, made by GNU Bison 3.5.1. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -16,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 @@ -31,9 +31,8 @@ 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. */ +/* Undocumented macros, especially those whose name start with YY_, + are private implementation details. Do not rely on them. */ #ifndef YY_YY_TARS_TAB_HPP_INCLUDED # define YY_YY_TARS_TAB_HPP_INCLUDED @@ -45,48 +44,43 @@ extern int yydebug; #endif -/* Token kinds. */ +/* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { - 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 */ + 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 }; - typedef enum yytokentype yytoken_kind_t; #endif /* Value type. */ diff --git a/util/src/CMakeLists.txt b/util/src/CMakeLists.txt index 31dcdf7f..6c3b7f99 100644 --- a/util/src/CMakeLists.txt +++ b/util/src/CMakeLists.txt @@ -28,7 +28,7 @@ add_library(tarsutil STATIC ${DIR_SRCS}) add_library(tarsutil_shared SHARED ${DIR_SRCS}) add_dependencies(tarsutil thirdparty) -target_link_libraries(tarsutil_shared mysqlclient) +#target_link_libraries(tarsutil_shared mysqlclient) target_compile_definitions(tarsutil_shared PRIVATE UTIL_DLL_EXPORT) if (TARS_SSL) From 5be0434edc3fa822723d6f3923d8f114c393bb1c Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 24 Oct 2024 09:57:41 +0800 Subject: [PATCH 36/44] cmake add ENABLE_SHARED, default OFF --- cmake/Common.cmake | 2 ++ mock/CMakeLists.txt | 18 ++++++++----- servant/libservant/CMakeLists.txt | 21 ++++++++------- tools/tarsparse/CMakeLists.txt | 16 ++++++----- util/src/CMakeLists.txt | 44 +++++++++++++++++-------------- 5 files changed, 59 insertions(+), 42 deletions(-) diff --git a/cmake/Common.cmake b/cmake/Common.cmake index 2bdeed60..bd6c8a2c 100755 --- a/cmake/Common.cmake +++ b/cmake/Common.cmake @@ -30,6 +30,7 @@ foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) endforeach() option(ONLY_LIB "option for only lib" ON) +option(ENABLE_SHARED "option for enable shared library" OFF) # option(TARS_OPENTRACKING "option for open tracking" OFF) @@ -130,5 +131,6 @@ message("TARS2CPP: ${TARS2CPP}") #message("TARS_OPENTRACKING: ${TARS_OPENTRACKING}") message("ONLY_LIB: ${ONLY_LIB}" ) message("TARS_STD_SHARED_PTR: ${TARS_STD_SHARED_PTR}" ) +message("ENABLE_SHARED: ${ENABLE_SHARED}" ) #------------------------------------------------------------- diff --git a/mock/CMakeLists.txt b/mock/CMakeLists.txt index cfe1eaef..87f601db 100755 --- a/mock/CMakeLists.txt +++ b/mock/CMakeLists.txt @@ -2,18 +2,22 @@ include_directories(../) file(GLOB_RECURSE SRC_FILES *.cpp) add_library(tarsmock STATIC ${SRC_FILES}) -add_library(tarsmock_shared SHARED ${SRC_FILES}) -target_link_libraries(tarsmock_shared tarsservant_shared tarsutil_shared) add_dependencies(tarsmock tarsservant) -add_dependencies(tarsmock_shared tarsservant) + install(DIRECTORY . DESTINATION include/mock FILES_MATCHING PATTERN "*.h") install(TARGETS tarsmock RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) -install(TARGETS tarsmock_shared RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) -if (WIN32) - install(FILES $ DESTINATION bin) -endif() +if(ENABLE_SHARED) + add_library(tarsmock_shared SHARED ${SRC_FILES}) + target_link_libraries(tarsmock_shared tarsservant_shared tarsutil_shared) + add_dependencies(tarsmock_shared tarsmock) + install(TARGETS tarsmock_shared RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + if (WIN32) + install(FILES $ DESTINATION bin) + endif() + +endif() diff --git a/servant/libservant/CMakeLists.txt b/servant/libservant/CMakeLists.txt index 3e46dcd0..9e234e25 100755 --- a/servant/libservant/CMakeLists.txt +++ b/servant/libservant/CMakeLists.txt @@ -16,14 +16,17 @@ install(TARGETS tarsservant LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) -add_library(tarsservant_shared SHARED ${DIR_SRCS}) -target_compile_definitions(tarsservant_shared PRIVATE SVT_DLL_EXPORT UTIL_USE_DLL) -target_link_libraries(tarsservant_shared tarsutil_shared tarsparse_shared) +if(ENABLE_SHARED) + add_library(tarsservant_shared SHARED ${DIR_SRCS}) -add_dependencies(tarsservant_shared COPY-SERVENT-TARS) -install(TARGETS tarsservant_shared - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) -if (WIN32) - install(FILES $ DESTINATION bin) + target_compile_definitions(tarsservant_shared PRIVATE SVT_DLL_EXPORT UTIL_USE_DLL) + target_link_libraries(tarsservant_shared tarsutil_shared tarsparse_shared) + + add_dependencies(tarsservant_shared tarsservant) + install(TARGETS tarsservant_shared + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) + if (WIN32) + install(FILES $ DESTINATION bin) + endif() endif() diff --git a/tools/tarsparse/CMakeLists.txt b/tools/tarsparse/CMakeLists.txt index ec25bf81..4a4181c7 100644 --- a/tools/tarsparse/CMakeLists.txt +++ b/tools/tarsparse/CMakeLists.txt @@ -29,7 +29,6 @@ foreach(LEC_YACC_SRC ${DEPENDS_LEC_YACC_SRC_LIST}) endforeach() add_library(${TARGETNAME} STATIC ${DIR_SRCS} ${DEPENDS_SRC_LIST}) -add_library(${TARGETNAME}_shared SHARED ${DIR_SRCS} ${DEPENDS_SRC_LIST}) if(UNIX) add_dependencies(${TARGETNAME} COPY-LEX-YACC) @@ -39,12 +38,17 @@ install(TARGETS ${TARGETNAME} LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) -install(TARGETS ${TARGETNAME}_shared - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) +if(ENABLE_SHARED) + add_library(${TARGETNAME}_shared SHARED ${DIR_SRCS} ${DEPENDS_SRC_LIST}) + add_dependencies(${TARGETNAME}_shared ${TARGETNAME}) + + install(TARGETS ${TARGETNAME}_shared + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) -if (WIN32) - install(FILES $ DESTINATION bin) + if (WIN32) + install(FILES $ DESTINATION bin) + endif() endif() FILE(GLOB HEADERS "*.h") diff --git a/util/src/CMakeLists.txt b/util/src/CMakeLists.txt index 6c3b7f99..279f9072 100644 --- a/util/src/CMakeLists.txt +++ b/util/src/CMakeLists.txt @@ -25,32 +25,36 @@ list(APPEND DIR_SRCS ${JUMP_SRC}) list(APPEND DIR_SRCS ${MAKE_SRC}) add_library(tarsutil STATIC ${DIR_SRCS}) -add_library(tarsutil_shared SHARED ${DIR_SRCS}) -add_dependencies(tarsutil thirdparty) -#target_link_libraries(tarsutil_shared mysqlclient) -target_compile_definitions(tarsutil_shared PRIVATE UTIL_DLL_EXPORT) - -if (TARS_SSL) - if (WIN32) - #windows动态编译需添加依赖库 - target_link_libraries(tarsutil_shared ${LIB_SSL}.lib ${LIB_CRYPTO}.lib Crypt32) - #else () - #linux动态编译未验证,暂时屏蔽 - #target_link_libraries(${LIB_TAF_UTIL} ${LIB_SSL}.a ${LIB_CRYPTO}.a) - endif () -endif() -add_dependencies(tarsutil_shared thirdparty) +add_dependencies(tarsutil thirdparty) install(TARGETS tarsutil LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) -install(TARGETS tarsutil_shared - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) -if (WIN32) - install(FILES $ DESTINATION bin) +if(ENABLE_SHARED) + add_library(tarsutil_shared SHARED ${DIR_SRCS}) + + target_link_libraries(tarsutil_shared libmysql) + target_compile_definitions(tarsutil_shared PRIVATE UTIL_DLL_EXPORT) + + if (TARS_SSL) + if (WIN32) + #windows动态编译需添加依赖库 + target_link_libraries(tarsutil_shared ${LIB_SSL}.lib ${LIB_CRYPTO}.lib Crypt32) + #else () + #linux动态编译未验证,暂时屏蔽 + #target_link_libraries(${LIB_TAF_UTIL} ${LIB_SSL}.a ${LIB_CRYPTO}.a) + endif () + endif() + add_dependencies(tarsutil_shared tarsutil) + + install(TARGETS tarsutil_shared + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) + if (WIN32) + install(FILES $ DESTINATION bin) + endif() endif() IF(WIN32) From 1c49d89fc5f048da1109da4fc92d4dde3efafe38 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 24 Oct 2024 10:18:26 +0800 Subject: [PATCH 37/44] util header use #pragma once --- servant/libservant/CMakeLists.txt | 4 ++-- util/include/util/tc_autoptr.h | 5 +---- util/include/util/tc_base64.h | 6 ++---- util/include/util/tc_bitmap.h | 7 +++---- util/include/util/tc_cas_queue.h | 5 +---- util/include/util/tc_cgi.h | 4 +--- util/include/util/tc_clientsocket.h | 5 +---- util/include/util/tc_common.h | 4 +--- util/include/util/tc_config.h | 5 +---- util/include/util/tc_consistent_hash.h | 4 +--- util/include/util/tc_consistent_hash_new.h | 4 +--- util/include/util/tc_coroutine.h | 4 +--- util/include/util/tc_coroutine_queue.h | 4 +--- util/include/util/tc_custom_protocol.h | 4 +--- util/include/util/tc_des.h | 4 +--- util/include/util/tc_docker.h | 4 +--- util/include/util/tc_dyn_object.h | 4 +--- util/include/util/tc_encoder.h | 8 +------- util/include/util/tc_epoller.h | 4 +--- util/include/util/tc_ex.h | 4 +--- util/include/util/tc_fcontext.h | 6 +----- util/include/util/tc_fifo.h | 4 +--- util/include/util/tc_file.h | 4 +--- util/include/util/tc_file_mutex.h | 4 +--- util/include/util/tc_grpc.h | 6 +----- util/include/util/tc_gzip.h | 5 +---- util/include/util/tc_hash_fun.h | 5 +---- util/include/util/tc_hashmap.h | 6 +----- util/include/util/tc_hashmap_compact.h | 5 +---- util/include/util/tc_http.h | 5 +---- util/include/util/tc_http2.h | 7 +------ util/include/util/tc_http_async.h | 4 +--- util/include/util/tc_json.h | 4 +--- util/include/util/tc_lock.h | 4 +--- util/include/util/tc_logger.h | 4 +--- util/include/util/tc_loop_queue.h | 4 +--- util/include/util/tc_malloc_chunk.h | 4 +--- util/include/util/tc_md5.h | 4 +--- util/include/util/tc_mem_chunk.h | 5 +---- util/include/util/tc_mem_queue.h | 4 +--- util/include/util/tc_mem_vector.h | 4 +--- util/include/util/tc_mmap.h | 7 ++----- util/include/util/tc_monitor.h | 5 +---- util/include/util/tc_multi_hashmap.h | 5 +---- util/include/util/tc_mysql.h | 4 +--- util/include/util/tc_network_buffer.h | 5 +---- util/include/util/tc_openssl.h | 1 - util/include/util/tc_option.h | 6 +----- util/include/util/tc_pack.h | 6 +----- util/include/util/tc_parsepara.h | 5 +---- util/include/util/tc_port.h | 4 +--- util/include/util/tc_proxy_info.h | 5 +---- util/include/util/tc_rbtree.h | 5 +---- util/include/util/tc_readers_writer_data.h | 6 +----- util/include/util/tc_sem_mutex.h | 7 +------ util/include/util/tc_sha.h | 5 +---- util/include/util/tc_shm.h | 5 +---- util/include/util/tc_singleton.h | 4 +--- util/include/util/tc_socket.h | 5 +---- util/include/util/tc_socket_async.h | 4 +--- util/include/util/tc_spin_lock.h | 4 +--- util/include/util/tc_squeue.h | 6 +----- util/include/util/tc_strptime.h | 8 ++------ util/include/util/tc_tea.h | 5 +---- util/include/util/tc_thread.h | 5 +---- util/include/util/tc_thread_cond.h | 5 +---- util/include/util/tc_thread_mutex.h | 5 +---- util/include/util/tc_thread_queue.h | 4 +--- util/include/util/tc_thread_rwlock.h | 5 +---- util/include/util/tc_timeout_queue.h | 7 ++----- util/include/util/tc_timeout_queue_new.h | 5 +---- util/include/util/tc_timeout_queue_noid.h | 5 +---- util/include/util/tc_timeprovider.h | 6 +----- util/include/util/tc_transceiver.h | 5 +---- util/include/util/tc_uuid_generator.h | 5 +---- util/include/util/tc_xml.h | 4 +--- 76 files changed, 82 insertions(+), 287 deletions(-) diff --git a/servant/libservant/CMakeLists.txt b/servant/libservant/CMakeLists.txt index 9e234e25..99ab3dc7 100755 --- a/servant/libservant/CMakeLists.txt +++ b/servant/libservant/CMakeLists.txt @@ -10,7 +10,7 @@ aux_source_directory(. DIR_SRCS) add_library(tarsservant STATIC ${DIR_SRCS}) -add_dependencies(tarsservant COPY-SERVENT-TARS) +add_dependencies(tarsservant tarsparse_shared COPY-SERVENT-TARS) install(TARGETS tarsservant LIBRARY DESTINATION lib @@ -20,7 +20,7 @@ if(ENABLE_SHARED) add_library(tarsservant_shared SHARED ${DIR_SRCS}) target_compile_definitions(tarsservant_shared PRIVATE SVT_DLL_EXPORT UTIL_USE_DLL) - target_link_libraries(tarsservant_shared tarsutil_shared tarsparse_shared) + target_link_libraries(tarsservant_shared tarsutil_shared) add_dependencies(tarsservant_shared tarsservant) install(TARGETS tarsservant_shared diff --git a/util/include/util/tc_autoptr.h b/util/include/util/tc_autoptr.h index e6430c72..7ac75fa3 100755 --- a/util/include/util/tc_autoptr.h +++ b/util/include/util/tc_autoptr.h @@ -14,9 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_AUTOPTR_H -#define __TC_AUTOPTR_H - +#pragma once #include "util/tc_ex.h" #include "util/tc_platform.h" #include @@ -534,4 +532,3 @@ inline bool operator<(const TC_AutoPtr& lhs, const TC_AutoPtr& rhs) } -#endif diff --git a/util/include/util/tc_base64.h b/util/include/util/tc_base64.h index 32168965..85202345 100644 --- a/util/include/util/tc_base64.h +++ b/util/include/util/tc_base64.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_BASE64_H -#define __TC_BASE64_H +#pragma once #include @@ -36,7 +35,7 @@ namespace tars * @brief This class provides standard base64 encoding and decoding methods. * @brief 该类提供标准的base64的编码解码 */ -class TC_Base64 +UTIL_DLL_API class TC_Base64 { public: /** @@ -139,4 +138,3 @@ class TC_Base64 }; } -#endif diff --git a/util/include/util/tc_bitmap.h b/util/include/util/tc_bitmap.h index babce72b..32df8ed3 100644 --- a/util/include/util/tc_bitmap.h +++ b/util/include/util/tc_bitmap.h @@ -14,13 +14,13 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_BIT_MAP_H__ -#define __TC_BIT_MAP_H__ +#pragma once #include #include #include #include "util/tc_ex.h" +#include "util/tc_platform.h" using namespace std; @@ -58,7 +58,7 @@ struct TC_BitMap_Exception : public TC_Exception * and then lock the blocks group by the tail number. * 注意群锁策略应该/8,然后按照尾号分群锁 */ -class TC_BitMap +class UTIL_DLL_API TC_BitMap { public: /** @@ -354,5 +354,4 @@ class TC_BitMap } -#endif diff --git a/util/include/util/tc_cas_queue.h b/util/include/util/tc_cas_queue.h index fe730e18..ee5d5d4b 100755 --- a/util/include/util/tc_cas_queue.h +++ b/util/include/util/tc_cas_queue.h @@ -1,6 +1,4 @@ -#ifndef __TC_CAS_QUEUE_H_ -#define __TC_CAS_QUEUE_H_ - +#pragma once #include #include #include @@ -269,5 +267,4 @@ template bool TC_CasQueue::empty() const } } -#endif diff --git a/util/include/util/tc_cgi.h b/util/include/util/tc_cgi.h index 9322237a..78be780b 100644 --- a/util/include/util/tc_cgi.h +++ b/util/include/util/tc_cgi.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_CGI_H -#define __TC_CGI_H +#pragma once #include #include @@ -691,4 +690,3 @@ class TC_Cgi } -#endif diff --git a/util/include/util/tc_clientsocket.h b/util/include/util/tc_clientsocket.h index f61654d4..4687348f 100644 --- a/util/include/util/tc_clientsocket.h +++ b/util/include/util/tc_clientsocket.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef _TC_CLIENTSOCKET_H__ -#define _TC_CLIENTSOCKET_H__ +#pragma once #include "util/tc_socket.h" #include @@ -875,4 +873,3 @@ class TC_UDPClient : public TC_ClientSocket } -#endif diff --git a/util/include/util/tc_common.h b/util/include/util/tc_common.h index b3f0d13b..8542d919 100644 --- a/util/include/util/tc_common.h +++ b/util/include/util/tc_common.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_COMMON_H -#define __TC_COMMON_H +#pragma once #include "util/tc_platform.h" @@ -1447,4 +1446,3 @@ bool TC_Common::equal(const unordered_map& mx , const unordered_map< } -#endif diff --git a/util/include/util/tc_config.h b/util/include/util/tc_config.h index 971b9591..e6447b0a 100644 --- a/util/include/util/tc_config.h +++ b/util/include/util/tc_config.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TC_CONFIG_H_ -#define __TC_CONFIG_H_ +#pragma once #include #include @@ -701,4 +699,3 @@ Add domain. Add a domain under the current domain. If the sadddomain domain alre }; } -#endif //_TC_CONFIG_H_ diff --git a/util/include/util/tc_consistent_hash.h b/util/include/util/tc_consistent_hash.h index c4688f1d..eb8ecd35 100644 --- a/util/include/util/tc_consistent_hash.h +++ b/util/include/util/tc_consistent_hash.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __CONSISTENT_HASH__ -#define __CONSISTENT_HASH__ +#pragma once #include "util/tc_md5.h" @@ -194,4 +193,3 @@ class TC_ConsistentHash }; } -#endif diff --git a/util/include/util/tc_consistent_hash_new.h b/util/include/util/tc_consistent_hash_new.h index dee6f415..fea88e34 100755 --- a/util/include/util/tc_consistent_hash_new.h +++ b/util/include/util/tc_consistent_hash_new.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_CONSISTENT_HASH_NEW_H_ -#define __TC_CONSISTENT_HASH_NEW_H_ +#pragma once #include "util/tc_md5.h" #include "util/tc_autoptr.h" @@ -223,4 +222,3 @@ class TC_ConsistentHashNew }; } -#endif diff --git a/util/include/util/tc_coroutine.h b/util/include/util/tc_coroutine.h index 0d62f5c9..9a84b730 100644 --- a/util/include/util/tc_coroutine.h +++ b/util/include/util/tc_coroutine.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef _TC_COROUTINES_H_ -#define _TC_COROUTINES_H_ +#pragma once #include #include @@ -786,4 +785,3 @@ class TC_Coroutine : public TC_Thread } -#endif diff --git a/util/include/util/tc_coroutine_queue.h b/util/include/util/tc_coroutine_queue.h index dea5e6e2..e2d586c7 100755 --- a/util/include/util/tc_coroutine_queue.h +++ b/util/include/util/tc_coroutine_queue.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_COROUTINE_QUEUE_H_ -#define __TC_COROUTINE_QUEUE_H_ +#pragma once #include #include @@ -359,5 +358,4 @@ template bool TC_CoroutineQueue::empty() const } } -#endif diff --git a/util/include/util/tc_custom_protocol.h b/util/include/util/tc_custom_protocol.h index d14e7a43..97411cc4 100644 --- a/util/include/util/tc_custom_protocol.h +++ b/util/include/util/tc_custom_protocol.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_CUSTOM_PROTOCOL_H_ -#define __TC_CUSTOM_PROTOCOL_H_ +#pragma once #include "util/tc_ex.h" #include "util/tc_port.h" @@ -141,5 +140,4 @@ class TC_CustomProtoRsp } -#endif diff --git a/util/include/util/tc_des.h b/util/include/util/tc_des.h index 59505774..bef6fab4 100644 --- a/util/include/util/tc_des.h +++ b/util/include/util/tc_des.h @@ -1,5 +1,4 @@ -#ifndef __TC_DES_H -#define __TC_DES_H +#pragma once #include #include @@ -190,5 +189,4 @@ class TC_Des }; } -#endif diff --git a/util/include/util/tc_docker.h b/util/include/util/tc_docker.h index 5cd1ae92..e95e459c 100755 --- a/util/include/util/tc_docker.h +++ b/util/include/util/tc_docker.h @@ -1,5 +1,4 @@ -#ifndef __TC_DOCKER_H_ -#define __TC_DOCKER_H_ +#pragma once #include #include @@ -213,5 +212,4 @@ class TC_Docker }; } -#endif diff --git a/util/include/util/tc_dyn_object.h b/util/include/util/tc_dyn_object.h index 6a0096b3..f18b3073 100644 --- a/util/include/util/tc_dyn_object.h +++ b/util/include/util/tc_dyn_object.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_DYN_OBJECT_H -#define __TC_DYN_OBJECT_H +#pragma once #include @@ -105,5 +104,4 @@ public: \ } -#endif diff --git a/util/include/util/tc_encoder.h b/util/include/util/tc_encoder.h index 1982b29f..e0a4ed1f 100644 --- a/util/include/util/tc_encoder.h +++ b/util/include/util/tc_encoder.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TC_ENCODER_H_ -#define __TC_ENCODER_H_ +#pragma once #include @@ -178,7 +176,3 @@ class TC_Encoder } - -#endif - - diff --git a/util/include/util/tc_epoller.h b/util/include/util/tc_epoller.h index 34813ce8..27246b5b 100755 --- a/util/include/util/tc_epoller.h +++ b/util/include/util/tc_epoller.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_EPOLLER_H_ -#define __TC_EPOLLER_H_ +#pragma once #include "util/tc_platform.h" #include "util/tc_socket.h" @@ -509,5 +508,4 @@ class TC_Epoller : public TC_TimerBase }; } -#endif diff --git a/util/include/util/tc_ex.h b/util/include/util/tc_ex.h index bc49835f..2b78c771 100644 --- a/util/include/util/tc_ex.h +++ b/util/include/util/tc_ex.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_EX_H -#define __TC_EX_H +#pragma once #include #include @@ -145,5 +144,4 @@ class TC_Exception : public exception } } -#endif diff --git a/util/include/util/tc_fcontext.h b/util/include/util/tc_fcontext.h index 13eb8d0b..2ffc284d 100644 --- a/util/include/util/tc_fcontext.h +++ b/util/include/util/tc_fcontext.h @@ -1,5 +1,4 @@ -#ifndef _TC_CONTEXT_FCONTEXT_H -#define _TC_CONTEXT_FCONTEXT_H +#pragma once namespace tars { @@ -16,6 +15,3 @@ 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) ); } - - -#endif diff --git a/util/include/util/tc_fifo.h b/util/include/util/tc_fifo.h index b6967eeb..9476b1e8 100644 --- a/util/include/util/tc_fifo.h +++ b/util/include/util/tc_fifo.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_FIFO_H -#define __TC_FIFO_H +#pragma once #include "util/tc_platform.h" @@ -157,5 +156,4 @@ class TC_Fifo #endif -#endif diff --git a/util/include/util/tc_file.h b/util/include/util/tc_file.h index db051152..4063fd8b 100644 --- a/util/include/util/tc_file.h +++ b/util/include/util/tc_file.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_FILE_H_ -#define __TC_FILE_H_ +#pragma once #include #include @@ -341,4 +340,3 @@ class TC_File static bool isPanfu(const string & sPath); }; } -#endif // TC_FILE_H diff --git a/util/include/util/tc_file_mutex.h b/util/include/util/tc_file_mutex.h index e1b23209..c7e4f193 100644 --- a/util/include/util/tc_file_mutex.h +++ b/util/include/util/tc_file_mutex.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_FILE_MUTEX_H -#define __TC_FILE_MUTEX_H +#pragma once #include "util/tc_platform.h" @@ -198,5 +197,4 @@ class TC_FileMutex } #endif -#endif diff --git a/util/include/util/tc_grpc.h b/util/include/util/tc_grpc.h index 4c2fdb52..842efe86 100644 --- a/util/include/util/tc_grpc.h +++ b/util/include/util/tc_grpc.h @@ -1,5 +1,4 @@ -#ifndef __TC_GRPC_PROTOCOL_H__ -#define __TC_GRPC_PROTOCOL_H__ +#pragma once #include #include "util/tc_network_buffer.h" @@ -108,6 +107,3 @@ class TC_GrpcClient : public TC_Http2Client } - - -#endif //__TC_GRPC_PROTOCOL_H__ \ No newline at end of file diff --git a/util/include/util/tc_gzip.h b/util/include/util/tc_gzip.h index 694e4087..97d8b3f2 100755 --- a/util/include/util/tc_gzip.h +++ b/util/include/util/tc_gzip.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_GZIP_H -#define __TC_GZIP_H +#pragma once #include "util/tc_platform.h" @@ -161,5 +160,3 @@ class TC_GZip }; } -//#endif -#endif diff --git a/util/include/util/tc_hash_fun.h b/util/include/util/tc_hash_fun.h index b0a5c7a0..62bb7bc0 100644 --- a/util/include/util/tc_hash_fun.h +++ b/util/include/util/tc_hash_fun.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef _TC_HASH_FUN_H_ -#define _TC_HASH_FUN_H_ +#pragma once #include #include @@ -201,5 +200,3 @@ struct magic_string_hash //////////////////////////////////////////////////////////////////// } -#endif - diff --git a/util/include/util/tc_hashmap.h b/util/include/util/tc_hashmap.h index f184831d..d3c6f73e 100755 --- a/util/include/util/tc_hashmap.h +++ b/util/include/util/tc_hashmap.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_HASHMAP_H__ -#define __TC_HASHMAP_H__ +#pragma once #include #include @@ -2323,6 +2322,3 @@ class TC_HashMap }; } - -#endif - diff --git a/util/include/util/tc_hashmap_compact.h b/util/include/util/tc_hashmap_compact.h index 6cf53b11..191d0205 100644 --- a/util/include/util/tc_hashmap_compact.h +++ b/util/include/util/tc_hashmap_compact.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_HASHMAP_COMPACT_H__ -#define __TC_HASHMAP_COMPACT_H__ +#pragma once #include #include @@ -2040,5 +2039,3 @@ class TC_HashMapCompact } -#endif - diff --git a/util/include/util/tc_http.h b/util/include/util/tc_http.h index 25625f3e..11221132 100755 --- a/util/include/util/tc_http.h +++ b/util/include/util/tc_http.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_HTTP_H_ -#define __TC_HTTP_H_ +#pragma once #include "util/tc_ex.h" #include "util/tc_port.h" @@ -1788,5 +1787,3 @@ class TC_HttpRequest : public TC_Http } -#endif - diff --git a/util/include/util/tc_http2.h b/util/include/util/tc_http2.h index cb1b52d5..5e06f858 100644 --- a/util/include/util/tc_http2.h +++ b/util/include/util/tc_http2.h @@ -1,5 +1,4 @@ -#ifndef __TC_HTTP2_H__ -#define __TC_HTTP2_H__ +#pragma once #include "util/tc_http.h" #include "util/tc_spin_lock.h" @@ -227,7 +226,3 @@ class TC_Http2Client : public TC_Http2 }; } - -//#endif - -#endif diff --git a/util/include/util/tc_http_async.h b/util/include/util/tc_http_async.h index 01fe6c0e..03031445 100644 --- a/util/include/util/tc_http_async.h +++ b/util/include/util/tc_http_async.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_HTTP_ASYNC_H_ -#define __TC_HTTP_ASYNC_H_ +#pragma once #include #include "util/tc_platform.h" @@ -497,5 +496,4 @@ class TC_HttpAsync : public TC_Thread, public TC_ThreadLock }; } -#endif diff --git a/util/include/util/tc_json.h b/util/include/util/tc_json.h index 0b390465..29a2daa2 100755 --- a/util/include/util/tc_json.h +++ b/util/include/util/tc_json.h @@ -15,8 +15,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_JSON_H -#define __TC_JSON_H +#pragma once #include #include @@ -433,4 +432,3 @@ class TC_JsonWriteOstream }; } -#endif diff --git a/util/include/util/tc_lock.h b/util/include/util/tc_lock.h index 729e8a4a..9def3025 100644 --- a/util/include/util/tc_lock.h +++ b/util/include/util/tc_lock.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef _TC_LOCK_H -#define _TC_LOCK_H +#pragma once #include #include @@ -312,5 +311,4 @@ class TC_RW_WLockT }; }; -#endif diff --git a/util/include/util/tc_logger.h b/util/include/util/tc_logger.h index 583ff1f2..1ccbe89b 100644 --- a/util/include/util/tc_logger.h +++ b/util/include/util/tc_logger.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_LOGGER_H -#define __TC_LOGGER_H +#pragma once #include "util/tc_autoptr.h" #include "util/tc_common.h" @@ -2037,5 +2036,4 @@ __global_logger_debug__.any() << TC_Common::now2msstr() <<"|" << std::this_threa } -#endif diff --git a/util/include/util/tc_loop_queue.h b/util/include/util/tc_loop_queue.h index cf189f0e..59092dad 100644 --- a/util/include/util/tc_loop_queue.h +++ b/util/include/util/tc_loop_queue.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef _TC_LOOP_QUEUE_H_ -#define _TC_LOOP_QUEUE_H_ +#pragma once #include #include @@ -227,5 +226,4 @@ class TC_LoopQueue } -#endif /* ----- #ifndef _TC_LOOP_QUEUE_H_ ----- */ diff --git a/util/include/util/tc_malloc_chunk.h b/util/include/util/tc_malloc_chunk.h index b0b59987..2d2ca457 100644 --- a/util/include/util/tc_malloc_chunk.h +++ b/util/include/util/tc_malloc_chunk.h @@ -13,8 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -#ifndef __TC_MALLOC_CHUNK_H -#define __TC_MALLOC_CHUNK_H +#pragma once #include #include @@ -880,4 +879,3 @@ namespace tars }; } -#endif diff --git a/util/include/util/tc_md5.h b/util/include/util/tc_md5.h index 6fe89215..ab4c2174 100644 --- a/util/include/util/tc_md5.h +++ b/util/include/util/tc_md5.h @@ -13,8 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -#ifndef __TC_MD5_H -#define __TC_MD5_H +#pragma once #include #include "util/tc_ex.h" @@ -239,4 +238,3 @@ class TC_MD5 }; } -#endif diff --git a/util/include/util/tc_mem_chunk.h b/util/include/util/tc_mem_chunk.h index d6a112ef..8b0e1eb2 100644 --- a/util/include/util/tc_mem_chunk.h +++ b/util/include/util/tc_mem_chunk.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TC_MEM_CHUNK_H__ -#define __TC_MEM_CHUNK_H__ +#pragma once #include #include @@ -798,4 +796,3 @@ class TC_MemMultiChunkAllocator } -#endif diff --git a/util/include/util/tc_mem_queue.h b/util/include/util/tc_mem_queue.h index ecaf28c3..cce5c9dc 100644 --- a/util/include/util/tc_mem_queue.h +++ b/util/include/util/tc_mem_queue.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_MEM_QUEUE_H__ -#define __TC_MEM_QUEUE_H__ +#pragma once #include @@ -277,4 +276,3 @@ class TC_MemQueue } -#endif diff --git a/util/include/util/tc_mem_vector.h b/util/include/util/tc_mem_vector.h index 60c415d0..e5d1ad1f 100644 --- a/util/include/util/tc_mem_vector.h +++ b/util/include/util/tc_mem_vector.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_MEM_VECTOR_H__ -#define __TC_MEM_VECTOR_H__ +#pragma once #include "util/tc_ex.h" #include @@ -376,4 +375,3 @@ string TC_MemVector::desc() const } -#endif diff --git a/util/include/util/tc_mmap.h b/util/include/util/tc_mmap.h index 00bab671..27255c11 100644 --- a/util/include/util/tc_mmap.h +++ b/util/include/util/tc_mmap.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_MMAP_H -#define __TC_MMAP_H +#pragma once #include "util/tc_platform.h" @@ -192,6 +191,4 @@ class TC_Mmap #endif }; -} -#endif - +} \ No newline at end of file diff --git a/util/include/util/tc_monitor.h b/util/include/util/tc_monitor.h index 1a345f9c..24627d88 100644 --- a/util/include/util/tc_monitor.h +++ b/util/include/util/tc_monitor.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef _TC_MONITOR_H -#define _TC_MONITOR_H +#pragma once #include "util/tc_thread_mutex.h" #include "util/tc_thread_cond.h" @@ -253,5 +251,4 @@ typedef TC_Monitor TC_ThreadLock; typedef TC_Monitor TC_ThreadRecLock; } -#endif diff --git a/util/include/util/tc_multi_hashmap.h b/util/include/util/tc_multi_hashmap.h index 54251f4a..d5da84bc 100644 --- a/util/include/util/tc_multi_hashmap.h +++ b/util/include/util/tc_multi_hashmap.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_MULTI_HASHMAP_H__ -#define __TC_MULTI_HASHMAP_H__ +#pragma once #include #include @@ -3338,5 +3337,3 @@ class TC_Multi_HashMap } -#endif - diff --git a/util/include/util/tc_mysql.h b/util/include/util/tc_mysql.h index 4ed154ba..17c3d587 100644 --- a/util/include/util/tc_mysql.h +++ b/util/include/util/tc_mysql.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_MYSQL_H -#define __TC_MYSQL_H +#pragma once #include "util/tc_platform.h" #include "mysql.h" @@ -806,4 +805,3 @@ class TC_Mysql }; } -#endif //_TC_MYSQL_H diff --git a/util/include/util/tc_network_buffer.h b/util/include/util/tc_network_buffer.h index 496a4e4a..6010d903 100755 --- a/util/include/util/tc_network_buffer.h +++ b/util/include/util/tc_network_buffer.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef TC_CPP_TC_NETWORKBUFFER_H -#define TC_CPP_TC_NETWORKBUFFER_H +#pragma once #include #include @@ -1059,4 +1057,3 @@ class TC_NetWorkBuffer } -#endif //TARS_CPP_TC_NETWORKBUFFER_H diff --git a/util/include/util/tc_openssl.h b/util/include/util/tc_openssl.h index 6b7b5127..f6706316 100644 --- a/util/include/util/tc_openssl.h +++ b/util/include/util/tc_openssl.h @@ -16,7 +16,6 @@ #pragma once - #include #include #include "util/tc_network_buffer.h" diff --git a/util/include/util/tc_option.h b/util/include/util/tc_option.h index 8501eedc..8a5c6268 100644 --- a/util/include/util/tc_option.h +++ b/util/include/util/tc_option.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TC_OPTION_H -#define __TC_OPTION_H +#pragma once #include #include @@ -167,5 +165,3 @@ class TC_Option } -#endif - diff --git a/util/include/util/tc_pack.h b/util/include/util/tc_pack.h index 78fdb693..075a7b84 100644 --- a/util/include/util/tc_pack.h +++ b/util/include/util/tc_pack.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TC_PACK_H_ -#define __TC_PACK_H_ +#pragma once #include "util/tc_platform.h" #include @@ -819,5 +817,3 @@ inline void decode(TC_PackOut &po, map &t) } - -#endif diff --git a/util/include/util/tc_parsepara.h b/util/include/util/tc_parsepara.h index 07b15c28..21826f1c 100644 --- a/util/include/util/tc_parsepara.h +++ b/util/include/util/tc_parsepara.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TC_PARSEPARA_H -#define __TC_PARSEPARA_H +#pragma once #include #include @@ -254,4 +252,3 @@ class TC_Parsepara }; } -#endif /*_TC_PARSEPARA_H*/ diff --git a/util/include/util/tc_port.h b/util/include/util/tc_port.h index ec33f4f8..92c19f7a 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -1,5 +1,4 @@ -#ifndef __TC_PORT_H -#define __TC_PORT_H +#pragma once #include "util/tc_platform.h" #include "util/tc_ex.h" @@ -385,4 +384,3 @@ class TC_Port } -#endif diff --git a/util/include/util/tc_proxy_info.h b/util/include/util/tc_proxy_info.h index 64b18f4e..1fe08df3 100644 --- a/util/include/util/tc_proxy_info.h +++ b/util/include/util/tc_proxy_info.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef TC_CPP_PROXYINFO_H -#define TC_CPP_PROXYINFO_H +#pragma once #include "util/tc_clientsocket.h" @@ -283,4 +281,3 @@ class TC_ProxyHttp : public TC_ProxyInfo } -#endif //TARS_CPP_PROXYINFO_H diff --git a/util/include/util/tc_rbtree.h b/util/include/util/tc_rbtree.h index 0633d792..376209db 100644 --- a/util/include/util/tc_rbtree.h +++ b/util/include/util/tc_rbtree.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TC_RBTREE_H -#define __TC_RBTREE_H +#pragma once #include #include @@ -1971,4 +1969,3 @@ class TC_RBTree } -#endif diff --git a/util/include/util/tc_readers_writer_data.h b/util/include/util/tc_readers_writer_data.h index 9715bd2c..3d02f56c 100644 --- a/util/include/util/tc_readers_writer_data.h +++ b/util/include/util/tc_readers_writer_data.h @@ -13,10 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TC_READERS_WRITER_DATA_H__ -#define __TC_READERS_WRITER_DATA_H__ - +#pragma once namespace tars { @@ -80,4 +77,3 @@ class TC_ReadersWriterData }; } -#endif diff --git a/util/include/util/tc_sem_mutex.h b/util/include/util/tc_sem_mutex.h index b04c2509..1822a0c1 100644 --- a/util/include/util/tc_sem_mutex.h +++ b/util/include/util/tc_sem_mutex.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_SEM_MUTEX_H -#define __TC_SEM_MUTEX_H +#pragma once #include "util/tc_platform.h" @@ -195,7 +194,3 @@ class TC_SemMutex }; } - -#endif - -//#endif diff --git a/util/include/util/tc_sha.h b/util/include/util/tc_sha.h index 95b85935..5866a90f 100644 --- a/util/include/util/tc_sha.h +++ b/util/include/util/tc_sha.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_TC_SHA_H -#define __TARS_TC_SHA_H +#pragma once #include #include @@ -173,5 +171,4 @@ class TC_SHA }; } -#endif diff --git a/util/include/util/tc_shm.h b/util/include/util/tc_shm.h index 00a2a37c..e2c18dea 100644 --- a/util/include/util/tc_shm.h +++ b/util/include/util/tc_shm.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TC_SHM_H__ -#define __TC_SHM_H__ +#pragma once #include "util/tc_platform.h" #if TARGET_PLATFORM_LINUX || TARGET_PLATFORM_IOS @@ -181,4 +179,3 @@ class TC_Shm } -#endif diff --git a/util/include/util/tc_singleton.h b/util/include/util/tc_singleton.h index 1b279f31..132ebb2f 100644 --- a/util/include/util/tc_singleton.h +++ b/util/include/util/tc_singleton.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TC_SINGLETON_H__ -#define __TC_SINGLETON_H__ +#pragma once #include "util/tc_monitor.h" #include @@ -325,4 +324,3 @@ template class CreatePolicy, template class Lif atomic TC_Singleton::__pInstance = {nullptr}; } -#endif diff --git a/util/include/util/tc_socket.h b/util/include/util/tc_socket.h index 7e91b5a2..25335665 100644 --- a/util/include/util/tc_socket.h +++ b/util/include/util/tc_socket.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TC_SOCKET_H -#define __TC_SOCKET_H +#pragma once #include "util/tc_platform.h" @@ -655,4 +653,3 @@ class TC_Socket }; } -#endif diff --git a/util/include/util/tc_socket_async.h b/util/include/util/tc_socket_async.h index eb852d9e..83f5ab45 100755 --- a/util/include/util/tc_socket_async.h +++ b/util/include/util/tc_socket_async.h @@ -1,5 +1,4 @@ -#ifndef __TC_SOCKET_ASYNC_H_ -#define __TC_SOCKET_ASYNC_H_ +#pragma once #include "util/tc_platform.h" #include "util/tc_autoptr.h" @@ -727,4 +726,3 @@ class UTIL_DLL_API TC_SocketAsyncCore : public TC_Singleton } -#endif diff --git a/util/include/util/tc_spin_lock.h b/util/include/util/tc_spin_lock.h index a2f9d29f..ee15ff89 100755 --- a/util/include/util/tc_spin_lock.h +++ b/util/include/util/tc_spin_lock.h @@ -1,6 +1,5 @@  -#ifndef __TC_SPIN_LOCK_H -#define __TC_SPIN_LOCK_H +#pragma once #include "util/tc_platform.h" #include @@ -40,4 +39,3 @@ class UTIL_DLL_API TC_SpinLock }; } -#endif diff --git a/util/include/util/tc_squeue.h b/util/include/util/tc_squeue.h index d772967e..7b10550b 100644 --- a/util/include/util/tc_squeue.h +++ b/util/include/util/tc_squeue.h @@ -13,12 +13,9 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TC_SQueue_H__ -#define __TC_SQueue_H__ +#pragma once #include -// #include #include #include #include @@ -247,4 +244,3 @@ class TC_SQueue }; } -#endif diff --git a/util/include/util/tc_strptime.h b/util/include/util/tc_strptime.h index 83516171..a57cecd5 100644 --- a/util/include/util/tc_strptime.h +++ b/util/include/util/tc_strptime.h @@ -1,11 +1,7 @@ -#ifndef __TC_STRPTIME_H__ -#define __TC_STRPTIME_H__ - + +#pragma once #ifdef TARGET_PLATFORM_WINDOWS char * strptime(const char *buf, const char *fmt, struct tm *tm); #endif - -#endif - diff --git a/util/include/util/tc_tea.h b/util/include/util/tc_tea.h index e5ff9bbe..d41f41db 100644 --- a/util/include/util/tc_tea.h +++ b/util/include/util/tc_tea.h @@ -1,5 +1,4 @@ -#ifndef _TC_TEA_H_ -#define _TC_TEA_H_ +#pragma once #include "util/tc_platform.h" #include @@ -62,5 +61,3 @@ class TC_Tea } -#endif - diff --git a/util/include/util/tc_thread.h b/util/include/util/tc_thread.h index 42b9c091..84af43c3 100644 --- a/util/include/util/tc_thread.h +++ b/util/include/util/tc_thread.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TC_THREAD_H_ -#define __TC_THREAD_H_ +#pragma once #include #include @@ -258,5 +256,4 @@ class TC_Thread : public TC_Runable }; } -#endif diff --git a/util/include/util/tc_thread_cond.h b/util/include/util/tc_thread_cond.h index ae7e07dd..5c38f16b 100644 --- a/util/include/util/tc_thread_cond.h +++ b/util/include/util/tc_thread_cond.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef _TC_THREAD_COND_H -#define _TC_THREAD_COND_H +#pragma once #include #include @@ -109,5 +108,3 @@ class TC_ThreadCond } -#endif - diff --git a/util/include/util/tc_thread_mutex.h b/util/include/util/tc_thread_mutex.h index 69616533..df16209f 100644 --- a/util/include/util/tc_thread_mutex.h +++ b/util/include/util/tc_thread_mutex.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TC_THREAD_MUTEX_H -#define __TC_THREAD_MUTEX_H +#pragma once #include "util/tc_lock.h" #include "util/tc_platform.h" @@ -131,5 +129,4 @@ class UTIL_DLL_API TC_ThreadRecMutex }; } -#endif diff --git a/util/include/util/tc_thread_queue.h b/util/include/util/tc_thread_queue.h index bce2c3a5..62f66d42 100644 --- a/util/include/util/tc_thread_queue.h +++ b/util/include/util/tc_thread_queue.h @@ -13,8 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -#ifndef __TC_THREAD_QUEUE_H_ -#define __TC_THREAD_QUEUE_H_ +#pragma once #include #include @@ -438,5 +437,4 @@ template bool TC_ThreadQueue::wait(size_t millseco } } -#endif diff --git a/util/include/util/tc_thread_rwlock.h b/util/include/util/tc_thread_rwlock.h index 285d213b..55073a20 100644 --- a/util/include/util/tc_thread_rwlock.h +++ b/util/include/util/tc_thread_rwlock.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TC_THREAD_RWLOCK_H -#define __TC_THREAD_RWLOCK_H +#pragma once #include #include @@ -141,4 +139,3 @@ typedef TC_RW_RLockT TC_ThreadRLock; typedef TC_RW_WLockT TC_ThreadWLock; } -#endif diff --git a/util/include/util/tc_timeout_queue.h b/util/include/util/tc_timeout_queue.h index e5413438..96dce430 100644 --- a/util/include/util/tc_timeout_queue.h +++ b/util/include/util/tc_timeout_queue.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TC_TIMEOUT_QUEUE_H -#define __TC_TIMEOUT_QUEUE_H +#pragma once #include #include @@ -487,5 +485,4 @@ template bool TC_TimeoutQueue::swap(deque &q) return true; } ///////////////////////////////////////////////////////////////// -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/util/include/util/tc_timeout_queue_new.h b/util/include/util/tc_timeout_queue_new.h index 733bfdf3..b50b2145 100644 --- a/util/include/util/tc_timeout_queue_new.h +++ b/util/include/util/tc_timeout_queue_new.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TC_TIMEOUT_QUEUE_NEW_H -#define __TC_TIMEOUT_QUEUE_NEW_H +#pragma once #include #include @@ -340,4 +338,3 @@ template bool TC_TimeoutQueueNew::erase(uint32_t uniqId, T & t) } ///////////////////////////////////////////////////////////////// } -#endif diff --git a/util/include/util/tc_timeout_queue_noid.h b/util/include/util/tc_timeout_queue_noid.h index 3fcaaa2f..c4f81863 100644 --- a/util/include/util/tc_timeout_queue_noid.h +++ b/util/include/util/tc_timeout_queue_noid.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef _TC_TIMEOUT_QUEUE_NOID_H_ -#define _TC_TIMEOUT_QUEUE_NOID_H_ +#pragma once #include #include @@ -222,4 +220,3 @@ template bool TC_TimeoutQueueNoID::timeout(T & t) } ///////////////////////////////////////////////////////////////// } -#endif diff --git a/util/include/util/tc_timeprovider.h b/util/include/util/tc_timeprovider.h index 027761f6..6e27c17e 100644 --- a/util/include/util/tc_timeprovider.h +++ b/util/include/util/tc_timeprovider.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TC_TIME_PROVIDER_H_ -#define __TC_TIME_PROVIDER_H_ +#pragma once #include #include "util/tc_platform.h" @@ -145,5 +143,3 @@ class UTIL_DLL_API TC_TimeProvider : public TC_Thread } -#endif - diff --git a/util/include/util/tc_transceiver.h b/util/include/util/tc_transceiver.h index a3674024..b840e1fa 100644 --- a/util/include/util/tc_transceiver.h +++ b/util/include/util/tc_transceiver.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef TC_CPP_TRANSCEIVER_H -#define TC_CPP_TRANSCEIVER_H +#pragma once #include #include "util/tc_platform.h" @@ -760,4 +758,3 @@ class TC_UDPTransceiver : public TC_Transceiver } -#endif diff --git a/util/include/util/tc_uuid_generator.h b/util/include/util/tc_uuid_generator.h index 7d7449ce..7596f06e 100644 --- a/util/include/util/tc_uuid_generator.h +++ b/util/include/util/tc_uuid_generator.h @@ -1,6 +1,4 @@ - -#ifndef __TC_UUID_GENERATOR_H -#define __TC_UUID_GENERATOR_H +#pragma once #include "util/tc_platform.h" #if TARGET_PLATFORM_LINUX || TARGET_PLATFORM_IOS @@ -130,4 +128,3 @@ class TC_UUIDGenerator : public TC_Singleton } -#endif //__TC_UUID_GENERATOR_H diff --git a/util/include/util/tc_xml.h b/util/include/util/tc_xml.h index 7f83a534..aa592940 100755 --- a/util/include/util/tc_xml.h +++ b/util/include/util/tc_xml.h @@ -1,5 +1,4 @@ -#ifndef __TC_XML_H_ -#define __TC_XML_H_ +#pragma once #include #include @@ -222,5 +221,4 @@ class TC_Xml } -#endif From 402a5eef11e4843a236235c881329ac543c89b99 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 24 Oct 2024 10:19:39 +0800 Subject: [PATCH 38/44] fix tc_base64 header bug --- util/include/util/tc_base64.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/include/util/tc_base64.h b/util/include/util/tc_base64.h index 85202345..45ba0058 100644 --- a/util/include/util/tc_base64.h +++ b/util/include/util/tc_base64.h @@ -15,6 +15,7 @@ */ #pragma once +#include "util/tc_platform.h" #include @@ -35,7 +36,7 @@ namespace tars * @brief This class provides standard base64 encoding and decoding methods. * @brief 该类提供标准的base64的编码解码 */ -UTIL_DLL_API class TC_Base64 +class UTIL_DLL_API TC_Base64 { public: /** From 15f4595dcb73bcc2d72b3e4ae6a8bc8549e8019d Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Thu, 24 Oct 2024 18:08:48 +0800 Subject: [PATCH 39/44] windows dll library succ --- mock/CMakeLists.txt | 3 +- mock/DbHandle.h | 2 +- mock/FrameworkServer.h | 2 +- mock/LogImp.h | 4 +- mock/QueryImp.h | 2 +- mock/StatImp.h | 2 +- mock/TarsMockUtil.h | 2 +- servant/libservant/AsyncProcThread.cpp | 4 +- servant/libservant/CMakeLists.txt | 10 +- servant/libservant/CommunicatorEpoll.cpp | 2 +- servant/libservant/Servant.cpp | 9 +- servant/libservant/ServantProxy.cpp | 10 +- servant/libservant/StatReport.cpp | 2 +- servant/servant/AdapterProxy.h | 7 +- servant/servant/AdminServant.h | 9 +- servant/servant/AppCache.h | 4 +- servant/servant/AppProtocol.h | 7 +- servant/servant/Application.h | 8 +- servant/servant/AsyncProcThread.h | 7 +- servant/servant/AuthLogic.h | 4 +- servant/servant/BaseNotify.h | 7 +- servant/servant/Communicator.h | 5 +- servant/servant/CommunicatorEpoll.h | 7 +- servant/servant/CommunicatorFactory.h | 7 +- servant/servant/Cookie.h | 6 +- servant/servant/Current.h | 7 +- servant/servant/EndpointInfo.h | 7 +- servant/servant/EndpointManager.h | 13 +- servant/servant/Global.h | 5 +- servant/servant/KeepAliveNodeF.h | 6 +- servant/servant/Message.h | 7 +- servant/servant/NotifyObserver.h | 5 +- servant/servant/ObjectProxy.h | 7 +- servant/servant/ObjectProxyFactory.h | 6 +- servant/servant/PropertyReport.h | 9 +- servant/servant/RemoteConfig.h | 4 +- servant/servant/RemoteLogger.h | 14 +- servant/servant/RemoteNotify.h | 5 +- servant/servant/ReqTime.h | 4 +- servant/servant/Servant.h | 20 +- servant/servant/ServantHandle.h | 7 +- servant/servant/ServantHelper.h | 5 +- servant/servant/ServantProxy.h | 26 +- servant/servant/ServantProxyFactory.h | 7 +- servant/servant/StatReport.h | 7 +- tools/CMakeLists.txt | 6 +- tools/tarsparse/CMakeLists.txt | 3 + util/include/util/tc_autoptr.h | 2 +- util/include/util/tc_cas_queue.h | 1 + util/include/util/tc_cgi.h | 5 +- util/include/util/tc_clientsocket.h | 10 +- util/include/util/tc_common.h | 221 +++++++++++- util/include/util/tc_config.h | 5 +- util/include/util/tc_consistent_hash.h | 5 +- util/include/util/tc_consistent_hash_new.h | 3 +- util/include/util/tc_coroutine.h | 10 +- util/include/util/tc_coroutine_mutex.h | 96 +++--- util/include/util/tc_coroutine_queue.h | 1 + util/include/util/tc_cron.h | 3 +- util/include/util/tc_custom_protocol.h | 5 +- util/include/util/tc_des.h | 3 +- util/include/util/tc_docker.h | 4 +- util/include/util/tc_dyn_object.h | 3 +- util/include/util/tc_encoder.h | 4 +- util/include/util/tc_epoll_server.h | 17 +- util/include/util/tc_epoller.h | 6 +- util/include/util/tc_ex.h | 5 +- util/include/util/tc_fifo.h | 2 +- util/include/util/tc_file.h | 2 +- util/include/util/tc_file_mutex.h | 2 +- util/include/util/tc_grpc.h | 5 +- util/include/util/tc_gzip.h | 13 +- util/include/util/tc_hash_fun.h | 1 + util/include/util/tc_hashmap.h | 3 +- util/include/util/tc_hashmap_compact.h | 3 +- util/include/util/tc_http.h | 11 +- util/include/util/tc_http2.h | 8 +- util/include/util/tc_http_async.h | 4 +- util/include/util/tc_json.h | 21 +- util/include/util/tc_lock.h | 1 + util/include/util/tc_logger.h | 15 +- util/include/util/tc_loop_queue.h | 1 + util/include/util/tc_malloc_chunk.h | 11 +- util/include/util/tc_md5.h | 3 +- util/include/util/tc_mem_chunk.h | 7 +- util/include/util/tc_mem_queue.h | 3 +- util/include/util/tc_mem_vector.h | 1 + util/include/util/tc_mmap.h | 2 +- util/include/util/tc_monitor.h | 2 + util/include/util/tc_multi_hashmap.h | 3 +- util/include/util/tc_mysql.h | 8 +- util/include/util/tc_network_buffer.h | 5 +- util/include/util/tc_openssl.h | 4 +- util/include/util/tc_option.h | 4 +- util/include/util/tc_pack.h | 2 +- util/include/util/tc_parsepara.h | 3 +- util/include/util/tc_port.h | 2 +- util/include/util/tc_proxy_info.h | 3 +- util/include/util/tc_rbtree.h | 4 +- util/include/util/tc_readers_writer_data.h | 1 + util/include/util/tc_sem_mutex.h | 2 +- util/include/util/tc_serialport.h | 4 +- util/include/util/tc_sha.h | 4 +- util/include/util/tc_shm.h | 2 +- util/include/util/tc_singleton.h | 1 + util/include/util/tc_socket.h | 2 +- util/include/util/tc_split.h | 3 +- util/include/util/tc_squeue.h | 4 +- util/include/util/tc_tea.h | 2 +- util/include/util/tc_thread.h | 6 +- util/include/util/tc_thread_cond.h | 2 +- util/include/util/tc_thread_pool.h | 4 +- util/include/util/tc_thread_queue.h | 1 + util/include/util/tc_timeout_queue.h | 1 + util/include/util/tc_timeout_queue_map.h | 1 + util/include/util/tc_timeout_queue_new.h | 3 +- util/include/util/tc_timeout_queue_noid.h | 2 + util/include/util/tc_timer.h | 5 +- util/include/util/tc_transceiver.h | 8 +- util/include/util/tc_uuid_generator.h | 2 - util/include/util/tc_xml.h | 13 +- util/src/CMakeLists.txt | 8 +- util/src/tc_common.cpp | 378 ++++++++++----------- util/src/tc_coroutine.cpp | 2 +- util/src/tc_gzip.cpp | 23 ++ util/src/tc_transceiver.cpp | 146 +------- 126 files changed, 801 insertions(+), 709 deletions(-) diff --git a/mock/CMakeLists.txt b/mock/CMakeLists.txt index 87f601db..b1627906 100755 --- a/mock/CMakeLists.txt +++ b/mock/CMakeLists.txt @@ -11,8 +11,9 @@ install(TARGETS tarsmock RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE if(ENABLE_SHARED) add_library(tarsmock_shared SHARED ${SRC_FILES}) + target_compile_definitions(tarsmock_shared PRIVATE SVT_USE_DLL UTIL_USE_DLL) target_link_libraries(tarsmock_shared tarsservant_shared tarsutil_shared) - add_dependencies(tarsmock_shared tarsmock) + add_dependencies(tarsmock_shared tarsservant_shared) install(TARGETS tarsmock_shared RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) diff --git a/mock/DbHandle.h b/mock/DbHandle.h index 0b83ad3d..dfa97b07 100755 --- a/mock/DbHandle.h +++ b/mock/DbHandle.h @@ -24,7 +24,7 @@ typedef map ObjectsCache; /** * 数据库操作类 */ -class CDbHandle +class UTIL_DLL_API CDbHandle { private: struct GroupPriorityEntry diff --git a/mock/FrameworkServer.h b/mock/FrameworkServer.h index 20081c4e..42ee4967 100755 --- a/mock/FrameworkServer.h +++ b/mock/FrameworkServer.h @@ -8,7 +8,7 @@ using namespace tars; extern vector> _clientStatData; extern vector> _serverStatData; -class FrameworkServer : public Application, public TC_Thread +class UTIL_DLL_API FrameworkServer : public Application, public TC_Thread { public: /** diff --git a/mock/LogImp.h b/mock/LogImp.h index a8628f60..54230b35 100755 --- a/mock/LogImp.h +++ b/mock/LogImp.h @@ -29,7 +29,7 @@ using namespace tars; /** * 全局信息 */ -struct GlobeInfo : public TC_ThreadLock +struct UTIL_DLL_API GlobeInfo : public TC_ThreadLock { public: /** @@ -170,7 +170,7 @@ extern GlobeInfo g_globe; /** * log实现 */ -class LogImp : public Log +class UTIL_DLL_API LogImp : public Log { public: /** diff --git a/mock/QueryImp.h b/mock/QueryImp.h index dcfe7ed0..02b77345 100755 --- a/mock/QueryImp.h +++ b/mock/QueryImp.h @@ -23,7 +23,7 @@ enum FUNID /** * 对象查询接口类 */ -class QueryImp: public QueryF +class UTIL_DLL_API QueryImp: public QueryF { public: /** diff --git a/mock/StatImp.h b/mock/StatImp.h index 27235cc9..debe12de 100644 --- a/mock/StatImp.h +++ b/mock/StatImp.h @@ -11,7 +11,7 @@ using namespace tars; -class StatImp : public StatF +class UTIL_DLL_API StatImp : public StatF { public: /** diff --git a/mock/TarsMockUtil.h b/mock/TarsMockUtil.h index d8a262d6..7c3f1bd8 100644 --- a/mock/TarsMockUtil.h +++ b/mock/TarsMockUtil.h @@ -11,7 +11,7 @@ class FrameworkServer; -class TarsMockUtil +class UTIL_DLL_API TarsMockUtil { public: TarsMockUtil(); diff --git a/servant/libservant/AsyncProcThread.cpp b/servant/libservant/AsyncProcThread.cpp index ce38d8e5..145bd96f 100644 --- a/servant/libservant/AsyncProcThread.cpp +++ b/servant/libservant/AsyncProcThread.cpp @@ -102,8 +102,8 @@ void AsyncProcThread::run() delete msg; } - ServantProxyThreadData::g_sp.reset(); - CallbackThreadData::g_sp.reset(); + ServantProxyThreadData::reset(); + CallbackThreadData::reset(); } void AsyncProcThread::callback(ReqMessage * msg) diff --git a/servant/libservant/CMakeLists.txt b/servant/libservant/CMakeLists.txt index 99ab3dc7..db14d63e 100755 --- a/servant/libservant/CMakeLists.txt +++ b/servant/libservant/CMakeLists.txt @@ -10,19 +10,21 @@ aux_source_directory(. DIR_SRCS) add_library(tarsservant STATIC ${DIR_SRCS}) -add_dependencies(tarsservant tarsparse_shared COPY-SERVENT-TARS) +add_dependencies(tarsservant tarsparse COPY-SERVENT-TARS) install(TARGETS tarsservant LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) if(ENABLE_SHARED) + add_definitions(-DSVT_DLL_EXPORT -DUTIL_USE_DLL) add_library(tarsservant_shared SHARED ${DIR_SRCS}) - target_compile_definitions(tarsservant_shared PRIVATE SVT_DLL_EXPORT UTIL_USE_DLL) - target_link_libraries(tarsservant_shared tarsutil_shared) + # target_compile_definitions(tarsservant_shared PRIVATE SVT_DLL_EXPORT UTIL_USE_DLL) + target_link_libraries(tarsservant_shared tarsutil_shared tarsparse_shared) - add_dependencies(tarsservant_shared tarsservant) + add_dependencies(tarsservant_shared tarsservant tarsutil_shared tarsparse_shared) + install(TARGETS tarsservant_shared LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) diff --git a/servant/libservant/CommunicatorEpoll.cpp b/servant/libservant/CommunicatorEpoll.cpp index 54a0d17a..347b0987 100755 --- a/servant/libservant/CommunicatorEpoll.cpp +++ b/servant/libservant/CommunicatorEpoll.cpp @@ -181,7 +181,7 @@ void CommunicatorEpoll::handleTerminate() _pSptd->_sched.reset(); - ServantProxyThreadData::g_sp.reset(); + ServantProxyThreadData::reset(); } _scheduler.reset(); diff --git a/servant/libservant/Servant.cpp b/servant/libservant/Servant.cpp index 264c2235..c0ab925d 100644 --- a/servant/libservant/Servant.cpp +++ b/servant/libservant/Servant.cpp @@ -25,7 +25,7 @@ namespace tars { -thread_local shared_ptr CallbackThreadData::g_sp; +static thread_local shared_ptr g_sp; Servant::Servant() //:_handle(NULL) { @@ -170,6 +170,13 @@ CallbackThreadData * CallbackThreadData::getData() return g_sp.get(); } +void CallbackThreadData::reset() +{ + if(g_sp) + { + g_sp.reset(); + } +} void CallbackThreadData::setResponseContext(const map & context) { diff --git a/servant/libservant/ServantProxy.cpp b/servant/libservant/ServantProxy.cpp index 77a8ea9e..de2362e2 100644 --- a/servant/libservant/ServantProxy.cpp +++ b/servant/libservant/ServantProxy.cpp @@ -30,7 +30,7 @@ namespace tars shared_ptr ServantProxyThreadData::g_immortal; -thread_local shared_ptr ServantProxyThreadData::g_sp; +thread_local shared_ptr g_sp; unsigned int _traceParamMaxLen = 1; // 默认1K /////////////////////////////////////////////////////////////// @@ -232,6 +232,14 @@ void ServantProxyThreadData::deconstructor(Communicator *communicator) } } +void ServantProxyThreadData::reset() +{ + if (g_sp) + { + g_sp.reset(); + } +} + void ServantProxyThreadData::erase(Communicator *communicator) { TC_LockT lock(_mutex); diff --git a/servant/libservant/StatReport.cpp b/servant/libservant/StatReport.cpp index 905e34fb..ccd939c9 100755 --- a/servant/libservant/StatReport.cpp +++ b/servant/libservant/StatReport.cpp @@ -712,7 +712,7 @@ void StatReport::run() } } - ServantProxyThreadData::g_sp.reset(); + ServantProxyThreadData::reset(); } //////////////////////////////////////////////////////////////// diff --git a/servant/servant/AdapterProxy.h b/servant/servant/AdapterProxy.h index f744be71..8c23b2e0 100644 --- a/servant/servant/AdapterProxy.h +++ b/servant/servant/AdapterProxy.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_ADAPTER_PROXY_H_ -#define __TARS_ADAPTER_PROXY_H_ +#pragma once #include "util/tc_timeout_queue_new.h" #include "util/tc_timeout_queue_map.h" @@ -39,7 +37,7 @@ namespace tars /** * 每个Adapter对应一个Endpoint,也就是一个服务端口 */ -class AdapterProxy +class SVT_DLL_API AdapterProxy { public: /** @@ -450,4 +448,3 @@ class AdapterProxy }; //////////////////////////////////////////////////////////////////// } -#endif diff --git a/servant/servant/AdminServant.h b/servant/servant/AdminServant.h index 442b5345..3ce1131b 100644 --- a/servant/servant/AdminServant.h +++ b/servant/servant/AdminServant.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_ADMIN_SERVANT_H -#define __TARS_ADMIN_SERVANT_H +#pragma once #include "servant/AdminF.h" @@ -28,7 +26,7 @@ class Application; /** * 管理Servant */ -class AdminServant : public AdminF +class SVT_DLL_API AdminServant : public AdminF { public: /** @@ -73,6 +71,3 @@ class AdminServant : public AdminF //////////////////////////////////////////////////////////////// } -#endif - - diff --git a/servant/servant/AppCache.h b/servant/servant/AppCache.h index b974dc50..d9d876b8 100644 --- a/servant/servant/AppCache.h +++ b/servant/servant/AppCache.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __APP_CACHE_H_ -#define __APP_CACHE_H_ +#pragma once #include #include @@ -108,4 +107,3 @@ class SVT_DLL_API AppCache : public TC_Singleton, public TC_ThreadMute }; ////////////////////////////////////////////////////////////////////// } -#endif diff --git a/servant/servant/AppProtocol.h b/servant/servant/AppProtocol.h index ee2a24dd..a58a6e59 100644 --- a/servant/servant/AppProtocol.h +++ b/servant/servant/AppProtocol.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_PROTOCOL_H_ -#define __TARS_PROTOCOL_H_ +#pragma once #include #include @@ -57,7 +55,7 @@ class TC_Transceiver; /** * 协议解析 */ -class AppProtocol +class SVT_DLL_API AppProtocol { public: /** @@ -330,4 +328,3 @@ class ProxyProtocol ////////////////////////////////////////////////////////////////////// } -#endif diff --git a/servant/servant/Application.h b/servant/servant/Application.h index 2e0297a7..436cb5cc 100644 --- a/servant/servant/Application.h +++ b/servant/servant/Application.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_APPLICATION_H -#define __TARS_APPLICATION_H +#pragma once #include #include @@ -201,7 +199,7 @@ class KeepAliveNodeFHelper; /** * 服务的基类 */ -class Application: public BaseNotify +class SVT_DLL_API Application: public BaseNotify { public: /** @@ -725,5 +723,3 @@ class Application: public BaseNotify //////////////////////////////////////////////////////////////////// } -#endif - diff --git a/servant/servant/AsyncProcThread.h b/servant/servant/AsyncProcThread.h index 25163d7c..f5fb57a5 100644 --- a/servant/servant/AsyncProcThread.h +++ b/servant/servant/AsyncProcThread.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_ASYNC_PROC_THREAD_H_ -#define __TARS_ASYNC_PROC_THREAD_H_ +#pragma once #include "servant/Message.h" #include "servant/Global.h" @@ -29,7 +27,7 @@ namespace tars /** * 异步回调后的处理线程 */ -class AsyncProcThread : public TC_Thread, public TC_ThreadLock +class SVT_DLL_API AsyncProcThread : public TC_Thread, public TC_ThreadLock { public: /** @@ -91,4 +89,3 @@ class AsyncProcThread : public TC_Thread, public TC_ThreadLock }; /////////////////////////////////////////////////////// } -#endif diff --git a/servant/servant/AuthLogic.h b/servant/servant/AuthLogic.h index 5ff2729f..94176b38 100644 --- a/servant/servant/AuthLogic.h +++ b/servant/servant/AuthLogic.h @@ -1,4 +1,6 @@ -#include "servant/AuthF.h" +#pragma once + +#include "servant/AuthF.h" #include "util/tc_epoll_server.h" namespace tars diff --git a/servant/servant/BaseNotify.h b/servant/servant/BaseNotify.h index 9dabc63c..8e975fdb 100644 --- a/servant/servant/BaseNotify.h +++ b/servant/servant/BaseNotify.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_BASE_NOTIFY_H_ -#define __TARS_BASE_NOTIFY_H_ +#pragma once #include "servant/Global.h" #include "util/tc_thread_queue.h" @@ -30,7 +28,7 @@ class NotifyObserver; /** * 需要接收到管理命令的对象从该类派生 */ -class BaseNotify : public TC_ThreadRecMutex, public TC_HandleBase +class SVT_DLL_API BaseNotify : public TC_ThreadRecMutex, public TC_HandleBase { public: /** @@ -92,4 +90,3 @@ class BaseNotify : public TC_ThreadRecMutex, public TC_HandleBase }; ///////////////////////////////////////////////////////////////////// } -#endif diff --git a/servant/servant/Communicator.h b/servant/servant/Communicator.h index b2742f29..e60245f1 100644 --- a/servant/servant/Communicator.h +++ b/servant/servant/Communicator.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_COMMUNICATOR_H_ -#define __TARS_COMMUNICATOR_H_ +#pragma once #include "util/tc_thread.h" #include "util/tc_config.h" @@ -622,4 +620,3 @@ class SVT_DLL_API Communicator : public TC_HandleBase }; //////////////////////////////////////////////////////////////////////// } -#endif diff --git a/servant/servant/CommunicatorEpoll.h b/servant/servant/CommunicatorEpoll.h index 0d106b4f..58fbb240 100644 --- a/servant/servant/CommunicatorEpoll.h +++ b/servant/servant/CommunicatorEpoll.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS__COMMUNICATOR_EPOLL_H_ -#define __TARS__COMMUNICATOR_EPOLL_H_ +#pragma once #include "util/tc_thread.h" #include "util/tc_thread_mutex.h" @@ -72,7 +70,7 @@ struct FDInfo /** * 客户端网络处理的线程类 */ -class CommunicatorEpoll : public TC_Thread, public enable_shared_from_this +class SVT_DLL_API CommunicatorEpoll : public TC_Thread, public enable_shared_from_this { public: @@ -466,4 +464,3 @@ class CommunicatorEpoll : public TC_Thread, public enable_shared_from_this, public TC_HandleBase, public TC_ThreadRecMutex +class SVT_DLL_API CommunicatorFactory : public TC_Singleton, public TC_HandleBase, public TC_ThreadRecMutex { public: /** @@ -104,4 +102,3 @@ class CommunicatorFactory : public TC_Singleton, public TC_ ////////////////////////////////////////////////////// } -#endif diff --git a/servant/servant/Cookie.h b/servant/servant/Cookie.h index 8e031044..e79dde93 100644 --- a/servant/servant/Cookie.h +++ b/servant/servant/Cookie.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_COOKIE_H__ -#define __TARS_COOKIE_H__ +#pragma once #include "servant/ServantProxy.h" @@ -69,5 +67,3 @@ class CookieOp } } }; - -#endif \ No newline at end of file diff --git a/servant/servant/Current.h b/servant/servant/Current.h index 709fd756..dbf51a6e 100644 --- a/servant/servant/Current.h +++ b/servant/servant/Current.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_CURRENT_H_ -#define __TARS_CURRENT_H_ +#pragma once #include "util/tc_epoll_server.h" #include "tup/RequestF.h" @@ -32,7 +30,7 @@ class ServantHandle; /** * 当前请求的上下文 */ -class Current : public TC_HandleBase +class SVT_DLL_API Current : public TC_HandleBase { public: typedef std::map TARS_STATUS; @@ -396,4 +394,3 @@ class Current : public TC_HandleBase }; ////////////////////////////////////////////////////////////// } -#endif diff --git a/servant/servant/EndpointInfo.h b/servant/servant/EndpointInfo.h index 6da493bb..d82a6c2a 100755 --- a/servant/servant/EndpointInfo.h +++ b/servant/servant/EndpointInfo.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_ENDPOINT_INFO_H_ -#define __TARS_ENDPOINT_INFO_H_ +#pragma once #include "util/tc_socket.h" #include "util/tc_clientsocket.h" @@ -32,7 +30,7 @@ namespace tars /** * 地址信息IP:Port */ -class EndpointInfo +class SVT_DLL_API EndpointInfo { public: @@ -268,4 +266,3 @@ class EndpointInfo }; ///////////////////////////////////////////////////////////////////////////// } -#endif diff --git a/servant/servant/EndpointManager.h b/servant/servant/EndpointManager.h index 9e6bc29d..570f674c 100644 --- a/servant/servant/EndpointManager.h +++ b/servant/servant/EndpointManager.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_ENDPOINT_MANAGER_H_ -#define __TARS_ENDPOINT_MANAGER_H_ +#pragma once #include "servant/EndpointInfo.h" #include "servant/EndpointF.h" @@ -51,7 +49,7 @@ enum EndpointWeightType /* * 路由请求与回调的实现类 */ -class QueryEpBase : public QueryFPrxCallback ,public enable_shared_from_this +class SVT_DLL_API QueryEpBase : public QueryFPrxCallback ,public enable_shared_from_this { public: /* @@ -321,7 +319,7 @@ class QueryEpBase : public QueryFPrxCallback ,public enable_shared_from_this #include @@ -231,4 +229,3 @@ struct TarsCommunicatorException : public TarsException }; /////////////////////////////////////////////////////////////////// } -#endif diff --git a/servant/servant/KeepAliveNodeF.h b/servant/servant/KeepAliveNodeF.h index 26faaace..57251981 100644 --- a/servant/servant/KeepAliveNodeF.h +++ b/servant/servant/KeepAliveNodeF.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_NODEF_H__ -#define __TARS_NODEF_H__ +#pragma once #include "servant/NodeF.h" #include "servant/Global.h" @@ -79,5 +77,3 @@ class SVT_DLL_API KeepAliveNodeFHelper : public TC_ThreadMutex } -#endif - diff --git a/servant/servant/Message.h b/servant/servant/Message.h index 80b81c7f..1f5be6d7 100644 --- a/servant/servant/Message.h +++ b/servant/servant/Message.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_MESSAGE_H_ -#define __TARS_MESSAGE_H_ +#pragma once #include #include "util/tc_autoptr.h" @@ -133,7 +131,7 @@ struct ThreadPrivateData struct ReqMonitor; -struct ReqMessage : public TC_HandleBase +struct SVT_DLL_API ReqMessage : public TC_HandleBase { //调用类型 enum CallType @@ -236,4 +234,3 @@ typedef TC_LoopQueue ReqInfoQueue; //////////////////////////////////////////////////////////////////////////////////////////////////// } -#endif diff --git a/servant/servant/NotifyObserver.h b/servant/servant/NotifyObserver.h index e01f1c76..0bc0e964 100644 --- a/servant/servant/NotifyObserver.h +++ b/servant/servant/NotifyObserver.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_NOTIFY_OBSERVER_H_ -#define __TARS_NOTIFY_OBSERVER_H_ +#pragma once #include "servant/Global.h" #include "servant/Current.h" @@ -120,4 +118,3 @@ class SVT_DLL_API NotifyObserver : public TC_ThreadRecMutex ///////////////////////////////////////////////////////////////// } -#endif diff --git a/servant/servant/ObjectProxy.h b/servant/servant/ObjectProxy.h index d6f81a6e..19a5dec5 100644 --- a/servant/servant/ObjectProxy.h +++ b/servant/servant/ObjectProxy.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_OBJECT_PROXY_H_ -#define __TARS_OBJECT_PROXY_H_ +#pragma once #include "servant/Communicator.h" #include "servant/Message.h" @@ -39,7 +37,7 @@ class EndpointManager; * 每个objectname在每个客户端网络线程中有唯一一个objectproxy * */ -class ObjectProxy : public TC_HandleBase, public TC_ThreadMutex +class SVT_DLL_API ObjectProxy : public TC_HandleBase, public TC_ThreadMutex { public: /** @@ -289,4 +287,3 @@ class ObjectProxy : public TC_HandleBase, public TC_ThreadMutex }; /////////////////////////////////////////////////////////////////////////////////// } -#endif diff --git a/servant/servant/ObjectProxyFactory.h b/servant/servant/ObjectProxyFactory.h index bf004637..6ee82020 100644 --- a/servant/servant/ObjectProxyFactory.h +++ b/servant/servant/ObjectProxyFactory.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TARS_OBJECT_PROXY_FACTORY_H_ -#define __TARS_OBJECT_PROXY_FACTORY_H_ +#pragma once #include "servant/Communicator.h" #include "servant/ObjectProxy.h" @@ -29,7 +28,7 @@ namespace tars * 每个objectname在每个客户端网络线程中有唯一一个objectproxy * */ -class ObjectProxyFactory : public TC_HandleBase, public TC_ThreadRecMutex +class SVT_DLL_API ObjectProxyFactory : public TC_HandleBase, public TC_ThreadRecMutex { public: /** @@ -99,4 +98,3 @@ class ObjectProxyFactory : public TC_HandleBase, public TC_ThreadRecMutex ///////////////////////////////////////////////////////////////////////////////////////// } -#endif diff --git a/servant/servant/PropertyReport.h b/servant/servant/PropertyReport.h index 2d7b5a7e..c65840cf 100755 --- a/servant/servant/PropertyReport.h +++ b/servant/servant/PropertyReport.h @@ -13,11 +13,9 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ +#pragma once -#ifndef __TARS_PROPERTY_REPORT_H_ -#define __TARS_PROPERTY_REPORT_H_ - - #include "util/tc_lock.h" +#include "util/tc_lock.h" #include "util/tc_autoptr.h" #include "util/tc_thread_mutex.h" #include "util/tc_spin_lock.h" @@ -38,7 +36,7 @@ namespace tars /** * 用户自定义属性统计基类 */ -class PropertyReport : public TC_HandleBase +class SVT_DLL_API PropertyReport : public TC_HandleBase { public: /** @@ -263,4 +261,3 @@ class PropertyReportImp : public PropertyReport, public TC_ThreadMutex } -#endif diff --git a/servant/servant/RemoteConfig.h b/servant/servant/RemoteConfig.h index a72f8efd..b4b647dc 100644 --- a/servant/servant/RemoteConfig.h +++ b/servant/servant/RemoteConfig.h @@ -14,8 +14,7 @@ * specific language governing permissions and limitations under the License. */ -#ifndef __TARS_CONFIG_H_ -#define __TARS_CONFIG_H_ +#pragma once #include "util/tc_autoptr.h" #include "util/tc_singleton.h" @@ -154,4 +153,3 @@ class SVT_DLL_API RemoteConfig //: public TC_Singleton } -#endif diff --git a/servant/servant/RemoteLogger.h b/servant/servant/RemoteLogger.h index fe3fc413..76e848b8 100755 --- a/servant/servant/RemoteLogger.h +++ b/servant/servant/RemoteLogger.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_LOGGER_H__ -#define __TARS_LOGGER_H__ +#pragma once #include "servant/Global.h" #include "servant/LogF.h" @@ -61,7 +59,7 @@ namespace tars /////////////////////////////////////////////////////////////////////////////// -class RollWriteT +class SVT_DLL_API RollWriteT { public: RollWriteT(); @@ -269,7 +267,7 @@ class TimeWriteT; /** * 远程的Log写操作类 */ -class RemoteTimeWriteT +class SVT_DLL_API RemoteTimeWriteT { public: RemoteTimeWriteT(); @@ -310,7 +308,7 @@ class RemoteTimeWriteT /** * 写Logger */ -class TimeWriteT +class SVT_DLL_API TimeWriteT { public: typedef TC_Logger RemoteTimeLogger; @@ -811,7 +809,7 @@ class SVT_DLL_API RemoteTimeLogger : public TC_HandleBase /** * 染色开关类,析构时关闭 */ -class TarsDyeingSwitch +class SVT_DLL_API TarsDyeingSwitch { public: /** @@ -1015,5 +1013,3 @@ class TarsDyeingSwitch #define TENLOCAL(swith) (RemoteTimeLogger::getInstance()->enableLocalLog(swith)) } -#endif - diff --git a/servant/servant/RemoteNotify.h b/servant/servant/RemoteNotify.h index 809bc9d6..5e8dd5ef 100644 --- a/servant/servant/RemoteNotify.h +++ b/servant/servant/RemoteNotify.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_NOTIFY_H_ -#define __TARS_NOTIFY_H_ +#pragma once #include "servant/NotifyF.h" #include "servant/Global.h" @@ -93,4 +91,3 @@ class SVT_DLL_API RemoteNotify : public TC_Singleton } -#endif diff --git a/servant/servant/ReqTime.h b/servant/servant/ReqTime.h index 93f161eb..c46a6b2c 100644 --- a/servant/servant/ReqTime.h +++ b/servant/servant/ReqTime.h @@ -13,8 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -#ifndef __TARS_REQTIME_H_ -#define __TARS_REQTIME_H_ +#pragma once namespace tars { @@ -40,4 +39,3 @@ class ReqTime }; } -#endif // __TARS_REQTIME_H_ diff --git a/servant/servant/Servant.h b/servant/servant/Servant.h index 891c3b40..67ac26b7 100644 --- a/servant/servant/Servant.h +++ b/servant/servant/Servant.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_SERVANT_H_ -#define __TARS_SERVANT_H_ +#pragma once #include "util/tc_autoptr.h" #include "util/tc_epoll_server.h" @@ -42,7 +40,7 @@ typedef std::shared_ptr BufferWrapperPtr; /** * 每个对象的基类 */ -class Servant : public BaseNotify +class SVT_DLL_API Servant : public BaseNotify { public: /** @@ -240,7 +238,7 @@ typedef TC_AutoPtr ServantPtr; * ServantCallback会把接收到的数据再放到对应servant的responsequeue中, 保证后续在对应的Servant::doResponse中处理 * 从而请求和响应在一个线程Servant中完成 */ -class ServantCallback : public ServantProxyCallback +class SVT_DLL_API ServantCallback : public ServantProxyCallback { public: /** @@ -290,10 +288,10 @@ class ServantCallback : public ServantProxyCallback ////////////////////////////////////////////////////////////////////// //线程私有数据 -class CallbackThreadData +class SVT_DLL_API CallbackThreadData { public: - static thread_local shared_ptr g_sp; + // static thread_local shared_ptr g_sp; /** * 构造函数 @@ -312,6 +310,10 @@ class CallbackThreadData */ static CallbackThreadData* getData(); + /** + * 释放线程数据 + */ + static void reset(); public: /** * 设置返回的额外内容 @@ -350,6 +352,4 @@ class CallbackThreadData }; ////////////////////////////////////////////////////////////////////// -} -////////////////////////////////////////////////////////////////////// -#endif +} \ No newline at end of file diff --git a/servant/servant/ServantHandle.h b/servant/servant/ServantHandle.h index 18b48aa3..b0581d68 100644 --- a/servant/servant/ServantHandle.h +++ b/servant/servant/ServantHandle.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_SERVANT_HANDLE_H -#define __TARS_SERVANT_HANDLE_H +#pragma once #include #include @@ -39,7 +37,7 @@ class Application; /** * 处理网络请求线程 */ -class ServantHandle : public TC_EpollServer::Handle, public enable_shared_from_this +class SVT_DLL_API ServantHandle : public TC_EpollServer::Handle, public enable_shared_from_this { public: /** @@ -222,5 +220,4 @@ class ServantHandle : public TC_EpollServer::Handle, public enable_shared_from_t typedef TC_AutoPtr ServantHandlePtr; /////////////////////////////////////////////////////////// } -#endif diff --git a/servant/servant/ServantHelper.h b/servant/servant/ServantHelper.h index a71b29c7..5f41cf28 100644 --- a/servant/servant/ServantHelper.h +++ b/servant/servant/ServantHelper.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_SERVANT_HELPER_H -#define __TARS_SERVANT_HELPER_H +#pragma once #include #include @@ -250,5 +248,4 @@ class SVT_DLL_API ServantHelperManager// : public TC_Singleton +class SVT_DLL_API ServantProxyThreadData : public std::enable_shared_from_this { public: /** @@ -137,7 +135,7 @@ class ServantProxyThreadData : public std::enable_shared_from_this g_sp; + // static thread_local shared_ptr g_sp; /** @@ -167,6 +165,11 @@ class ServantProxyThreadData : public std::enable_shared_from_this HttpCallbackPtr; -class HttpServantProxyCallback : virtual public ServantProxyCallback +class SVT_DLL_API HttpServantProxyCallback : virtual public ServantProxyCallback { public: explicit HttpServantProxyCallback(const HttpCallbackPtr& cb); @@ -775,7 +778,7 @@ class HttpServantProxyCallback : virtual public ServantProxyCallback */ class EndpointManagerThread; -class ServantProxy : public TC_HandleBase, public TC_ThreadMutex +class SVT_DLL_API ServantProxy : public TC_HandleBase, public TC_ThreadMutex { public: /** @@ -1480,4 +1483,3 @@ class ServantProxy : public TC_HandleBase, public TC_ThreadMutex }; } -#endif diff --git a/servant/servant/ServantProxyFactory.h b/servant/servant/ServantProxyFactory.h index 5f01daef..bbc223c2 100644 --- a/servant/servant/ServantProxyFactory.h +++ b/servant/servant/ServantProxyFactory.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_SERVANT_PROXY_FACTORY_H_ -#define __TARS_SERVANT_PROXY_FACTORY_H_ +#pragma once #include "servant/Global.h" #include "servant/Communicator.h" @@ -27,7 +25,7 @@ namespace tars /** * 创建ServantProxy对象,每个object在进程空间只有一个ServantProxy实例 */ -class ServantProxyFactory : public TC_ThreadRecMutex +class SVT_DLL_API ServantProxyFactory : public TC_ThreadRecMutex { public: /** @@ -64,4 +62,3 @@ class ServantProxyFactory : public TC_ThreadRecMutex }; ////////////////////////////////////////////////////// } -#endif diff --git a/servant/servant/StatReport.h b/servant/servant/StatReport.h index 1d81e751..dd99b2c2 100644 --- a/servant/servant/StatReport.h +++ b/servant/servant/StatReport.h @@ -13,9 +13,7 @@ * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - -#ifndef __TARS_STAT_REPORT_H_ -#define __TARS_STAT_REPORT_H_ +#pragma once #include "util/tc_thread.h" #include "util/tc_readers_writer_data.h" @@ -39,7 +37,7 @@ namespace tars * 1 模块间调用的信息 * 2 业务自定义的属性统计 */ -class StatReport : public TC_HandleBase, public TC_Thread, public TC_ThreadLock +class SVT_DLL_API StatReport : public TC_HandleBase, public TC_Thread, public TC_ThreadLock { public: @@ -307,4 +305,3 @@ class StatReport : public TC_HandleBase, public TC_Thread, public TC_ThreadLock /////////////////////////////////////////////////////////// } -#endif diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 317540d1..9bfb929a 100755 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -3,8 +3,6 @@ project(tools) include_directories(${util_SOURCE_DIR}/include) -link_libraries(tarsutil) - function(tars2language TARGET) set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) @@ -17,10 +15,10 @@ function(tars2language TARGET) aux_source_directory(. DIR_SRCS) - link_libraries(tarsparse) - add_executable(${TARGET} ${DIR_SRCS}) + target_link_libraries(${TARGET} tarsutil tarsparse) + install(TARGETS ${TARGET} RUNTIME DESTINATION tools) endfunction() diff --git a/tools/tarsparse/CMakeLists.txt b/tools/tarsparse/CMakeLists.txt index 4a4181c7..167d8170 100644 --- a/tools/tarsparse/CMakeLists.txt +++ b/tools/tarsparse/CMakeLists.txt @@ -41,6 +41,9 @@ install(TARGETS ${TARGETNAME} if(ENABLE_SHARED) add_library(${TARGETNAME}_shared SHARED ${DIR_SRCS} ${DEPENDS_SRC_LIST}) add_dependencies(${TARGETNAME}_shared ${TARGETNAME}) + target_compile_definitions(${TARGETNAME}_shared PRIVATE UTIL_DLL_EXPORT) + + target_link_libraries(${TARGETNAME}_shared tarsutil_shared) install(TARGETS ${TARGETNAME}_shared LIBRARY DESTINATION lib diff --git a/util/include/util/tc_autoptr.h b/util/include/util/tc_autoptr.h index 7ac75fa3..4fcb53aa 100755 --- a/util/include/util/tc_autoptr.h +++ b/util/include/util/tc_autoptr.h @@ -41,7 +41,7 @@ struct TC_AutoPtrNull_Exception : public TC_Exception * 所有需要智能指针支持的类都需要从该对象继承, * */ -class UTIL_DLL_API TC_HandleBase +class TC_HandleBase { public: diff --git a/util/include/util/tc_cas_queue.h b/util/include/util/tc_cas_queue.h index ee5d5d4b..f52f8f90 100755 --- a/util/include/util/tc_cas_queue.h +++ b/util/include/util/tc_cas_queue.h @@ -2,6 +2,7 @@ #include #include #include +#include "util/tc_platform.h" #include "util/tc_lock.h" #include "util/tc_spin_lock.h" diff --git a/util/include/util/tc_cgi.h b/util/include/util/tc_cgi.h index 78be780b..91ce0f5f 100644 --- a/util/include/util/tc_cgi.h +++ b/util/include/util/tc_cgi.h @@ -20,6 +20,7 @@ #include #include #include +#include "util/tc_platform.h" #include "util/tc_ex.h" namespace tars @@ -59,7 +60,7 @@ ostream &operator<<(ostream &os, const TC_Cgi_Upload &tcCgiUpload); * @brief cgi上传文件操作,通过该类获取cgi上传的文件信息 * @brief CGI Uploaded File Operation, you can get cgi uploaded file info from this class. */ -class TC_Cgi_Upload +class UTIL_DLL_API TC_Cgi_Upload { public: friend ostream &operator<<(ostream &os, const TC_Cgi_Upload &tcCgiUpload); @@ -214,7 +215,7 @@ class TC_Cgi_Upload * 如果有文件上传需要调用setUpload, 并且需要在parseCgi之前调用 * setUpload, which is called by the uploaded files, needs to be called before parseCgi. */ -class TC_Cgi +class UTIL_DLL_API TC_Cgi { public: diff --git a/util/include/util/tc_clientsocket.h b/util/include/util/tc_clientsocket.h index 4687348f..5bd13f2f 100644 --- a/util/include/util/tc_clientsocket.h +++ b/util/include/util/tc_clientsocket.h @@ -14,7 +14,7 @@ * specific language governing permissions and limitations under the License. */ #pragma once - +#include "util/tc_platform.h" #include "util/tc_socket.h" #include #include "util/tc_http.h" @@ -58,7 +58,7 @@ struct TC_EndpointParse_Exception : public TC_Exception * 此时-h表示的文件路径 * At this time, the file path is represented by '-h' */ -class TC_Endpoint +class UTIL_DLL_API TC_Endpoint { public: //监听类型 @@ -442,7 +442,7 @@ class TC_Endpoint * @brief 客户端socket相关操作基类 * @brief Client Socket Related Operation Base Class */ -class TC_ClientSocket +class UTIL_DLL_API TC_ClientSocket { public: @@ -585,7 +585,7 @@ class TC_ClientSocket * 多线程使用的时候,不用多线程同时send/recv,小心串包; * When using multithreading, do not send/recv at the same time, and be careful of mixing packets; */ -class TC_TCPClient : public TC_ClientSocket +class UTIL_DLL_API TC_TCPClient : public TC_ClientSocket { public: /** @@ -758,7 +758,7 @@ class TC_TCPClient : public TC_ClientSocket * @brief When using multithreading, do not send/recv with multithreading at the same time. Be careful about mixing packets. */ -class TC_UDPClient : public TC_ClientSocket +class UTIL_DLL_API TC_UDPClient : public TC_ClientSocket { public: /** diff --git a/util/include/util/tc_common.h b/util/include/util/tc_common.h index 8542d919..3deecd6c 100644 --- a/util/include/util/tc_common.h +++ b/util/include/util/tc_common.h @@ -87,7 +87,7 @@ class UTIL_DLL_API TC_Common { public: //用于计算时区差异! - class TimezoneHelper + class UTIL_DLL_API TimezoneHelper { public: TimezoneHelper(); @@ -1188,47 +1188,238 @@ vector TC_Common::sepstr(const string &sStr, const string &sSep, bool withEmp return vt; } +// template<> +// string TC_Common::tostr(const bool &t); + +// template<> +// string TC_Common::tostr(const char &t); + +// template<> +// string TC_Common::tostr(const unsigned char &t); + +// template<> +// string TC_Common::tostr(const short &t); + +// template<> +// string TC_Common::tostr(const unsigned short &t); + +// template<> +// string TC_Common::tostr(const int &t); + +// template<> +// string TC_Common::tostr(const unsigned int &t); + +// template<> +// string TC_Common::tostr(const long &t); + +// template<> +// string TC_Common::tostr(const long long &t); + +// template<> +// string TC_Common::tostr(const unsigned long &t); + +// template<> +// string TC_Common::tostr(const float &t); + +// template<> +// string TC_Common::tostr(const double &t); + +// template<> +// string TC_Common::tostr(const long double &t); + +// template<> +// string TC_Common::tostr(const std::string &t); + + template<> -string TC_Common::tostr(const bool &t); +inline string TC_Common::tostr(const bool &t) +{ + char buf[2]; + buf[0] = t ? '1' : '0'; + buf[1] = '\0'; + return string(buf); +} + template<> -string TC_Common::tostr(const char &t); +inline string TC_Common::tostr(const char &t) +{ + char buf[2]; + snprintf(buf, 2, "%c", t); + return string(buf); +} template<> -string TC_Common::tostr(const unsigned char &t); +inline string TC_Common::tostr(const unsigned char &t) +{ + char buf[2]; + snprintf(buf, 2, "%c", t); + return string(buf); +} template<> -string TC_Common::tostr(const short &t); +inline string TC_Common::tostr(const short &t) +{ + char buf[16]; + snprintf(buf, 16, "%d", t); + return string(buf); +} template<> -string TC_Common::tostr(const unsigned short &t); +inline string TC_Common::tostr(const unsigned short &t) +{ + char buf[16]; + snprintf(buf, 16, "%u", t); + return string(buf); +} template<> -string TC_Common::tostr(const int &t); +inline string TC_Common::tostr(const int &t) +{ + char buf[16]; + snprintf(buf, 16, "%d", t); + return string(buf); +} template<> -string TC_Common::tostr(const unsigned int &t); +inline string TC_Common::tostr(const unsigned int &t) +{ + char buf[16]; + snprintf(buf, 16, "%u", t); + return string(buf); +} template<> -string TC_Common::tostr(const long &t); +inline string TC_Common::tostr(const long &t) +{ + char buf[32]; + snprintf(buf, 32, "%ld", t); + return string(buf); +} template<> -string TC_Common::tostr(const long long &t); +inline string TC_Common::tostr(const long long &t) +{ + char buf[32]; + snprintf(buf, 32, "%lld", t); + return string(buf); +} + template<> -string TC_Common::tostr(const unsigned long &t); +inline string TC_Common::tostr(const unsigned long &t) +{ + char buf[32]; + snprintf(buf, 32, "%lu", t); + return string(buf); +} template<> -string TC_Common::tostr(const float &t); +inline string TC_Common::tostr(const float &t) +{ + //C++11 to_string,默认保留后面6位小数 + string s = std::to_string(t); + + //去掉无效0, eg. 1.0300 -> 1.03;1.00 -> 1 + bool bFlag = false; + int pos = int(s.size() - 1); + for (; pos > 0; --pos) + { + if (s[pos] == '0') + { + bFlag = true; + if (s[pos - 1] == '.') + { + //-2为了去掉"."号 + pos -= 2; + break; + } + } + else + { + break; + } + } + + if (bFlag) + s = s.substr(0, pos + 1); + + return s; +} template<> -string TC_Common::tostr(const double &t); +inline string TC_Common::tostr(const double &t) +{ + //C++11 to_string,默认保留后面6位小数 + string s = std::to_string(t); + //去掉无效0, eg. 1.0300 -> 1.03;1.00 -> 1 + bool bFlag = false; + int pos = int(s.size() - 1); + for (; pos > 0; --pos) + { + if (s[pos] == '0') + { + bFlag = true; + if (s[pos - 1] == '.') + { + //-2为了去掉"."号 + pos -= 2; + break; + } + } + else + { + break; + } + } + + if (bFlag) + s = s.substr(0, pos + 1); + + return s; + +} template<> -string TC_Common::tostr(const long double &t); +inline string TC_Common::tostr(const long double &t) +{ + char buf[32]; + snprintf(buf, 32, "%Lf", t); + string s(buf); + + //去掉无效0, eg. 1.0300 -> 1.03;1.00 -> 1 + bool bFlag = false; + int pos = int(s.size() - 1); + for (; pos > 0; --pos) + { + if (s[pos] == '0') + { + bFlag = true; + if (s[pos - 1] == '.') + { + //-2为了去掉"."号 + pos -= 2; + break; + } + } + else + { + break; + } + } + + if (bFlag) + s = s.substr(0, pos + 1); + + return s; + +} template<> -string TC_Common::tostr(const std::string &t); +inline string TC_Common::tostr(const std::string &t) +{ + return t; +} template string TC_Common::tostr(const vector &t) diff --git a/util/include/util/tc_config.h b/util/include/util/tc_config.h index e6447b0a..d03a502c 100644 --- a/util/include/util/tc_config.h +++ b/util/include/util/tc_config.h @@ -19,6 +19,7 @@ #include #include #include +#include "util/tc_platform.h" #include "util/tc_ex.h" namespace tars @@ -75,7 +76,7 @@ struct TC_ConfigNoParam_Exception : public TC_Exception * @brief 定义配置文件中的域的类. * @brief Class that defines the domain in the configuration file */ -class TC_ConfigDomain +class UTIL_DLL_API TC_ConfigDomain { public: friend class TC_Config; @@ -419,7 +420,7 @@ class TC_ConfigDomain * Get Domain Vector: getDomainVector ('/Main', v); 'v' can get a list of Domains to increase the number of the value pairs under the domain or domain */ -class TC_Config +class UTIL_DLL_API TC_Config { public: diff --git a/util/include/util/tc_consistent_hash.h b/util/include/util/tc_consistent_hash.h index eb8ecd35..45d14d0f 100644 --- a/util/include/util/tc_consistent_hash.h +++ b/util/include/util/tc_consistent_hash.h @@ -16,6 +16,7 @@ #pragma once +#include "util/tc_platform.h" #include "util/tc_md5.h" using namespace std; @@ -46,13 +47,11 @@ struct node_T unsigned int iIndex; }; - - /** * @brief 一致性hash算法类 * @brief Consistency hash algorithm class. */ -class TC_ConsistentHash +class UTIL_DLL_API TC_ConsistentHash { public: diff --git a/util/include/util/tc_consistent_hash_new.h b/util/include/util/tc_consistent_hash_new.h index fea88e34..5cc5341f 100755 --- a/util/include/util/tc_consistent_hash_new.h +++ b/util/include/util/tc_consistent_hash_new.h @@ -16,6 +16,7 @@ #pragma once +#include "util/tc_platform.h" #include "util/tc_md5.h" #include "util/tc_autoptr.h" #include "util/tc_hash_fun.h" @@ -79,7 +80,7 @@ class TC_HashAlgFactory * @brief 一致性hash算法类 * @brief Consistency Hash Algorithm Class */ -class TC_ConsistentHashNew +class UTIL_DLL_API TC_ConsistentHashNew { public: diff --git a/util/include/util/tc_coroutine.h b/util/include/util/tc_coroutine.h index 9a84b730..a7af6d9f 100644 --- a/util/include/util/tc_coroutine.h +++ b/util/include/util/tc_coroutine.h @@ -22,7 +22,7 @@ #include #include #include - +#include "util/tc_platform.h" #include "util/tc_fcontext.h" #include "util/tc_thread_queue.h" #include "util/tc_monitor.h" @@ -120,7 +120,7 @@ class TC_CoroutineScheduler; * 协程信息类 * 保存了协程的基本信息, 并将协程用链表的形式组织在一起 */ -class TC_CoroutineInfo +class UTIL_DLL_API TC_CoroutineInfo { public: /** @@ -343,10 +343,8 @@ class TC_CoroutineInfo /** * 协程调度类 */ -class TC_CoroutineScheduler +class UTIL_DLL_API TC_CoroutineScheduler { -protected: - static thread_local shared_ptr g_scheduler; public: @@ -685,7 +683,7 @@ class TC_CoroutineScheduler * 3 调用start函数, 启动线程, 同时会创建iNum个协程, 调度器中最多存在iPoolSize个协程同时运行 * 4 terminate结束 */ -class TC_Coroutine : public TC_Thread +class UTIL_DLL_API TC_Coroutine : public TC_Thread { public: /** diff --git a/util/include/util/tc_coroutine_mutex.h b/util/include/util/tc_coroutine_mutex.h index 694dc72f..525a1403 100644 --- a/util/include/util/tc_coroutine_mutex.h +++ b/util/include/util/tc_coroutine_mutex.h @@ -8,64 +8,66 @@ namespace tars { - ///////////////////////////////////////////////// - /** - * @file tc_coroutine_mutex.h - * @brief 协程锁互斥类 - * - * @author edisenwang - */ - ///////////////////////////////////////////////// - - /** - * @brief 协程锁 . - * - * 开启协程后使用 - */ - class TC_CoMutex{ - protected: - struct CoMutexInfo{ - const std::shared_ptr _sched; - uint32_t _coroId; +///////////////////////////////////////////////// +/** + * @file tc_coroutine_mutex.h + * @brief 协程锁互斥类 + * + * @author edisenwang + */ +///////////////////////////////////////////////// + +/** + * @brief 协程锁 . + * + * 开启协程后使用 + */ +class UTIL_DLL_API TC_CoMutex +{ +protected: + struct CoMutexInfo + { + const std::shared_ptr _sched; + uint32_t _coroId; - CoMutexInfo(const std::shared_ptr sched, uint32_t coroId):_sched(sched), _coroId(coroId){} - }; + CoMutexInfo(const std::shared_ptr sched, uint32_t coroId):_sched(sched), _coroId(coroId){} + }; - public: - TC_CoMutex(); +public: + TC_CoMutex(); - virtual ~TC_CoMutex(); + virtual ~TC_CoMutex(); - /** - * @brief 尝试锁 - * - * @return bool - */ - bool try_lock(); + /** + * @brief 尝试锁 + * + * @return bool + */ + bool try_lock(); - /** - * @brief 加锁 - */ - void lock(); + /** + * @brief 加锁 + */ + void lock(); - /** - * @brief 解锁 - */ - void unlock(); + /** + * @brief 解锁 + */ + void unlock(); - protected: +protected: - // noncopyable - TC_CoMutex(const TC_CoMutex&) = delete; - void operator=(const TC_CoMutex&) = delete; + // noncopyable + TC_CoMutex(const TC_CoMutex&) = delete; + void operator=(const TC_CoMutex&) = delete; - protected: +protected: - TC_SpinLock _slck; + TC_SpinLock _slck; - mutable std::mutex _mutex; + mutable std::mutex _mutex; - std::list _list; - }; + std::list _list; +}; } diff --git a/util/include/util/tc_coroutine_queue.h b/util/include/util/tc_coroutine_queue.h index e2d586c7..da0e4724 100755 --- a/util/include/util/tc_coroutine_queue.h +++ b/util/include/util/tc_coroutine_queue.h @@ -21,6 +21,7 @@ #include #include #include +#include "util/tc_platform.h" #include "util/tc_coroutine.h" using namespace std; diff --git a/util/include/util/tc_cron.h b/util/include/util/tc_cron.h index b3a56db0..86ac96f7 100644 --- a/util/include/util/tc_cron.h +++ b/util/include/util/tc_cron.h @@ -6,6 +6,7 @@ #include #include #include +#include "util/tc_platform.h" #include "util/tc_common.h" #include "util/tc_ex.h" #include @@ -23,7 +24,7 @@ struct TC_CronException : public TC_Exception typedef uint8_t cron_int; -class TC_Cron +class UTIL_DLL_API TC_Cron { public: enum class CronField diff --git a/util/include/util/tc_custom_protocol.h b/util/include/util/tc_custom_protocol.h index 97411cc4..b2eba6d9 100644 --- a/util/include/util/tc_custom_protocol.h +++ b/util/include/util/tc_custom_protocol.h @@ -16,6 +16,7 @@ #pragma once +#include "util/tc_platform.h" #include "util/tc_ex.h" #include "util/tc_port.h" #include "util/tc_common.h" @@ -76,7 +77,7 @@ struct TC_CustomProtoRsp_Exception : public TC_CustomProto_Exception ~TC_CustomProtoRsp_Exception() {}; }; -class TC_CustomProtoReq +class UTIL_DLL_API TC_CustomProtoReq { public: void encode(shared_ptr& buff) @@ -94,7 +95,7 @@ class TC_CustomProtoReq string _buffer; }; -class TC_CustomProtoRsp +class UTIL_DLL_API TC_CustomProtoRsp { public: typedef std::function IncrementDecodeFunc; diff --git a/util/include/util/tc_des.h b/util/include/util/tc_des.h index bef6fab4..07193271 100644 --- a/util/include/util/tc_des.h +++ b/util/include/util/tc_des.h @@ -2,6 +2,7 @@ #include #include +#include "util/tc_platform.h" #include "util/tc_ex.h" using namespace std; @@ -62,7 +63,7 @@ struct TC_DES_Exception : public TC_Exception * The key must be a null-terminated string. * */ -class TC_Des +class UTIL_DLL_API TC_Des { public: /** diff --git a/util/include/util/tc_docker.h b/util/include/util/tc_docker.h index e95e459c..22e33a53 100755 --- a/util/include/util/tc_docker.h +++ b/util/include/util/tc_docker.h @@ -7,7 +7,7 @@ #include #include - +#include "util/tc_platform.h" #include "util/tc_autoptr.h" #include "util/tc_json.h" @@ -27,7 +27,7 @@ class TC_HttpResponse; * 注意: * - 同步等待操作docker, 会阻塞 */ -class TC_Docker +class UTIL_DLL_API TC_Docker { public: diff --git a/util/include/util/tc_dyn_object.h b/util/include/util/tc_dyn_object.h index f18b3073..34cac3ef 100644 --- a/util/include/util/tc_dyn_object.h +++ b/util/include/util/tc_dyn_object.h @@ -17,6 +17,7 @@ #pragma once #include +#include "util/tc_platform.h" namespace tars { @@ -60,7 +61,7 @@ struct TC_DYN_Init } }; -class TC_DYN_Object +class UTIL_DLL_API TC_DYN_Object { public: TC_DYN_Object(){}; diff --git a/util/include/util/tc_encoder.h b/util/include/util/tc_encoder.h index e0a4ed1f..358f20c7 100644 --- a/util/include/util/tc_encoder.h +++ b/util/include/util/tc_encoder.h @@ -16,7 +16,7 @@ #pragma once #include - +#include "util/tc_platform.h" #include "util/tc_ex.h" namespace tars @@ -55,7 +55,7 @@ struct TC_Encoder_Exception : public TC_Exception * 2:UTF8 ==> GBK的转换 * 2: The transformation from UTF8 to GBK */ -class TC_Encoder +class UTIL_DLL_API TC_Encoder { public: diff --git a/util/include/util/tc_epoll_server.h b/util/include/util/tc_epoll_server.h index 82ebced3..afcd1769 100755 --- a/util/include/util/tc_epoll_server.h +++ b/util/include/util/tc_epoll_server.h @@ -24,6 +24,7 @@ #include #include #include +#include "util/tc_platform.h" #include "util/tc_epoller.h" #include "util/tc_thread.h" #include "util/tc_clientsocket.h" @@ -126,7 +127,7 @@ struct TC_EpollServer_Exception : public TC_Exception ~TC_EpollServer_Exception() {}; }; -class TC_EpollServer : public TC_HandleBase, public detail::LogInterface +class UTIL_DLL_API TC_EpollServer : public TC_HandleBase, public detail::LogInterface { public: @@ -172,7 +173,7 @@ class TC_EpollServer : public TC_HandleBase, public detail::LogInterface /** * 接收包的上下文 */ - class RecvContext : public std::enable_shared_from_this + class UTIL_DLL_API RecvContext : public std::enable_shared_from_this { public: RecvContext(int threadIndex, uint32_t uid, @@ -241,7 +242,7 @@ class TC_EpollServer : public TC_HandleBase, public detail::LogInterface * 发送包的上下文 * 由RecvContext创建出来 */ - class SendContext + class UTIL_DLL_API SendContext { public: SendContext(const shared_ptr & context, char cmd) @@ -279,7 +280,7 @@ class TC_EpollServer : public TC_HandleBase, public detail::LogInterface /** * 数据队列包装 */ - class DataBuffer + class UTIL_DLL_API DataBuffer { public: /** @@ -470,7 +471,7 @@ class TC_EpollServer : public TC_HandleBase, public detail::LogInterface /** * 建立连接的socket信息 */ - class Connection + class UTIL_DLL_API Connection { public: /** @@ -803,7 +804,7 @@ class TC_EpollServer : public TC_HandleBase, public detail::LogInterface /** * 带有时间链表的map */ - class ConnectionList + class UTIL_DLL_API ConnectionList { public: /** @@ -973,7 +974,7 @@ class TC_EpollServer : public TC_HandleBase, public detail::LogInterface //////////////////////////////////////////////////////////////////////////// // 服务端口管理,监听socket信息 - class BindAdapter : public enable_shared_from_this // : public TC_HandleBase + class UTIL_DLL_API BindAdapter : public enable_shared_from_this // : public TC_HandleBase { public: /** @@ -1855,7 +1856,7 @@ class TC_EpollServer : public TC_HandleBase, public detail::LogInterface /** * 具体处理基类 */ - class Handle// : public TC_HandleBase + class UTIL_DLL_API Handle// : public TC_HandleBase { public: /** diff --git a/util/include/util/tc_epoller.h b/util/include/util/tc_epoller.h index 27246b5b..6e79f25e 100755 --- a/util/include/util/tc_epoller.h +++ b/util/include/util/tc_epoller.h @@ -65,11 +65,11 @@ namespace tars * @brief epoller操作类,已经默认采用了EPOLLET方式做触发 * @brief epoller operation class, EPOLLET has been used by default for triggering */ -class TC_Epoller : public TC_TimerBase +class UTIL_DLL_API TC_Epoller : public TC_TimerBase { public: - class EpollInfo : public enable_shared_from_this + class UTIL_DLL_API EpollInfo : public enable_shared_from_this { public: /** @@ -198,7 +198,7 @@ class TC_Epoller : public TC_TimerBase /** * @brief 通知epoll从wait中醒过来 */ - class NotifyInfo + class UTIL_DLL_API NotifyInfo { public: diff --git a/util/include/util/tc_ex.h b/util/include/util/tc_ex.h index 2b78c771..4dafd3b6 100644 --- a/util/include/util/tc_ex.h +++ b/util/include/util/tc_ex.h @@ -15,10 +15,9 @@ */ #pragma once - +#include "util/tc_platform.h" #include #include - using namespace std; namespace tars @@ -36,7 +35,7 @@ namespace tars * @brief 异常类. * @brief Exception Class */ -class TC_Exception : public exception +class UTIL_DLL_API TC_Exception : public exception { public: /** diff --git a/util/include/util/tc_fifo.h b/util/include/util/tc_fifo.h index 9476b1e8..680aa3b7 100644 --- a/util/include/util/tc_fifo.h +++ b/util/include/util/tc_fifo.h @@ -36,7 +36,7 @@ namespace tars *@brief 管道操作类. *@brief Pipeline operation. */ -class TC_Fifo +class UTIL_DLL_API TC_Fifo { public: diff --git a/util/include/util/tc_file.h b/util/include/util/tc_file.h index 4063fd8b..edd54b85 100644 --- a/util/include/util/tc_file.h +++ b/util/include/util/tc_file.h @@ -61,7 +61,7 @@ struct TC_File_Exception : public TC_Exception * @brief 常用文件名处理函数. * */ -class TC_File +class UTIL_DLL_API TC_File { public: diff --git a/util/include/util/tc_file_mutex.h b/util/include/util/tc_file_mutex.h index c7e4f193..5e6dea0f 100644 --- a/util/include/util/tc_file_mutex.h +++ b/util/include/util/tc_file_mutex.h @@ -47,7 +47,7 @@ struct TC_FileMutex_Exception : public TC_Lock_Exception * @brief 文件锁, 注意:只能在进程间加锁. * @brief file lock , attion : You can only lock between processes */ -class TC_FileMutex +class UTIL_DLL_API TC_FileMutex { public: diff --git a/util/include/util/tc_grpc.h b/util/include/util/tc_grpc.h index 842efe86..334b0a79 100644 --- a/util/include/util/tc_grpc.h +++ b/util/include/util/tc_grpc.h @@ -1,6 +1,7 @@ #pragma once #include +#include "util/tc_platform.h" #include "util/tc_network_buffer.h" #include "util/tc_spin_lock.h" #include "util/tc_http2.h" @@ -11,7 +12,7 @@ namespace tars void addGrpcPrefix(string& body, bool compressed); bool RemoveGrpcPrefix(string& body, bool* compressed); -class TC_GrpcServer : public TC_Http2Server +class UTIL_DLL_API TC_GrpcServer : public TC_Http2Server { public: @@ -56,7 +57,7 @@ class TC_GrpcServer : public TC_Http2Server ///////////////////////////////////////////////////////////////////////////////// -class TC_GrpcClient : public TC_Http2Client +class UTIL_DLL_API TC_GrpcClient : public TC_Http2Client { public: diff --git a/util/include/util/tc_gzip.h b/util/include/util/tc_gzip.h index 97d8b3f2..216a4be5 100755 --- a/util/include/util/tc_gzip.h +++ b/util/include/util/tc_gzip.h @@ -17,6 +17,7 @@ #pragma once #include "util/tc_platform.h" +#include "util/tc_ex.h" #include #include @@ -35,13 +36,23 @@ namespace tars * @brief Gzip Class, Encapsulated zlib Library */ +/** + * @brief gzip异常类 + * @brief gzip exception class + */ +struct TC_GZip_Exception : public TC_Exception +{ + TC_GZip_Exception(const string &sBuffer) : TC_Exception(sBuffer){}; + ~TC_GZip_Exception() {}; +}; + ///////////////////////////////////////////////// /** * @brief 该类提供标准GZIP压缩和解压算法 * @brief This class provides standard GZIP compression and decompression algorithms */ -class TC_GZip +class UTIL_DLL_API TC_GZip { protected: struct Output diff --git a/util/include/util/tc_hash_fun.h b/util/include/util/tc_hash_fun.h index 62bb7bc0..454d4a68 100644 --- a/util/include/util/tc_hash_fun.h +++ b/util/include/util/tc_hash_fun.h @@ -18,6 +18,7 @@ #include #include +#include "util/tc_platform.h" using namespace std; diff --git a/util/include/util/tc_hashmap.h b/util/include/util/tc_hashmap.h index d3c6f73e..93756d0c 100755 --- a/util/include/util/tc_hashmap.h +++ b/util/include/util/tc_hashmap.h @@ -21,6 +21,7 @@ #include #include #include +#include "util/tc_platform.h" #include "util/tc_ex.h" #include "util/tc_mem_vector.h" #include "util/tc_pack.h" @@ -70,7 +71,7 @@ struct TC_HashMap_Exception : public TC_Exception *支持dump到文件,或从文件load; *Support dump to file or load from file; */ -class TC_HashMap +class UTIL_DLL_API TC_HashMap { public: struct HashMapIterator; diff --git a/util/include/util/tc_hashmap_compact.h b/util/include/util/tc_hashmap_compact.h index 191d0205..d4d9ea3d 100644 --- a/util/include/util/tc_hashmap_compact.h +++ b/util/include/util/tc_hashmap_compact.h @@ -21,6 +21,7 @@ #include #include #include +#include "util/tc_platform.h" #include "util/tc_ex.h" #include "util/tc_mem_vector.h" #include "util/tc_pack.h" @@ -51,7 +52,7 @@ struct TC_HashMapCompact_Exception : public TC_Exception * @brief 紧凑性hashmap. * 基于内存的hashmap,所有操作需要自己加锁 , 使用方式同TC_Hashmap,但是64位系统下更节约额外的管理空间 */ -class TC_HashMapCompact +class UTIL_DLL_API TC_HashMapCompact { public: struct HashMapIterator; diff --git a/util/include/util/tc_http.h b/util/include/util/tc_http.h index 11221132..a2e595e3 100755 --- a/util/include/util/tc_http.h +++ b/util/include/util/tc_http.h @@ -16,6 +16,7 @@ #pragma once +#include "util/tc_platform.h" #include "util/tc_ex.h" #include "util/tc_port.h" #include "util/tc_common.h" @@ -137,7 +138,7 @@ class TC_HttpResponse; * rootPath:ftp://user:password@www.qq.com:8080/. */ -class TC_URL +class UTIL_DLL_API TC_URL { public: @@ -408,7 +409,7 @@ class TC_URL * @brief http协议解析类, 请求和响应都在该类中解析 * @brief HTTP protocol resolution class in which both requests and responses are resolved */ -class TC_Http +class UTIL_DLL_API TC_Http { public: static unordered_map HEADER; @@ -802,7 +803,7 @@ class TC_Http * @brief 简单的Cookie管理类. * @brief Simple Cookie Management Class */ -class TC_HttpCookie +class UTIL_DLL_API TC_HttpCookie { public: typedef map http_cookie_data; @@ -986,7 +987,7 @@ class TC_HttpCookie /********************* TC_HttpResponse ***********************/ -class TC_HttpResponse : public TC_Http +class UTIL_DLL_API TC_HttpResponse : public TC_Http { public: @@ -1324,7 +1325,7 @@ class TC_HttpResponse : public TC_Http /********************* TC_HttpRequest ***********************/ -class TC_HttpRequest : public TC_Http +class UTIL_DLL_API TC_HttpRequest : public TC_Http { public: diff --git a/util/include/util/tc_http2.h b/util/include/util/tc_http2.h index 5e06f858..e5e0b2f5 100644 --- a/util/include/util/tc_http2.h +++ b/util/include/util/tc_http2.h @@ -1,5 +1,5 @@ #pragma once - +#include "util/tc_platform.h" #include "util/tc_http.h" #include "util/tc_spin_lock.h" #include "util/tc_network_buffer.h" @@ -9,7 +9,7 @@ typedef struct nghttp2_session nghttp2_session; namespace tars { -class TC_Http2 +class UTIL_DLL_API TC_Http2 { public: /** @@ -92,7 +92,7 @@ class TC_Http2 }; -class TC_Http2Server : public TC_Http2 +class UTIL_DLL_API TC_Http2Server : public TC_Http2 { public: @@ -169,7 +169,7 @@ class TC_Http2Server : public TC_Http2 ///////////////////////////////////////////////////////////////////////////////// -class TC_Http2Client : public TC_Http2 +class UTIL_DLL_API TC_Http2Client : public TC_Http2 { public: diff --git a/util/include/util/tc_http_async.h b/util/include/util/tc_http_async.h index 03031445..e671e802 100644 --- a/util/include/util/tc_http_async.h +++ b/util/include/util/tc_http_async.h @@ -15,9 +15,9 @@ */ #pragma once +#include "util/tc_platform.h" #include -#include "util/tc_platform.h" #include "util/tc_thread_pool.h" #include "util/tc_network_buffer.h" #include "util/tc_http.h" @@ -65,7 +65,7 @@ struct TC_HttpAsync_Exception : public TC_Exception * @brief 异步线程处理类. * @brief Asynchronous Thread Processing Class */ -class TC_HttpAsync : public TC_Thread, public TC_ThreadLock +class UTIL_DLL_API TC_HttpAsync : public TC_Thread, public TC_ThreadLock { public: /** diff --git a/util/include/util/tc_json.h b/util/include/util/tc_json.h index 29a2daa2..56fd16f8 100755 --- a/util/include/util/tc_json.h +++ b/util/include/util/tc_json.h @@ -22,6 +22,7 @@ #include #include #include +#include "util/tc_platform.h" #include "util/tc_autoptr.h" @@ -54,7 +55,7 @@ enum eJsonType * json类型的基类。没有任何意义 * Base class of type json.No meaning. */ -class JsonValue : public TC_HandleBase +class UTIL_DLL_API JsonValue : public TC_HandleBase { public: virtual eJsonType getType()=0; @@ -68,7 +69,7 @@ typedef TC_AutoPtr JsonValuePtr; * json类型 null * json type null type */ -class JsonValueNull : public JsonValue +class UTIL_DLL_API JsonValueNull : public JsonValue { public: JsonValueNull() @@ -89,7 +90,7 @@ typedef TC_AutoPtr JsonValueNullPtr; * json类型 string类型 例如"dd\ndfd" * json type string type for example: "dd\ndfd" */ -class JsonValueString : public JsonValue +class UTIL_DLL_API JsonValueString : public JsonValue { public: JsonValueString(const string & s):value(s) @@ -115,7 +116,7 @@ typedef TC_AutoPtr JsonValueStringPtr; * json类型 number类型 例如 1.5e8 * json type number type for example: 1.5e8 */ -class JsonValueNum : public JsonValue +class UTIL_DLL_API JsonValueNum : public JsonValue { public: JsonValueNum(double d,bool isInt=false):value(d),lvalue(d),isInt(isInt) @@ -146,7 +147,7 @@ typedef TC_AutoPtr JsonValueNumPtr; * json类型 object类型 例如 {"aa","bb"} * json type object type for example: {"aa","bb"} */ -class JsonValueObj: public JsonValue +class UTIL_DLL_API JsonValueObj: public JsonValue { public: eJsonType getType() @@ -177,7 +178,7 @@ typedef TC_AutoPtr JsonValueObjPtr; * json类型 array类型 例如 ["aa","bb"] * json type array type for example: ["aa","bb"] */ -class JsonValueArray: public JsonValue +class UTIL_DLL_API JsonValueArray: public JsonValue { public: eJsonType getType() @@ -223,7 +224,7 @@ typedef TC_AutoPtr JsonValueArrayPtr; * json类型 boolean类型 例如 true * json type boolean type for example: true */ -class JsonValueBoolean : public JsonValue +class UTIL_DLL_API JsonValueBoolean : public JsonValue { public: JsonValueBoolean() {} @@ -247,7 +248,7 @@ typedef TC_AutoPtr JsonValueBooleanPtr; * 分析json字符串用到的 读字符的类 * Classes for parsing read characters used in JSON strings */ -class BufferJsonReader +class UTIL_DLL_API BufferJsonReader { /*buffer*/ const char * _buf; ///< 缓冲区 @@ -331,7 +332,7 @@ class BufferJsonReader * 分析json的类。都是static * Analyze json's classes.All static. */ -class TC_Json +class UTIL_DLL_API TC_Json { public: //json类型到字符串的转换 @@ -404,7 +405,7 @@ class TC_Json }; -class TC_JsonWriteOstream +class UTIL_DLL_API TC_JsonWriteOstream { public: static void writeValue(const JsonValuePtr & p, ostream& ostr, bool withSpace = false); diff --git a/util/include/util/tc_lock.h b/util/include/util/tc_lock.h index 9def3025..96053c8e 100644 --- a/util/include/util/tc_lock.h +++ b/util/include/util/tc_lock.h @@ -19,6 +19,7 @@ #include #include #include +#include "util/tc_platform.h" #include "util/tc_ex.h" using namespace std; diff --git a/util/include/util/tc_logger.h b/util/include/util/tc_logger.h index 1ccbe89b..07fc940b 100644 --- a/util/include/util/tc_logger.h +++ b/util/include/util/tc_logger.h @@ -16,6 +16,7 @@ #pragma once +#include "util/tc_platform.h" #include "util/tc_autoptr.h" #include "util/tc_common.h" #include "util/tc_ex.h" @@ -277,7 +278,7 @@ namespace tars * 关键点:注册日志后,会保存职能指针,保证日志对象一直存在 * Key point: After registering the log, the function pointer is saved to ensure that the log object always exists */ - class TC_LoggerThreadGroup + class UTIL_DLL_API TC_LoggerThreadGroup { public: /** @@ -385,7 +386,7 @@ namespace tars * @brief 自定义logger buffer * @brief Custom logger buffer */ - class LoggerBuffer : public std::basic_streambuf + class UTIL_DLL_API LoggerBuffer : public std::basic_streambuf { public: /** @@ -493,7 +494,7 @@ namespace tars * @brief 临时类, 析够的时候写日志 * @brief Temporary class, log when enough analysis */ - class LoggerStream + class UTIL_DLL_API LoggerStream { public: /** @@ -1555,7 +1556,7 @@ namespace tars * @brief 根据时间滚动日志分隔类型 * @brief Separation type based on scrolling log */ - class LogType : public TC_HandleBase + UTIL_DLL_API class LogType : public TC_HandleBase { public: LogType() : _next_time_t(0), _format("%Y%m%d"), _frequency(1), _des("day") @@ -1624,7 +1625,7 @@ namespace tars }; typedef TC_AutoPtr LogTypePtr; - class LogByDay : public LogType + UTIL_DLL_API class LogByDay : public LogType { public: static const string FORMAT; @@ -1642,7 +1643,7 @@ namespace tars } }; - class LogByHour : public LogType + UTIL_DLL_API class LogByHour : public LogType { public: static const string FORMAT; @@ -1661,7 +1662,7 @@ namespace tars } }; - class LogByMinute : public LogType + UTIL_DLL_API class LogByMinute : public LogType { public: static const string FORMAT; diff --git a/util/include/util/tc_loop_queue.h b/util/include/util/tc_loop_queue.h index 59092dad..f0d1d763 100644 --- a/util/include/util/tc_loop_queue.h +++ b/util/include/util/tc_loop_queue.h @@ -19,6 +19,7 @@ #include #include #include +#include "util/tc_platform.h" using namespace std; diff --git a/util/include/util/tc_malloc_chunk.h b/util/include/util/tc_malloc_chunk.h index 2d2ca457..829ee35a 100644 --- a/util/include/util/tc_malloc_chunk.h +++ b/util/include/util/tc_malloc_chunk.h @@ -20,6 +20,7 @@ #include #include #include +#include "util/tc_platform.h" using namespace std; @@ -49,7 +50,7 @@ namespace tars * 内存大小所属的大小类别与该内存大小类别需要的内存页的映射 * The mapping of the size category to which the memory size belongs to and the memory pages required by the memory size category */ - class SizeMap + class UTIL_DLL_API SizeMap { public: SizeMap() { Init(); } @@ -125,7 +126,7 @@ namespace tars }; //////////////////////////////////////////////////////////////////////////////////////////////////// - class Static + class UTIL_DLL_API Static { public: static SizeMap* sizemap() @@ -144,7 +145,7 @@ namespace tars * 用于分配sizeof(TC_Span)大小的内存块 * Used to allocate sizeof (TC_Span) size memory block */ - class TC_SpanAllocator + class UTIL_DLL_API TC_SpanAllocator { public: TC_SpanAllocator() : _pHead(NULL), _pData(NULL) {} @@ -253,7 +254,7 @@ namespace tars * 并通过TC_Span和PageMap进行管理 * And through TC_Span and PageMap are managed */ - class TC_Page + class UTIL_DLL_API TC_Page { public: #pragma pack(1) @@ -673,7 +674,7 @@ namespace tars }; //////////////////////////////////////////////////////////////////////////////////////////////////// - class TC_MallocChunkAllocator + class UTIL_DLL_API TC_MallocChunkAllocator { public: TC_MallocChunkAllocator():_pHead(NULL),_pChunk(NULL),_nallocator(NULL) {} diff --git a/util/include/util/tc_md5.h b/util/include/util/tc_md5.h index ab4c2174..9a3fb25f 100644 --- a/util/include/util/tc_md5.h +++ b/util/include/util/tc_md5.h @@ -16,6 +16,7 @@ #pragma once #include +#include "util/tc_platform.h" #include "util/tc_ex.h" #include "util/tc_common.h" @@ -69,7 +70,7 @@ struct TC_MD5_Exception : public TC_Exception ~TC_MD5_Exception() throw(){}; }; -class TC_MD5 +class UTIL_DLL_API TC_MD5 { typedef unsigned char *POINTER; typedef unsigned short int UINT2; diff --git a/util/include/util/tc_mem_chunk.h b/util/include/util/tc_mem_chunk.h index 8b0e1eb2..b979673c 100644 --- a/util/include/util/tc_mem_chunk.h +++ b/util/include/util/tc_mem_chunk.h @@ -17,6 +17,7 @@ #include #include +#include "util/tc_platform.h" using namespace std; @@ -37,7 +38,7 @@ namespace tars * 将连续的内存分成大小相同的块,形成链表,并能够分配和释放这些大小相同的快 * Divides contiguous memory into blocks of the same size, forms a chain table, and is able to allocate and release these blocks of the same size quickly */ -class TC_MemChunk +class UTIL_DLL_API TC_MemChunk { public: @@ -274,7 +275,7 @@ class TC_MemChunk * TC_MemChunk 暂时只支持同一个Block大小的MemChunk * TC_MemChunk temporarily only supports MemChunk of the same block size */ -class TC_MemChunkAllocator +class UTIL_DLL_API TC_MemChunkAllocator { public: @@ -508,7 +509,7 @@ class TC_MemChunkAllocator * 自动计算出块的个数(每种大小块的个数相同) * Automatically calculate the number of blocks (the same number for each size) */ -class TC_MemMultiChunkAllocator +class UTIL_DLL_API TC_MemMultiChunkAllocator { public: diff --git a/util/include/util/tc_mem_queue.h b/util/include/util/tc_mem_queue.h index cce5c9dc..17e18f53 100644 --- a/util/include/util/tc_mem_queue.h +++ b/util/include/util/tc_mem_queue.h @@ -17,6 +17,7 @@ #pragma once #include +#include "util/tc_platform.h" using namespace std; @@ -41,7 +42,7 @@ namespace tars * 做了保护,即使被kill掉,队列不会坏掉,最多错误一个数据 * Protected so that even if killed, the queue will not break, at most one data error */ -class TC_MemQueue +class UTIL_DLL_API TC_MemQueue { public: diff --git a/util/include/util/tc_mem_vector.h b/util/include/util/tc_mem_vector.h index e5d1ad1f..2d058b7e 100644 --- a/util/include/util/tc_mem_vector.h +++ b/util/include/util/tc_mem_vector.h @@ -15,6 +15,7 @@ */ #pragma once +#include "util/tc_platform.h" #include "util/tc_ex.h" #include diff --git a/util/include/util/tc_mmap.h b/util/include/util/tc_mmap.h index 27255c11..b07b3c00 100644 --- a/util/include/util/tc_mmap.h +++ b/util/include/util/tc_mmap.h @@ -64,7 +64,7 @@ struct TC_Mmap_Exception : public TC_Exception * 实现了类似的封装, 推荐直接使用 * Similar encapsulation implemented, recommended for direct use */ -class TC_Mmap +class UTIL_DLL_API TC_Mmap { public: diff --git a/util/include/util/tc_monitor.h b/util/include/util/tc_monitor.h index 24627d88..259b627f 100644 --- a/util/include/util/tc_monitor.h +++ b/util/include/util/tc_monitor.h @@ -15,6 +15,8 @@ */ #pragma once +#include "util/tc_platform.h" + #include "util/tc_thread_mutex.h" #include "util/tc_thread_cond.h" diff --git a/util/include/util/tc_multi_hashmap.h b/util/include/util/tc_multi_hashmap.h index d5da84bc..2f85314a 100644 --- a/util/include/util/tc_multi_hashmap.h +++ b/util/include/util/tc_multi_hashmap.h @@ -21,6 +21,7 @@ #include #include #include +#include "util/tc_platform.h" #include "util/tc_ex.h" #include "util/tc_mem_vector.h" #include "util/tc_pack.h" @@ -59,7 +60,7 @@ struct TC_Multi_HashMap_Exception : public TC_Exception * 所有存储的地址均采用32位保存,为内存块的索引,要求总内存块数不能超过32位范围 * All stored addresses are 32-bit, indexed by memory blocks, requiring that the total number of memory blocks do not exceed the 32-bit range */ -class TC_Multi_HashMap +class UTIL_DLL_API TC_Multi_HashMap { public: struct HashMapIterator; diff --git a/util/include/util/tc_mysql.h b/util/include/util/tc_mysql.h index 17c3d587..feabf824 100644 --- a/util/include/util/tc_mysql.h +++ b/util/include/util/tc_mysql.h @@ -50,7 +50,7 @@ struct TC_Mysql_Exception : public TC_Exception * @brief 数据库配置接口 * @brief Database configuration interface */ -struct TC_DBConf +struct UTIL_DLL_API TC_DBConf { /** * 主机地址 @@ -180,7 +180,7 @@ struct TC_DBConf * TC_Mysql::DB_STR表示组装sql语句时,加””并转义; * TC_Mysql:: DB_STR means to add "" and escape when assembling SQL statements; */ -class TC_Mysql +class UTIL_DLL_API TC_Mysql { public: /** @@ -327,7 +327,7 @@ class TC_Mysql * @brief mysql的一条记录 * @brief A record of MySQL */ - class MysqlRecord + class UTIL_DLL_API MysqlRecord { public: /** @@ -355,7 +355,7 @@ class TC_Mysql * @brief 查询出来的mysql数据 * @brief MySQL data queried */ - class MysqlData + class UTIL_DLL_API MysqlData { public: /** diff --git a/util/include/util/tc_network_buffer.h b/util/include/util/tc_network_buffer.h index 6010d903..4cf92a99 100755 --- a/util/include/util/tc_network_buffer.h +++ b/util/include/util/tc_network_buffer.h @@ -20,6 +20,7 @@ #include #include #include +#include "util/tc_platform.h" #include "util/tc_socket.h" ///////////////////////////////////////////////// @@ -59,7 +60,7 @@ struct TC_NetWorkBuffer_Exception : public TC_Exception ~TC_NetWorkBuffer_Exception() {}; }; -class TC_NetWorkBuffer +class UTIL_DLL_API TC_NetWorkBuffer { public: //////////////////////////////////////////////////////////////////////////// @@ -84,7 +85,7 @@ class TC_NetWorkBuffer /** * buffer */ - class Buffer + class UTIL_DLL_API Buffer { public: diff --git a/util/include/util/tc_openssl.h b/util/include/util/tc_openssl.h index f6706316..31d29de9 100644 --- a/util/include/util/tc_openssl.h +++ b/util/include/util/tc_openssl.h @@ -18,6 +18,8 @@ #include #include +#include "util/tc_platform.h" + #include "util/tc_network_buffer.h" struct ssl_st; @@ -43,7 +45,7 @@ namespace tars /** *@brief OpenSsl wrapper */ -class TC_OpenSSL +class UTIL_DLL_API TC_OpenSSL { public: diff --git a/util/include/util/tc_option.h b/util/include/util/tc_option.h index 8a5c6268..606852eb 100644 --- a/util/include/util/tc_option.h +++ b/util/include/util/tc_option.h @@ -19,6 +19,8 @@ #include #include #include +#include "util/tc_platform.h" + using namespace std; namespace tars @@ -38,7 +40,7 @@ namespace tars * 支持以下形式的参数: ./main.exe --name=value --with abc def * The following form of parameters are supported: ./main.exe --name=value --with abc def */ -class TC_Option +class UTIL_DLL_API TC_Option { public: /** diff --git a/util/include/util/tc_pack.h b/util/include/util/tc_pack.h index 075a7b84..02468035 100644 --- a/util/include/util/tc_pack.h +++ b/util/include/util/tc_pack.h @@ -61,7 +61,7 @@ struct TC_PackOut_Exception : public TC_Exception /** * @brief 组包类, 用户组成一个二进制包 */ -class TC_PackIn +class UTIL_DLL_API TC_PackIn { public: diff --git a/util/include/util/tc_parsepara.h b/util/include/util/tc_parsepara.h index 21826f1c..6908b802 100644 --- a/util/include/util/tc_parsepara.h +++ b/util/include/util/tc_parsepara.h @@ -17,6 +17,7 @@ #include #include +#include "util/tc_platform.h" using namespace std; @@ -44,7 +45,7 @@ namespace tars * @param 型如name=value&name=value字符串 * @param : Types such as name=value&name=value string */ -class TC_Parsepara +class UTIL_DLL_API TC_Parsepara { public: diff --git a/util/include/util/tc_port.h b/util/include/util/tc_port.h index 92c19f7a..aa4ec2d3 100755 --- a/util/include/util/tc_port.h +++ b/util/include/util/tc_port.h @@ -48,7 +48,7 @@ struct TC_Port_Exception : public TC_Exception /** * 跨平台相关函数封装 */ -class TC_Port +class UTIL_DLL_API TC_Port { public: diff --git a/util/include/util/tc_proxy_info.h b/util/include/util/tc_proxy_info.h index 1fe08df3..175933b8 100644 --- a/util/include/util/tc_proxy_info.h +++ b/util/include/util/tc_proxy_info.h @@ -14,6 +14,7 @@ * specific language governing permissions and limitations under the License. */ #pragma once +#include "util/tc_platform.h" #include "util/tc_clientsocket.h" @@ -33,7 +34,7 @@ namespace tars * 6 检查isSuccess, 如果不成功, 则跳转到3, 直到isSuccess * 7 期间检查sendProxyPacket & recvProxyPacket的返回值, 如果为false, 则表示鉴权不通过. */ -class TC_ProxyInfo +class UTIL_DLL_API TC_ProxyInfo { public: TC_ProxyInfo(const TC_Endpoint & ep, const string & user, const string & pass) diff --git a/util/include/util/tc_rbtree.h b/util/include/util/tc_rbtree.h index 376209db..86920d2b 100644 --- a/util/include/util/tc_rbtree.h +++ b/util/include/util/tc_rbtree.h @@ -19,6 +19,8 @@ #include #include #include +#include "util/tc_platform.h" + #include "util/tc_ex.h" #include "util/tc_pack.h" #include "util/tc_mem_chunk.h" @@ -60,7 +62,7 @@ struct TC_RBTree_Exception : public TC_Exception * * 支持dump到文件,或从文件load; */ -class TC_RBTree +class UTIL_DLL_API TC_RBTree { public: struct RBTreeLockIterator; diff --git a/util/include/util/tc_readers_writer_data.h b/util/include/util/tc_readers_writer_data.h index 3d02f56c..74e7ab25 100644 --- a/util/include/util/tc_readers_writer_data.h +++ b/util/include/util/tc_readers_writer_data.h @@ -14,6 +14,7 @@ * specific language governing permissions and limitations under the License. */ #pragma once +#include "util/tc_platform.h" namespace tars { diff --git a/util/include/util/tc_sem_mutex.h b/util/include/util/tc_sem_mutex.h index 1822a0c1..27b42b39 100644 --- a/util/include/util/tc_sem_mutex.h +++ b/util/include/util/tc_sem_mutex.h @@ -60,7 +60,7 @@ typedef int key_t; * 2 采用IPC的信号量实现 * 3 信号量采用了SEM_UNDO参数, 当进程结束时会自动调整信号量 */ -class TC_SemMutex +class UTIL_DLL_API TC_SemMutex { public: /** diff --git a/util/include/util/tc_serialport.h b/util/include/util/tc_serialport.h index 63307228..9bf8bb4b 100644 --- a/util/include/util/tc_serialport.h +++ b/util/include/util/tc_serialport.h @@ -78,7 +78,7 @@ class TC_SerialPortGroup; /** * 异步串口通信类 */ -class TC_SerialPort +class UTIL_DLL_API TC_SerialPort { public: //协议解析器 @@ -264,7 +264,7 @@ class TC_SerialPort }; -class TC_SerialPortGroup +class UTIL_DLL_API TC_SerialPortGroup { public: /** diff --git a/util/include/util/tc_sha.h b/util/include/util/tc_sha.h index 5866a90f..77c781d7 100644 --- a/util/include/util/tc_sha.h +++ b/util/include/util/tc_sha.h @@ -18,6 +18,8 @@ #include #include #include +#include "util/tc_platform.h" + #include "util/tc_ex.h" using namespace std; @@ -58,7 +60,7 @@ struct TC_SHA_Exception : public TC_Exception * @brief sha各种hash算法, * */ -class TC_SHA +class UTIL_DLL_API TC_SHA { public: /** diff --git a/util/include/util/tc_shm.h b/util/include/util/tc_shm.h index e2c18dea..ea319241 100644 --- a/util/include/util/tc_shm.h +++ b/util/include/util/tc_shm.h @@ -57,7 +57,7 @@ typedef int SHMID; * 2 _bOwner=false: 析够时不detach共享内存 * 3 _bOwner=true: 析够时detach共享内存 */ -class TC_Shm +class UTIL_DLL_API TC_Shm { public: diff --git a/util/include/util/tc_singleton.h b/util/include/util/tc_singleton.h index 132ebb2f..79dcbb53 100644 --- a/util/include/util/tc_singleton.h +++ b/util/include/util/tc_singleton.h @@ -15,6 +15,7 @@ */ #pragma once +#include "util/tc_platform.h" #include "util/tc_monitor.h" #include diff --git a/util/include/util/tc_socket.h b/util/include/util/tc_socket.h index 25335665..7aaeaead 100644 --- a/util/include/util/tc_socket.h +++ b/util/include/util/tc_socket.h @@ -84,7 +84,7 @@ struct TC_SocketConnect_Exception : public TC_Socket_Exception /** * @brief Socket类, 封装了socket的基本方法 */ -class TC_Socket +class UTIL_DLL_API TC_Socket { public: /** diff --git a/util/include/util/tc_split.h b/util/include/util/tc_split.h index 70beaa5f..1093bac8 100644 --- a/util/include/util/tc_split.h +++ b/util/include/util/tc_split.h @@ -1,6 +1,7 @@ #pragma once #include +#include "util/tc_platform.h" using namespace std; @@ -17,7 +18,7 @@ namespace tars double dvalue1 = sp.getNextAsDouble(); double dvalue2 = sp.getNextAsDouble(); */ -class TC_Split +class UTIL_DLL_API TC_Split { public: diff --git a/util/include/util/tc_squeue.h b/util/include/util/tc_squeue.h index 7b10550b..b8422eeb 100644 --- a/util/include/util/tc_squeue.h +++ b/util/include/util/tc_squeue.h @@ -22,6 +22,8 @@ #include #include #include +#include "util/tc_platform.h" + #include "util/tc_ex.h" /** * 结构化的queue,在一边读一边写的情况下可以不用加锁,是线程(进程)安全的 @@ -41,7 +43,7 @@ struct TC_SQueue_Exception : public TC_Exception ~TC_SQueue_Exception() throw(){}; }; -class TC_SQueue +class UTIL_DLL_API TC_SQueue { public: TC_SQueue() {_header = NULL;_data = NULL;} diff --git a/util/include/util/tc_tea.h b/util/include/util/tc_tea.h index d41f41db..2a9ab36d 100644 --- a/util/include/util/tc_tea.h +++ b/util/include/util/tc_tea.h @@ -33,7 +33,7 @@ struct TC_Tea_Exception : public TC_Exception /** * @brief tea算法,通常用第二代算法 */ -class TC_Tea +class UTIL_DLL_API TC_Tea { public: diff --git a/util/include/util/tc_thread.h b/util/include/util/tc_thread.h index 84af43c3..9341fa49 100644 --- a/util/include/util/tc_thread.h +++ b/util/include/util/tc_thread.h @@ -17,8 +17,8 @@ #include #include -// #include #include +#include "util/tc_platform.h" #include "util/tc_ex.h" #include "util/tc_monitor.h" @@ -52,7 +52,7 @@ class TC_CoroutineScheduler; /** * @brief 线程控制类 */ -class TC_ThreadControl +class UTIL_DLL_API TC_ThreadControl { public: @@ -112,7 +112,7 @@ class TC_Runable * * 可以通过TC_ThreadControl管理线程。 */ -class TC_Thread : public TC_Runable +class UTIL_DLL_API TC_Thread : public TC_Runable { public: diff --git a/util/include/util/tc_thread_cond.h b/util/include/util/tc_thread_cond.h index 5c38f16b..31d0bbd8 100644 --- a/util/include/util/tc_thread_cond.h +++ b/util/include/util/tc_thread_cond.h @@ -41,7 +41,7 @@ class TC_ThreadMutex; * * 通常不直接使用,而是使用TC_ThreadLock/TC_ThreadRecLock; */ -class TC_ThreadCond +class UTIL_DLL_API TC_ThreadCond { public: diff --git a/util/include/util/tc_thread_pool.h b/util/include/util/tc_thread_pool.h index bd0fa3e1..6e011ff4 100644 --- a/util/include/util/tc_thread_pool.h +++ b/util/include/util/tc_thread_pool.h @@ -78,7 +78,7 @@ struct TC_ThreadPool_Exception : public TC_Exception * 使用方式说明: * 具体示例代码请参见:examples/util/example_tc_thread_pool.cpp */ -class TC_ThreadPool +class UTIL_DLL_API TC_ThreadPool { protected: struct TaskFunc @@ -234,7 +234,7 @@ class TC_ThreadPool //根据keyhash的线程池 -class TC_ThreadPoolHash +class UTIL_DLL_API TC_ThreadPoolHash { public: TC_ThreadPoolHash(); diff --git a/util/include/util/tc_thread_queue.h b/util/include/util/tc_thread_queue.h index 62f66d42..206acf7c 100644 --- a/util/include/util/tc_thread_queue.h +++ b/util/include/util/tc_thread_queue.h @@ -20,6 +20,7 @@ #include #include #include +#include "util/tc_platform.h" using namespace std; diff --git a/util/include/util/tc_timeout_queue.h b/util/include/util/tc_timeout_queue.h index 96dce430..40d92677 100644 --- a/util/include/util/tc_timeout_queue.h +++ b/util/include/util/tc_timeout_queue.h @@ -21,6 +21,7 @@ #include #include #include +#include "util/tc_platform.h" #include "util/tc_autoptr.h" #include #include diff --git a/util/include/util/tc_timeout_queue_map.h b/util/include/util/tc_timeout_queue_map.h index f48a94d2..2ffc5522 100644 --- a/util/include/util/tc_timeout_queue_map.h +++ b/util/include/util/tc_timeout_queue_map.h @@ -8,6 +8,7 @@ #include #include #include +#include "util/tc_platform.h" namespace tars { diff --git a/util/include/util/tc_timeout_queue_new.h b/util/include/util/tc_timeout_queue_new.h index b50b2145..e5750a6a 100644 --- a/util/include/util/tc_timeout_queue_new.h +++ b/util/include/util/tc_timeout_queue_new.h @@ -18,13 +18,12 @@ #include #include #include -// #include #include #include #include +#include "util/tc_platform.h" #include "util/tc_autoptr.h" #include "util/tc_monitor.h" -// #include "util/tc_functor.h" #include "util/tc_timeprovider.h" using namespace std; diff --git a/util/include/util/tc_timeout_queue_noid.h b/util/include/util/tc_timeout_queue_noid.h index c4f81863..e76e8987 100644 --- a/util/include/util/tc_timeout_queue_noid.h +++ b/util/include/util/tc_timeout_queue_noid.h @@ -19,6 +19,8 @@ #include #include #include +#include "util/tc_platform.h" + #include "util/tc_autoptr.h" #include "util/tc_monitor.h" #include "util/tc_timeprovider.h" diff --git a/util/include/util/tc_timer.h b/util/include/util/tc_timer.h index e356e79b..a996df22 100644 --- a/util/include/util/tc_timer.h +++ b/util/include/util/tc_timer.h @@ -21,6 +21,7 @@ #include #include #include +#include "util/tc_platform.h" #include "util/tc_thread_pool.h" #include "util/tc_timeprovider.h" @@ -44,7 +45,7 @@ namespace tars /** * @brief 定时器类 */ -class TC_TimerBase +class UTIL_DLL_API TC_TimerBase { protected: @@ -301,7 +302,7 @@ class TC_TimerBase /** * @brief 定时器类 */ -class TC_Timer : public TC_TimerBase +class UTIL_DLL_API TC_Timer : public TC_TimerBase { public: diff --git a/util/include/util/tc_transceiver.h b/util/include/util/tc_transceiver.h index b840e1fa..0b353945 100644 --- a/util/include/util/tc_transceiver.h +++ b/util/include/util/tc_transceiver.h @@ -68,7 +68,7 @@ struct TC_Transceiver_Exception : public TC_Exception * 10 具体客户端使用方式可以参考: CommunicatorEpoll类, 服务端参考: tc_epoll_server * */ -class TC_Transceiver +class UTIL_DLL_API TC_Transceiver { public: /** @@ -653,7 +653,7 @@ class TC_Transceiver /** * TCP 传输实现 */ -class TC_TCPTransceiver : public TC_Transceiver +class UTIL_DLL_API TC_TCPTransceiver : public TC_Transceiver { public: /** @@ -694,7 +694,7 @@ class TC_TCPTransceiver : public TC_Transceiver /** * SSL 传输实现 */ -class TC_SSLTransceiver : public TC_TCPTransceiver +class UTIL_DLL_API TC_SSLTransceiver : public TC_TCPTransceiver { public: /** @@ -715,7 +715,7 @@ class TC_SSLTransceiver : public TC_TCPTransceiver /** * UDP 传输实现 */ -class TC_UDPTransceiver : public TC_Transceiver +class UTIL_DLL_API TC_UDPTransceiver : public TC_Transceiver { public: diff --git a/util/include/util/tc_uuid_generator.h b/util/include/util/tc_uuid_generator.h index 7596f06e..c5bca38f 100644 --- a/util/include/util/tc_uuid_generator.h +++ b/util/include/util/tc_uuid_generator.h @@ -3,10 +3,8 @@ #include "util/tc_platform.h" #if TARGET_PLATFORM_LINUX || TARGET_PLATFORM_IOS #include -//#include #else #include -//#include #endif #include diff --git a/util/include/util/tc_xml.h b/util/include/util/tc_xml.h index aa592940..7ef7e57f 100755 --- a/util/include/util/tc_xml.h +++ b/util/include/util/tc_xml.h @@ -7,6 +7,7 @@ #include #include +#include "util/tc_platform.h" #include "util/tc_autoptr.h" using namespace std; @@ -38,7 +39,7 @@ enum eXmlType /* * Xml类型的基类。没有任何意义 */ -class XmlValue : public tars::TC_HandleBase +class UTIL_DLL_API XmlValue : public tars::TC_HandleBase { public: virtual eXmlType getType()=0; @@ -52,7 +53,7 @@ typedef tars::TC_AutoPtr XmlValuePtr; /* * Xml类型 string类型 */ -class XmlValueString : public XmlValue +class UTIL_DLL_API XmlValueString : public XmlValue { public: XmlValueString(const string & s, bool _cdata = false):value(s), cdata(_cdata) @@ -76,7 +77,7 @@ typedef tars::TC_AutoPtr XmlValueStringPtr; /* * Xml类型 object类型 例如 */ -class XmlValueObj: public XmlValue +class UTIL_DLL_API XmlValueObj: public XmlValue { public: eXmlType getType() @@ -92,7 +93,7 @@ typedef tars::TC_AutoPtr XmlValueObjPtr; /* * Xml类型 array类型 例如 */ -class XmlValueArray: public XmlValue +class UTIL_DLL_API XmlValueArray: public XmlValue { public: eXmlType getType() @@ -112,7 +113,7 @@ typedef tars::TC_AutoPtr XmlValueArrayPtr; /* * 分析Xml字符串用到的 读字符的类 */ -class BufferXmlReader +class UTIL_DLL_API BufferXmlReader { public: const char * _buf; ///< 缓冲区 @@ -190,7 +191,7 @@ class BufferXmlReader /* * 分析Xml的类。都是static */ -class TC_Xml +class UTIL_DLL_API TC_Xml { public: //Xml类型到字符串的转换 diff --git a/util/src/CMakeLists.txt b/util/src/CMakeLists.txt index 279f9072..643f50bb 100644 --- a/util/src/CMakeLists.txt +++ b/util/src/CMakeLists.txt @@ -33,21 +33,19 @@ install(TARGETS tarsutil ARCHIVE DESTINATION lib) if(ENABLE_SHARED) + ADD_DEFINITIONS( -DUTIL_DLL_EXPORT ) add_library(tarsutil_shared SHARED ${DIR_SRCS}) target_link_libraries(tarsutil_shared libmysql) - target_compile_definitions(tarsutil_shared PRIVATE UTIL_DLL_EXPORT) + # target_compile_definitions(tarsutil_shared PRIVATE UTIL_DLL_EXPORT) if (TARS_SSL) if (WIN32) #windows动态编译需添加依赖库 target_link_libraries(tarsutil_shared ${LIB_SSL}.lib ${LIB_CRYPTO}.lib Crypt32) - #else () - #linux动态编译未验证,暂时屏蔽 - #target_link_libraries(${LIB_TAF_UTIL} ${LIB_SSL}.a ${LIB_CRYPTO}.a) endif () endif() - add_dependencies(tarsutil_shared tarsutil) + add_dependencies(tarsutil_shared thirdparty) install(TARGETS tarsutil_shared LIBRARY DESTINATION lib diff --git a/util/src/tc_common.cpp b/util/src/tc_common.cpp index 11a5e7bc..89716d59 100644 --- a/util/src/tc_common.cpp +++ b/util/src/tc_common.cpp @@ -144,195 +144,195 @@ bool TC_Common::equal(const unordered_set& vx, const unordered_set MATCH_DOUBLE } -template<> -string TC_Common::tostr(const bool &t) -{ - char buf[2]; - buf[0] = t ? '1' : '0'; - buf[1] = '\0'; - return string(buf); -} - - -template<> -string TC_Common::tostr(const char &t) -{ - char buf[2]; - snprintf(buf, 2, "%c", t); - return string(buf); -} - -template<> -string TC_Common::tostr(const unsigned char &t) -{ - char buf[2]; - snprintf(buf, 2, "%c", t); - return string(buf); -} - -template<> -string TC_Common::tostr(const short &t) -{ - char buf[16]; - snprintf(buf, 16, "%d", t); - return string(buf); -} - -template<> -string TC_Common::tostr(const unsigned short &t) -{ - char buf[16]; - snprintf(buf, 16, "%u", t); - return string(buf); -} - -template<> -string TC_Common::tostr(const int &t) -{ - char buf[16]; - snprintf(buf, 16, "%d", t); - return string(buf); -} - -template<> -string TC_Common::tostr(const unsigned int &t) -{ - char buf[16]; - snprintf(buf, 16, "%u", t); - return string(buf); -} - -template<> -string TC_Common::tostr(const long &t) -{ - char buf[32]; - snprintf(buf, 32, "%ld", t); - return string(buf); -} - -template<> -string TC_Common::tostr(const long long &t) -{ - char buf[32]; - snprintf(buf, 32, "%lld", t); - return string(buf); -} - - -template<> -string TC_Common::tostr(const unsigned long &t) -{ - char buf[32]; - snprintf(buf, 32, "%lu", t); - return string(buf); -} - -template<> -string TC_Common::tostr(const float &t) -{ - //C++11 to_string,默认保留后面6位小数 - string s = std::to_string(t); - - //去掉无效0, eg. 1.0300 -> 1.03;1.00 -> 1 - bool bFlag = false; - int pos = int(s.size() - 1); - for (; pos > 0; --pos) - { - if (s[pos] == '0') - { - bFlag = true; - if (s[pos - 1] == '.') - { - //-2为了去掉"."号 - pos -= 2; - break; - } - } - else - { - break; - } - } - - if (bFlag) - s = s.substr(0, pos + 1); - - return s; -} - -template<> -string TC_Common::tostr(const double &t) -{ - //C++11 to_string,默认保留后面6位小数 - string s = std::to_string(t); - //去掉无效0, eg. 1.0300 -> 1.03;1.00 -> 1 - bool bFlag = false; - int pos = int(s.size() - 1); - for (; pos > 0; --pos) - { - if (s[pos] == '0') - { - bFlag = true; - if (s[pos - 1] == '.') - { - //-2为了去掉"."号 - pos -= 2; - break; - } - } - else - { - break; - } - } - - if (bFlag) - s = s.substr(0, pos + 1); - - return s; - -} - -template<> -string TC_Common::tostr(const long double &t) -{ - char buf[32]; - snprintf(buf, 32, "%Lf", t); - string s(buf); - - //去掉无效0, eg. 1.0300 -> 1.03;1.00 -> 1 - bool bFlag = false; - int pos = int(s.size() - 1); - for (; pos > 0; --pos) - { - if (s[pos] == '0') - { - bFlag = true; - if (s[pos - 1] == '.') - { - //-2为了去掉"."号 - pos -= 2; - break; - } - } - else - { - break; - } - } - - if (bFlag) - s = s.substr(0, pos + 1); - - return s; - -} - -template<> -string TC_Common::tostr(const std::string &t) -{ - return t; -} +// template<> +// string TC_Common::tostr(const bool &t) +// { +// char buf[2]; +// buf[0] = t ? '1' : '0'; +// buf[1] = '\0'; +// return string(buf); +// } + + +// template<> +// string TC_Common::tostr(const char &t) +// { +// char buf[2]; +// snprintf(buf, 2, "%c", t); +// return string(buf); +// } + +// template<> +// string TC_Common::tostr(const unsigned char &t) +// { +// char buf[2]; +// snprintf(buf, 2, "%c", t); +// return string(buf); +// } + +// template<> +// string TC_Common::tostr(const short &t) +// { +// char buf[16]; +// snprintf(buf, 16, "%d", t); +// return string(buf); +// } + +// template<> +// string TC_Common::tostr(const unsigned short &t) +// { +// char buf[16]; +// snprintf(buf, 16, "%u", t); +// return string(buf); +// } + +// template<> +// string TC_Common::tostr(const int &t) +// { +// char buf[16]; +// snprintf(buf, 16, "%d", t); +// return string(buf); +// } + +// template<> +// string TC_Common::tostr(const unsigned int &t) +// { +// char buf[16]; +// snprintf(buf, 16, "%u", t); +// return string(buf); +// } + +// template<> +// string TC_Common::tostr(const long &t) +// { +// char buf[32]; +// snprintf(buf, 32, "%ld", t); +// return string(buf); +// } + +// template<> +// string TC_Common::tostr(const long long &t) +// { +// char buf[32]; +// snprintf(buf, 32, "%lld", t); +// return string(buf); +// } + + +// template<> +// string TC_Common::tostr(const unsigned long &t) +// { +// char buf[32]; +// snprintf(buf, 32, "%lu", t); +// return string(buf); +// } + +// template<> +// string TC_Common::tostr(const float &t) +// { +// //C++11 to_string,默认保留后面6位小数 +// string s = std::to_string(t); + +// //去掉无效0, eg. 1.0300 -> 1.03;1.00 -> 1 +// bool bFlag = false; +// int pos = int(s.size() - 1); +// for (; pos > 0; --pos) +// { +// if (s[pos] == '0') +// { +// bFlag = true; +// if (s[pos - 1] == '.') +// { +// //-2为了去掉"."号 +// pos -= 2; +// break; +// } +// } +// else +// { +// break; +// } +// } + +// if (bFlag) +// s = s.substr(0, pos + 1); + +// return s; +// } + +// template<> +// string TC_Common::tostr(const double &t) +// { +// //C++11 to_string,默认保留后面6位小数 +// string s = std::to_string(t); +// //去掉无效0, eg. 1.0300 -> 1.03;1.00 -> 1 +// bool bFlag = false; +// int pos = int(s.size() - 1); +// for (; pos > 0; --pos) +// { +// if (s[pos] == '0') +// { +// bFlag = true; +// if (s[pos - 1] == '.') +// { +// //-2为了去掉"."号 +// pos -= 2; +// break; +// } +// } +// else +// { +// break; +// } +// } + +// if (bFlag) +// s = s.substr(0, pos + 1); + +// return s; + +// } + +// template<> +// string TC_Common::tostr(const long double &t) +// { +// char buf[32]; +// snprintf(buf, 32, "%Lf", t); +// string s(buf); + +// //去掉无效0, eg. 1.0300 -> 1.03;1.00 -> 1 +// bool bFlag = false; +// int pos = int(s.size() - 1); +// for (; pos > 0; --pos) +// { +// if (s[pos] == '0') +// { +// bFlag = true; +// if (s[pos - 1] == '.') +// { +// //-2为了去掉"."号 +// pos -= 2; +// break; +// } +// } +// else +// { +// break; +// } +// } + +// if (bFlag) +// s = s.substr(0, pos + 1); + +// return s; + +// } + +// template<> +// string TC_Common::tostr(const std::string &t) +// { +// return t; +// } string TC_Common::trim(const string &sStr, const string &s, bool bChar) { diff --git a/util/src/tc_coroutine.cpp b/util/src/tc_coroutine.cpp index 53c74bca..a80be947 100755 --- a/util/src/tc_coroutine.cpp +++ b/util/src/tc_coroutine.cpp @@ -297,7 +297,7 @@ void TC_CoroutineInfo::corotineProc(void * args, transfer_t t) /////////////////////////////////////////////////////////////////////////////////////////// -thread_local shared_ptr TC_CoroutineScheduler::g_scheduler; +thread_local shared_ptr g_scheduler; const shared_ptr &TC_CoroutineScheduler::create() { diff --git a/util/src/tc_gzip.cpp b/util/src/tc_gzip.cpp index 2f0f441b..138cac17 100644 --- a/util/src/tc_gzip.cpp +++ b/util/src/tc_gzip.cpp @@ -197,4 +197,27 @@ bool TC_GZip::uncompress(const char *src, size_t length, TC_GZip::Output* o) } +#else + + +namespace tars +{ + +bool TC_GZip::compress(const char *src, size_t length, string& buffer) +{ + throw TC_GZip_Exception("[TC_GZip::compress] zlib not support"); + +} + +bool TC_GZip::compress(const char *src, size_t length, vector& buffer) +{ + throw TC_GZip_Exception("[TC_GZip::compress] zlib not support"); +} + +bool TC_GZip::uncompress(const char *src, size_t length, TC_GZip::Output* o) +{ + throw TC_GZip_Exception("[TC_GZip::uncompress] zlib not support"); +} + +} #endif diff --git a/util/src/tc_transceiver.cpp b/util/src/tc_transceiver.cpp index 2fee18bd..bed55b66 100644 --- a/util/src/tc_transceiver.cpp +++ b/util/src/tc_transceiver.cpp @@ -984,7 +984,7 @@ bool TC_TCPTransceiver::doResponse() do { // auto data = _recvBuffer.getOrCreateBuffer(BUFFER_SIZE / 8, BUFFER_SIZE); - size_t expansion = std::max(std::min(_recvBuffer.getBufferLength(), (size_t)MAX_BUFFER_SIZE), (size_t)BUFFER_SIZE); + size_t expansion = (std::max)((std::min)(_recvBuffer.getBufferLength(), (size_t)MAX_BUFFER_SIZE), (size_t)BUFFER_SIZE); auto data = _recvBuffer.getOrCreateBuffer(BUFFER_SIZE / 8, expansion); uint32_t left = (uint32_t)data->left(); @@ -1086,29 +1086,31 @@ int TC_TCPTransceiver::recv(void* buf, uint32_t len, uint32_t flag) return iRet; } ///////////////////////////////////////////////////////////////// -#if TARS_SSL TC_SSLTransceiver::TC_SSLTransceiver(TC_Epoller* epoller, const TC_Endpoint &ep) : TC_TCPTransceiver(epoller, ep) { } -#if 0 - bool TC_SSLTransceiver::doResponse() { - checkConnect(); +#if TARS_SSL + checkConnect(); int iRet = 0; + int64_t now = TNOWMS; -// int packetCount = 0; do { - char buff[BUFFER_SIZE] = {0x00}; - if ((iRet = this->recv(buff, BUFFER_SIZE, 0)) > 0) + auto data = _recvBuffer.getOrCreateBuffer(BUFFER_SIZE/8, BUFFER_SIZE); + + uint32_t left = (uint32_t)data->left(); + + if ((iRet = this->recv((void*)data->free(), left, 0)) > 0) { - int check = doCheckProxy(buff, iRet); + int check = doCheckProxy(data->free(), iRet); + if(check != 0) { return true; @@ -1116,7 +1118,8 @@ bool TC_SSLTransceiver::doResponse() const bool preHandshake = _openssl->isHandshaked(); - int ret = _openssl->read(buff, iRet, _sendBuffer); + int ret = _openssl->read(data->free(), iRet, _sendBuffer); + if (ret != 0) { // LOG_CONSOLE_DEBUG << "ret:" << ret << ", " << _openssl->getErrMsg() << endl; @@ -1124,25 +1127,9 @@ bool TC_SSLTransceiver::doResponse() } else if(!_sendBuffer.empty()) { -// LOG_CONSOLE_DEBUG << "[Transceiver::doResponse SSL_read prehandshake:" << preHandshake << ", handshake:" << _openssl->isHandshaked() << ", send handshake len:" << _sendBuffer.getBufferLength() << endl; - int ret = doRequest(); - - if(ret < 0) - { - // doRequest失败 close fd - if (!isValid()) - { - THROW_ERROR(TC_Transceiver_Exception, CR_SSL, "[TC_SSLTransceiver::doResponse, ssl doRequest failed: " + _desc + ", info: " + _openssl->getErrMsg() + "]"); - } - else - { - return true; - } - } + doRequest(); } -// LOG_CONSOLE_DEBUG << "recv length:" << iRet << ", preHandshake:" << preHandshake << endl; - if (!_openssl->isHandshaked()) { // LOG_CONSOLE_DEBUG << "[Transceiver::doResponse not handshake, prehandshake:" << preHandshake << ", handshake:" << _openssl->isHandshaked() << endl; @@ -1186,7 +1173,7 @@ bool TC_SSLTransceiver::doResponse() } //接收的数据小于buffer大小, 内核会再次通知你 - if(iRet < BUFFER_SIZE) + if(iRet < left) { break; } @@ -1200,108 +1187,11 @@ bool TC_SSLTransceiver::doResponse() } return iRet != 0; -} - #else - -bool TC_SSLTransceiver::doResponse() -{ - checkConnect(); - - int iRet = 0; - - int64_t now = TNOWMS; - - do - { - auto data = _recvBuffer.getOrCreateBuffer(BUFFER_SIZE/8, BUFFER_SIZE); - - uint32_t left = (uint32_t)data->left(); - - if ((iRet = this->recv((void*)data->free(), left, 0)) > 0) - { - int check = doCheckProxy(data->free(), iRet); - - if(check != 0) - { - return true; - } - - const bool preHandshake = _openssl->isHandshaked(); - - int ret = _openssl->read(data->free(), iRet, _sendBuffer); - - if (ret != 0) - { -// LOG_CONSOLE_DEBUG << "ret:" << ret << ", " << _openssl->getErrMsg() << endl; - THROW_ERROR(TC_Transceiver_Exception, CR_SSL, "[TC_SSLTransceiver::doResponse, SSL_read handshake failed: " + _desc + ", info: " + _openssl->getErrMsg() + "]"); - } - else if(!_sendBuffer.empty()) - { - doRequest(); - } - - if (!_openssl->isHandshaked()) - { -// LOG_CONSOLE_DEBUG << "[Transceiver::doResponse not handshake, prehandshake:" << preHandshake << ", handshake:" << _openssl->isHandshaked() << endl; - return true; - } - - if (!preHandshake) - { - if(_isServer) - { - _onRequestCallback(this); - } - else - { - //握手完毕, 客户端直接发送鉴权请求 - doAuthReq(); - // doAuthReq失败,会close fd, 这里判断下是否还有效 - if (!isValid()) - { - THROW_ERROR(TC_Transceiver_Exception, CR_SSL, - "[TC_SSLTransceiver::doResponse, doAuthReq failed: " + _desc + ", info: " + - _openssl->getErrMsg() + "]"); - } - else - { -// LOG_CONSOLE_DEBUG << "[Transceiver::doResponse prehandshake:" << preHandshake << ", handshake:" << _openssl->isHandshaked() << endl; - } - } - } - - TC_NetWorkBuffer *rbuf = _openssl->recvBuffer(); - - //解析协议 - doProtocolAnalysis(rbuf); - - //收包太多了, 中断一下, 释放线程给send等 - if (TNOWMS - now >= LONG_NETWORK_TRANS_TIME && isValid()) - { - _epollInfo->mod(EPOLLIN | EPOLLOUT); - break; - } - - //接收的数据小于buffer大小, 内核会再次通知你 - if(iRet < left) - { - break; - } - } - } - while (iRet>0); - - if(iRet == 0) - { - tcpClose(false, CR_PEER_CLOSE, "peer close connection"); - } - - return iRet != 0; - } - -#endif + THROW_ERROR(TC_Transceiver_Exception, CR_SSL, "[TC_SSLTransceiver::doResponse, ssl not support!]"); + return false; #endif +} ///////////////////////////////////////////////////////////////// TC_UDPTransceiver::TC_UDPTransceiver(TC_Epoller* epoller, const TC_Endpoint& ep) From d40a3b8140accffbe538b0fc0b6d44e1ffc54081 Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Fri, 25 Oct 2024 08:56:20 +0800 Subject: [PATCH 40/44] fix cmake build dynamic lib in mac bug --- util/src/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/src/CMakeLists.txt b/util/src/CMakeLists.txt index 643f50bb..4107c377 100644 --- a/util/src/CMakeLists.txt +++ b/util/src/CMakeLists.txt @@ -36,8 +36,7 @@ if(ENABLE_SHARED) ADD_DEFINITIONS( -DUTIL_DLL_EXPORT ) add_library(tarsutil_shared SHARED ${DIR_SRCS}) - target_link_libraries(tarsutil_shared libmysql) - # target_compile_definitions(tarsutil_shared PRIVATE UTIL_DLL_EXPORT) + target_link_libraries(tarsutil_shared ${LIB_MYSQL}) if (TARS_SSL) if (WIN32) From 40c62933321dce3b7226cf29b68af0e619851d2e Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Fri, 25 Oct 2024 11:02:26 +0800 Subject: [PATCH 41/44] tars-tools.cmake support dynamic of ssl https mysql in mac --- cmake/Thirdparty.cmake | 76 +++----------------- servant/makefile/tars-tools.cmake.in | 103 +++++++++++++++++++-------- tools/pb2tarscpp/CMakeLists.txt | 1 + util/src/CMakeLists.txt | 6 ++ 4 files changed, 90 insertions(+), 96 deletions(-) diff --git a/cmake/Thirdparty.cmake b/cmake/Thirdparty.cmake index a48edfc1..9c76f866 100755 --- a/cmake/Thirdparty.cmake +++ b/cmake/Thirdparty.cmake @@ -8,19 +8,6 @@ endif(UNIX) option(TARS_SSL "option for ssl" OFF) option(TARS_HTTP2 "option for http2" OFF) option(TARS_PROTOBUF "option for protocol" OFF) -#option(TARS_GPERF "option for gperf" OFF) - -#IF(UNIX) -# FIND_PACKAGE(ZLIB) -# IF(NOT ZLIB_FOUND) -# SET(ERRORMSG "zlib library not found. Please install appropriate package, remove CMakeCache.txt and rerun cmake.") -# IF(CMAKE_SYSTEM_NAME MATCHES "Linux") -# SET(ERRORMSG ${ERRORMSG} "On Debian/Ubuntu, package name is zlib1g-dev(apt-get install zlib1g-dev), on Redhat/Centos and derivates it is zlib-devel (yum install zlib-devel).") -# ENDIF() -# MESSAGE(FATAL_ERROR ${ERRORMSG}) -# ENDIF() -# -#ENDIF(UNIX) if (TARS_MYSQL) add_definitions(-DTARS_MYSQL=1) @@ -30,10 +17,6 @@ if (TARS_GZIP) add_definitions(-DTARS_GZIP=1) endif () -#if (TARS_GPERF) -# add_definitions(-DTARS_GPERF=1) -#endif () - if (TARS_SSL) add_definitions(-DTARS_SSL=1) endif () @@ -57,51 +40,12 @@ set(LIB_SSL) set(LIB_CRYPTO) set(LIB_PROTOBUF) set(LIB_GTEST) -#set(LIB_GPERF) -#set(LIB_TCMALLOC_PROFILER) -#set(LIB_TCMALLOC_MINIMAL) + #------------------------------------------------------------- add_custom_target(thirdparty) include(ExternalProject) -# -#if (TARS_GPERF) -# -# set(GPERF_DIR_INC "${THIRDPARTY_PATH}/gperf/include") -# set(GRPEF_DIR_LIB "${THIRDPARTY_PATH}/gperf/lib") -# include_directories(${GPERF_DIR_INC}) -# link_directories(${GRPEF_DIR_LIB}) -# -# if (UNIX) -# set(LIB_GPERF "profiler") -# set(LIB_TCMALLOC_PROFILER "tcmalloc_and_profiler") -# set(LIB_TCMALLOC_MINIMAL "tcmalloc_and_minimal") -# -# ExternalProject_Add(ADD_${LIB_GPERF} -# URL https://tars-thirdpart-1300910346.cos.ap-guangzhou.myqcloud.com//src/gperftools-2.7.tar.gz -# DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download -# PREFIX ${CMAKE_BINARY_DIR} -# INSTALL_DIR ${CMAKE_SOURCE_DIR} -# CONFIGURE_COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/src/gperf --disable-shared --disable-debugalloc -# SOURCE_DIR ${CMAKE_BINARY_DIR}/src/gperf-lib -# BUILD_IN_SOURCE 1 -# BUILD_COMMAND make -# URL_MD5 c6a852a817e9160c79bdb2d3101b4601 -# ) -# -# add_dependencies(thirdparty ADD_${LIB_GPERF}) -# -# INSTALL(FILES ${CMAKE_BINARY_DIR}/src/gperf/bin/pprof -# PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ -# DESTINATION thirdparty/bin/) -# INSTALL(DIRECTORY ${CMAKE_BINARY_DIR}/src/gperf/lib DESTINATION thirdparty) -# INSTALL(DIRECTORY ${CMAKE_BINARY_DIR}/src/gperf/include/gperftools DESTINATION thirdparty/include) -# -# endif (UNIX) -# -#endif (TARS_GPERF) - if(WIN32) @@ -138,7 +82,7 @@ if (WIN32) CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/gtest -A x64 -Dgtest_force_shared_crt=on -DBUILD_GMOCK=OFF SOURCE_DIR ${CMAKE_BINARY_DIR}/src/gtest-lib BUILD_IN_SOURCE 1 - BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE} + BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE} -- j4 INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE} --target install URL_MD5 82358affdd7ab94854c8ee73a180fc53 ) @@ -182,7 +126,7 @@ if (TARS_PROTOBUF) CONFIGURE_COMMAND ${CMAKE_COMMAND} cmake -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/protobuf -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON SOURCE_DIR ${CMAKE_BINARY_DIR}/src/protobuf-lib BUILD_IN_SOURCE 1 - BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release + BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release -- j4 INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install URL_MD5 fb59398329002c98d4d92238324c4187 ) @@ -195,7 +139,7 @@ if (TARS_PROTOBUF) DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download PREFIX ${CMAKE_BINARY_DIR} INSTALL_DIR ${CMAKE_SOURCE_DIR} - CONFIGURE_COMMAND ${CMAKE_COMMAND} cmake -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/protobuf -DBUILD_SHARED_LIBS=OFF -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + CONFIGURE_COMMAND ${CMAKE_COMMAND} cmake -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/protobuf -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} SOURCE_DIR ${CMAKE_BINARY_DIR}/src/protobuf-lib BUILD_IN_SOURCE 1 BUILD_COMMAND make @@ -243,7 +187,7 @@ if (TARS_SSL) DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download PREFIX ${CMAKE_BINARY_DIR} INSTALL_DIR ${CMAKE_SOURCE_DIR} - CONFIGURE_COMMAND ./config --prefix=${CMAKE_BINARY_DIR}/src/openssl --openssldir=ssl no-shared + CONFIGURE_COMMAND ./config --prefix=${CMAKE_BINARY_DIR}/src/openssl --openssldir=ssl SOURCE_DIR ${CMAKE_BINARY_DIR}/src/openssl-lib BUILD_IN_SOURCE 1 BUILD_COMMAND make @@ -275,7 +219,7 @@ if (TARS_MYSQL) 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 + BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release -- j4 INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install URL_MD5 bad636fe9bcc9bb62e3f5b784495a9b5 ) @@ -288,7 +232,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=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_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 -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 @@ -321,7 +265,7 @@ if (TARS_GZIP) CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/zlib SOURCE_DIR ${CMAKE_BINARY_DIR}/src/zlib-lib BUILD_IN_SOURCE 1 - BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release + BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release -- j4 INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install URL_MD5 1c9f62f0778697a09d36121ead88e08e ) @@ -366,10 +310,10 @@ if (TARS_HTTP2) 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/nghttp2 -DENABLE_LIB_ONLY=ON -DENABLE_STATIC_LIB=ON + CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/nghttp2 -DENABLE_LIB_ONLY=ON SOURCE_DIR ${CMAKE_BINARY_DIR}/src/nghttp2-lib BUILD_IN_SOURCE 1 - BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release + BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release -- j4 INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install URL_MD5 5df375bbd532fcaa7cd4044b54b1188d ) diff --git a/servant/makefile/tars-tools.cmake.in b/servant/makefile/tars-tools.cmake.in index 2d34cf7e..17cdff74 100755 --- a/servant/makefile/tars-tools.cmake.in +++ b/servant/makefile/tars-tools.cmake.in @@ -15,36 +15,67 @@ set(TARS_PATH "@CMAKE_INSTALL_PREFIX@") option(TARS_MYSQL "open mysql support" @TARS_MYSQL@) option(TARS_SSL "open ssl support" @TARS_SSL@) option(TARS_HTTP2 "open http2 support" @TARS_HTTP2@) +option(ENABLE_SHARED "enable tars shared lib" OFF) set(TARS_INC "${TARS_PATH}/include") set(TARS_LIB_DIR "${TARS_PATH}/lib" ) +set(THRIDPARTY_LIB_DIR "${TARS_PATH}/thirdparty/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") -else() - set (LIB_TARS_SERVANT "${TARS_LIB_DIR}/libtarsservant.a") - set (LIB_TARS_UTIL "${TARS_LIB_DIR}/libtarsutil.a") -endif() - include_directories(${TARS_INC}) link_directories(${TARS_LIB_DIR}) include_directories(${TARS_PATH}/thirdparty/include/mysql) -if(WIN32) - set(LIB_SSL "libssl") - set(LIB_CRYPTO "libcrypto") - set(LIB_MYSQL "libmysql") - set(LIB_HTTP2 "nghttp2_static") + +if(ENABLE_SHARED) + if(WIN32) + set (LIB_TARS_SERVANT "${TARS_LIB_DIR}/tarsservant_shared.lib") + set (LIB_TARS_UTIL "${TARS_LIB_DIR}/tarsutil_shared.lib") + elseif(APPLE) + set (LIB_TARS_SERVANT "${TARS_LIB_DIR}/libtarsservant_shared.dylib") + set (LIB_TARS_UTIL "${TARS_LIB_DIR}/libtarsutil_shared.dylib") + else() + set (LIB_TARS_SERVANT "${TARS_LIB_DIR}/libtarsservant_shared.so") + set (LIB_TARS_UTIL "${TARS_LIB_DIR}/libtarsutil_shared.so") + endif() else() - set(LIB_SSL "ssl") - set(LIB_CRYPTO "crypto") - set(LIB_MYSQL "mysqlclient") - set(LIB_HTTP2 "nghttp2_static") -endif () + if(WIN32) + set (LIB_TARS_SERVANT "${TARS_LIB_DIR}/tarsservant.lib") + set (LIB_TARS_UTIL "${TARS_LIB_DIR}/tarsutil.lib") + else() + set (LIB_TARS_SERVANT "${TARS_LIB_DIR}/libtarsservant.a") + set (LIB_TARS_UTIL "${TARS_LIB_DIR}/libtarsutil.a") + endif() +endif() + +if(ENABLE_SHARED) + if(WIN32) + set(LIB_SSL "libssl") + set(LIB_CRYPTO "libcrypto") + set(LIB_MYSQL "libmysql") + set(LIB_HTTP2 "nghttp2") + else() + set(LIB_SSL "ssl") + set(LIB_CRYPTO "crypto") + set(LIB_MYSQL "mysqlclient") + set(LIB_HTTP2 "nghttp2") + endif () +else() + if(WIN32) + set(LIB_SSL "libssl") + set(LIB_CRYPTO "libcrypto") + set(LIB_MYSQL "libmysql") + set(LIB_HTTP2 "nghttp2_static") + else() + set(LIB_SSL "${THRIDPARTY_LIB_DIR}/libssl.a") + set(LIB_CRYPTO "${THRIDPARTY_LIB_DIR}/libcrypto.a") + set(LIB_MYSQL "${THRIDPARTY_LIB_DIR}/libmysqlclient.a") + set(LIB_HTTP2 "${THRIDPARTY_LIB_DIR}/libnghttp2_static.a") + endif () +endif() + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "set build type to release default") IF (CMAKE_BUILD_TYPE STREQUAL "") @@ -98,16 +129,16 @@ ENDIF (UNIX) #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char") -set(TARS_RELEASE "${PROJECT_BINARY_DIR}/run-release.cmake") +set(TARS_RELEASE "${PROJECT_BINARY_DIR}/cmake-run/run-release.cmake") FILE(WRITE ${TARS_RELEASE} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E echo release all)\n") -set(TARS_TAR "${PROJECT_BINARY_DIR}/run-tar.cmake") +set(TARS_TAR "${PROJECT_BINARY_DIR}/cmake-run/run-tar.cmake") FILE(WRITE ${TARS_TAR} "") #################################################################### -set(TARS_UPLOAD "${PROJECT_BINARY_DIR}/run-upload.cmake") -set(TARS_UPLOAD_TARS "${PROJECT_BINARY_DIR}/run-upload-tars.cmake") +set(TARS_UPLOAD "${PROJECT_BINARY_DIR}/cmake-run/run-upload.cmake") +set(TARS_UPLOAD_TARS "${PROJECT_BINARY_DIR}/cmake-run/run-upload-tars.cmake") FILE(WRITE ${TARS_UPLOAD} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E echo upload all)\n") FILE(WRITE ${TARS_UPLOAD_TARS} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E echo upload tars all)\n") @@ -126,8 +157,8 @@ IF (TARS_K8S_BASE_IMAGE STREQUAL "") set(TARS_K8S_BASE_IMAGE "tarscloud/tars.cppbase") ENDIF () -set(TARS_K8S_UPLOAD "${CMAKE_BINARY_DIR}/run-k8s-upload.cmake") -set(TARS_K8S_UPLOAD_TARS "${CMAKE_BINARY_DIR}/run-k8s-upload-tars.cmake") +set(TARS_K8S_UPLOAD "${CMAKE_BINARY_DIR}/cmake-run/run-k8s-upload.cmake") +set(TARS_K8S_UPLOAD_TARS "${CMAKE_BINARY_DIR}/cmake-run/run-k8s-upload-tars.cmake") FILE(WRITE ${TARS_K8S_UPLOAD} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E echo upload k8s all)\n") FILE(WRITE ${TARS_K8S_UPLOAD_TARS} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E echo upload k8s tars all)\n") @@ -183,7 +214,7 @@ macro(gen_lib APP TARGET) endif() #make release ######################################################################### - SET(RUN_RELEASE_COMMAND_FILE "${PROJECT_BINARY_DIR}/run-release-${TARGET}.cmake") + SET(RUN_RELEASE_COMMAND_FILE "${PROJECT_BINARY_DIR}/cmake-run/run-release-${TARGET}.cmake") if (TARS_INPUT) if(WIN32) @@ -273,7 +304,7 @@ macro(gen_server APP TARGET) #make tar ######################################################################### #must create tmp directory, avoid linux cmake conflict! - SET(RUN_TAR_COMMAND_FILE "${CMAKE_BINARY_DIR}/run-tar-${TARGET}.cmake") + SET(RUN_TAR_COMMAND_FILE "${CMAKE_BINARY_DIR}/cmake-run/run-tar-${TARGET}.cmake") FILE(WRITE ${RUN_TAR_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E echo mkdir -p ${CMAKE_BINARY_DIR}/tmp/${TARGET})\n") FILE(APPEND ${RUN_TAR_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E echo rm -rf ${CMAKE_BINARY_DIR}/tmp/${TARGET})\n") FILE(APPEND ${RUN_TAR_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/tmp/${TARGET})\n") @@ -313,7 +344,7 @@ macro(gen_server APP TARGET) FILE(APPEND ${TARS_TAR} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -P ${RUN_TAR_COMMAND_FILE})\n") #make upload ######################################################################### - SET(RUN_UPLOAD_COMMAND_FILE "${PROJECT_BINARY_DIR}/run-upload-${TARGET}.cmake") + SET(RUN_UPLOAD_COMMAND_FILE "${PROJECT_BINARY_DIR}/cmake-run/run-upload-${TARGET}.cmake") IF(WIN32) FILE(WRITE ${RUN_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E echo ${TARS_WEB_HOST}/api/upload_and_publish -Fsuse=@${TARGET}.tgz -Fapplication=${APP} -Fmodule_name=${TARGET} -Fcomment=developer-auto-upload)\n") FILE(APPEND ${RUN_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND ${TARS_PATH}/thirdparty/bin/curl.exe ${TARS_WEB_HOST}/api/upload_and_publish?ticket=${TARS_TOKEN} -Fsuse=@${TARGET}.tgz -Fapplication=${APP} -Fmodule_name=${TARGET} -Fcomment=developer-auto-upload)\n") @@ -336,7 +367,7 @@ macro(gen_server APP TARGET) #make upload-tars ######################################################################### if (TARS_INPUT) - SET(RUN_UPLOAD_TARS_COMMAND_FILE "${PROJECT_BINARY_DIR}/run-upload-tars-${TARGET}.cmake") + SET(RUN_UPLOAD_TARS_COMMAND_FILE "${PROJECT_BINARY_DIR}/cmake-run/run-upload-tars-${TARGET}.cmake") IF(WIN32) FILE(WRITE ${RUN_UPLOAD_TARS_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E echo ${TARS_WEB_HOST}/api/upload_tars_file -Fsuse=@${TARGET}-merge.tars -Fapplication=${APP} -Fserver_name=${TARGET})\n") @@ -366,7 +397,7 @@ macro(gen_server APP TARGET) #make k8s upload ######################################################################### - SET(RUN_K8S_UPLOAD_COMMAND_FILE "${CMAKE_BINARY_DIR}/run-k8s-upload-${TARGET}.cmake") + SET(RUN_K8S_UPLOAD_COMMAND_FILE "${CMAKE_BINARY_DIR}/cmake-run/run-k8s-upload-${TARGET}.cmake") FILE(WRITE ${RUN_K8S_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E echo ${TARS_K8S_WEB_HOST}/pages/k8s/api/upload_and_publish -Fsuse=@${TARGET}.tgz -Fapplication=${APP} -Fmodule_name=${TARGET} -Fserver_type=cpp -Fbase_image=${TARS_K8S_BASE_IMAGE} -Fcomment=developer-auto-upload)\n") FILE(APPEND ${RUN_K8S_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND curl ${TARS_K8S_WEB_HOST}/pages/k8s/api/upload_and_publish?ticket=${TARS_K8S_TOKEN} -Fsuse=@${TARGET}.tgz -Fapplication=${APP} -Fmodule_name=${TARGET} -Fserver_type=cpp -Fbase_image=${TARS_K8S_BASE_IMAGE} -Fcomment=developer-auto-upload)\n") FILE(APPEND ${RUN_K8S_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E echo \n---------------------------------------------------------------------------)\n") @@ -399,7 +430,7 @@ macro(gen_server APP TARGET) endif () #make release ######################################################################### - SET(RUN_RELEASE_COMMAND_FILE "${PROJECT_BINARY_DIR}/run-release-${TARGET}.cmake") + SET(RUN_RELEASE_COMMAND_FILE "${PROJECT_BINARY_DIR}/cmake-run/run-release-${TARGET}.cmake") if (TARS_INPUT) if(WIN32) @@ -488,6 +519,7 @@ message("CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") message("PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}") message("CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") message("PLATFORM: ${PLATFORM}") +message("ENABLE_SHARED: ${ENABLE_SHARED}") message("TARS2CPP: ${TARS2CPP}") message("TARSMERGE: ${TARSMERGE}") message("TARS_MYSQL: ${TARS_MYSQL}") @@ -498,5 +530,16 @@ message("TARS_TOKEN: ${TARS_TOKEN}") message("TARS_K8S_WEB_HOST: ${TARS_K8S_WEB_HOST}") message("TARS_K8S_BASE_IMAGE: ${TARS_K8S_BASE_IMAGE}") message("TARS_K8S_TOKEN: ${TARS_K8S_TOKEN}") +if(TARS_MYSQL) +message("LIB_MYSQL: ${LIB_MYSQL}") +endif() +if(TARS_SSL) +message("LIB_SSL: ${LIB_SSL}") +message("LIB_CRYPTO: ${LIB_CRYPTO}") +endif() +if(TARS_HTTP2) +message("LIB_HTTP2: ${LIB_HTTP2}") +endif() + message("-------------------------------------------------------------------------------------") diff --git a/tools/pb2tarscpp/CMakeLists.txt b/tools/pb2tarscpp/CMakeLists.txt index 05876c39..a8c8b120 100644 --- a/tools/pb2tarscpp/CMakeLists.txt +++ b/tools/pb2tarscpp/CMakeLists.txt @@ -10,6 +10,7 @@ aux_source_directory(. DIR_SRCS) add_executable(pb2tarscpp ${DIR_SRCS}) +add_dependencies(pb2tarscpp thirdparty) target_link_libraries(pb2tarscpp ${LIB_PROTOBUF} ${LIB_PROTOC}) diff --git a/util/src/CMakeLists.txt b/util/src/CMakeLists.txt index 4107c377..9e52e9e6 100644 --- a/util/src/CMakeLists.txt +++ b/util/src/CMakeLists.txt @@ -42,8 +42,14 @@ if(ENABLE_SHARED) if (WIN32) #windows动态编译需添加依赖库 target_link_libraries(tarsutil_shared ${LIB_SSL}.lib ${LIB_CRYPTO}.lib Crypt32) + else() + target_link_libraries(tarsutil_shared ${LIB_SSL} ${LIB_CRYPTO}) endif () endif() + + if(TARS_HTTP2) + target_link_libraries(tarsutil_shared nghttp2) + endif() add_dependencies(tarsutil_shared thirdparty) install(TARGETS tarsutil_shared From 936f499fcf30af442c4e3f9aaf9c8ba7579421ab Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Fri, 25 Oct 2024 11:20:46 +0800 Subject: [PATCH 42/44] tars-tools.cmake add lib show --- cmake/Thirdparty.cmake | 14 ++++----- servant/makefile/tars-tools.cmake.in | 31 ++++++++++++++----- servant/script/cmake_demo/CMakeLists.txt | 2 +- servant/script/cmake_http_demo/CMakeLists.txt | 2 +- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/cmake/Thirdparty.cmake b/cmake/Thirdparty.cmake index 9c76f866..97c7bced 100755 --- a/cmake/Thirdparty.cmake +++ b/cmake/Thirdparty.cmake @@ -57,7 +57,7 @@ if(WIN32) CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/curl SOURCE_DIR ${CMAKE_BINARY_DIR}/src/curl-lib BUILD_IN_SOURCE 1 - BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release + BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release -- j4 INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install URL_MD5 b9bb5e11d579425154a9f97ed44be9b8 ) @@ -97,7 +97,7 @@ else() CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/gtest -DBUILD_GMOCK=OFF -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} SOURCE_DIR ${CMAKE_BINARY_DIR}/src/gtest-lib BUILD_IN_SOURCE 1 - BUILD_COMMAND make + BUILD_COMMAND make -j4 URL_MD5 6f26d634fa9cac718263c2df20df21a4 ) endif() @@ -142,7 +142,7 @@ if (TARS_PROTOBUF) CONFIGURE_COMMAND ${CMAKE_COMMAND} cmake -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/protobuf -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} SOURCE_DIR ${CMAKE_BINARY_DIR}/src/protobuf-lib BUILD_IN_SOURCE 1 - BUILD_COMMAND make + BUILD_COMMAND make -j4 URL_MD5 fb59398329002c98d4d92238324c4187 ) @@ -191,7 +191,7 @@ if (TARS_SSL) SOURCE_DIR ${CMAKE_BINARY_DIR}/src/openssl-lib BUILD_IN_SOURCE 1 BUILD_COMMAND make - INSTALL_COMMAND make install_sw + INSTALL_COMMAND make install_sw -j4 URL_MD5 ac0d4387f3ba0ad741b0580dd45f6ff3 ) @@ -235,7 +235,7 @@ if (TARS_MYSQL) CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/mysql -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -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 + BUILD_COMMAND make mysqlclient -j4 URL_MD5 3578d736b9d493eae076a67e3ed473eb ) @@ -281,7 +281,7 @@ if (TARS_GZIP) CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/zlib -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} SOURCE_DIR ${CMAKE_BINARY_DIR}/src/zlib-lib BUILD_IN_SOURCE 1 - BUILD_COMMAND make + BUILD_COMMAND make -j4 URL_MD5 1c9f62f0778697a09d36121ead88e08e ) @@ -327,7 +327,7 @@ if (TARS_HTTP2) CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/nghttp2 -DENABLE_LIB_ONLY=ON -DENABLE_STATIC_LIB=ON -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} SOURCE_DIR ${CMAKE_BINARY_DIR}/src/nghttp2-lib BUILD_IN_SOURCE 1 - BUILD_COMMAND make + BUILD_COMMAND make -j4 URL_MD5 5df375bbd532fcaa7cd4044b54b1188d ) diff --git a/servant/makefile/tars-tools.cmake.in b/servant/makefile/tars-tools.cmake.in index 17cdff74..0d8831b8 100755 --- a/servant/makefile/tars-tools.cmake.in +++ b/servant/makefile/tars-tools.cmake.in @@ -15,6 +15,7 @@ set(TARS_PATH "@CMAKE_INSTALL_PREFIX@") option(TARS_MYSQL "open mysql support" @TARS_MYSQL@) option(TARS_SSL "open ssl support" @TARS_SSL@) option(TARS_HTTP2 "open http2 support" @TARS_HTTP2@) +option(TARS_GZIP "open gzip support" @TARS_GZIP@) option(ENABLE_SHARED "enable tars shared lib" OFF) set(TARS_INC "${TARS_PATH}/include") @@ -26,8 +27,9 @@ list(APPEND TARS_TOOL_FLAG "") include_directories(${TARS_INC}) link_directories(${TARS_LIB_DIR}) -include_directories(${TARS_PATH}/thirdparty/include/mysql) +link_directories(${THRIDPARTY_LIB_DIR}) +include_directories(${TARS_PATH}/thirdparty/include/mysql) if(ENABLE_SHARED) if(WIN32) @@ -56,11 +58,13 @@ if(ENABLE_SHARED) set(LIB_CRYPTO "libcrypto") set(LIB_MYSQL "libmysql") set(LIB_HTTP2 "nghttp2") + set(LIB_GZIP "libz") else() set(LIB_SSL "ssl") set(LIB_CRYPTO "crypto") set(LIB_MYSQL "mysqlclient") set(LIB_HTTP2 "nghttp2") + set(LIB_GZIP "z") endif () else() if(WIN32) @@ -68,11 +72,13 @@ else() set(LIB_CRYPTO "libcrypto") set(LIB_MYSQL "libmysql") set(LIB_HTTP2 "nghttp2_static") + set(LIB_GZIP "z") else() set(LIB_SSL "${THRIDPARTY_LIB_DIR}/libssl.a") set(LIB_CRYPTO "${THRIDPARTY_LIB_DIR}/libcrypto.a") set(LIB_MYSQL "${THRIDPARTY_LIB_DIR}/libmysqlclient.a") set(LIB_HTTP2 "${THRIDPARTY_LIB_DIR}/libnghttp2_static.a") + set(LIB_GZIP "${THRIDPARTY_LIB_DIR}/libz.a") endif () endif() @@ -294,6 +300,10 @@ macro(gen_server APP TARGET) target_link_libraries(${TARGET} ${LIB_HTTP2}) endif() + if(TARS_GZIP) + target_link_libraries(${TARGET} ${LIB_GZIP}) + endif() + if(APPLE) target_link_libraries(${TARGET} iconv) endif() @@ -520,16 +530,15 @@ message("PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}") message("CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") message("PLATFORM: ${PLATFORM}") message("ENABLE_SHARED: ${ENABLE_SHARED}") +message("TARS_INC: ${TARS_INC}") +message("TARS_LIB_DIR: ${TARS_LIB_DIR}") message("TARS2CPP: ${TARS2CPP}") message("TARSMERGE: ${TARSMERGE}") message("TARS_MYSQL: ${TARS_MYSQL}") message("TARS_HTTP2: ${TARS_HTTP2}") message("TARS_SSL: ${TARS_SSL}") -message("TARS_WEB_HOST: ${TARS_WEB_HOST}") -message("TARS_TOKEN: ${TARS_TOKEN}") -message("TARS_K8S_WEB_HOST: ${TARS_K8S_WEB_HOST}") -message("TARS_K8S_BASE_IMAGE: ${TARS_K8S_BASE_IMAGE}") -message("TARS_K8S_TOKEN: ${TARS_K8S_TOKEN}") +message("TARS_GZIP: ${TARS_GZIP}") +message("THRIDPARTY_LIB_DIR: ${THRIDPARTY_LIB_DIR}") if(TARS_MYSQL) message("LIB_MYSQL: ${LIB_MYSQL}") endif() @@ -540,6 +549,14 @@ endif() if(TARS_HTTP2) message("LIB_HTTP2: ${LIB_HTTP2}") endif() - +if(TARS_GZIP) +message("LIB_GZIP: ${LIB_GZIP}") +endif() +message("-------------------------------------------------------------------------------------") +message("TARS_WEB_HOST: ${TARS_WEB_HOST}") +message("TARS_TOKEN: ${TARS_TOKEN}") +message("TARS_K8S_WEB_HOST: ${TARS_K8S_WEB_HOST}") +message("TARS_K8S_BASE_IMAGE: ${TARS_K8S_BASE_IMAGE}") +message("TARS_K8S_TOKEN: ${TARS_K8S_TOKEN}") message("-------------------------------------------------------------------------------------") diff --git a/servant/script/cmake_demo/CMakeLists.txt b/servant/script/cmake_demo/CMakeLists.txt index 38c1c11a..50ff21e7 100644 --- a/servant/script/cmake_demo/CMakeLists.txt +++ b/servant/script/cmake_demo/CMakeLists.txt @@ -19,7 +19,7 @@ IF (TARS_WEB_HOST STREQUAL "") ENDIF () include_directories(/usr/local/tars/cpp/thirdparty/include) -link_directories(/usr/local/tars/cpp/thirdparty/lib) +# link_directories(/usr/local/tars/cpp/thirdparty/lib) #include_directories(/home/tarsprotol/App/OtherServer) diff --git a/servant/script/cmake_http_demo/CMakeLists.txt b/servant/script/cmake_http_demo/CMakeLists.txt index 38c1c11a..50ff21e7 100644 --- a/servant/script/cmake_http_demo/CMakeLists.txt +++ b/servant/script/cmake_http_demo/CMakeLists.txt @@ -19,7 +19,7 @@ IF (TARS_WEB_HOST STREQUAL "") ENDIF () include_directories(/usr/local/tars/cpp/thirdparty/include) -link_directories(/usr/local/tars/cpp/thirdparty/lib) +# link_directories(/usr/local/tars/cpp/thirdparty/lib) #include_directories(/home/tarsprotol/App/OtherServer) From b4c09dcc6eeef4d03646ccd92fade1f2f7cd4e5d Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Fri, 25 Oct 2024 11:41:08 +0800 Subject: [PATCH 43/44] fix thirdparty windows maccpucount:4 --- cmake/Thirdparty.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cmake/Thirdparty.cmake b/cmake/Thirdparty.cmake index 97c7bced..366056ae 100755 --- a/cmake/Thirdparty.cmake +++ b/cmake/Thirdparty.cmake @@ -57,7 +57,7 @@ if(WIN32) CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/curl SOURCE_DIR ${CMAKE_BINARY_DIR}/src/curl-lib BUILD_IN_SOURCE 1 - BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release -- j4 + BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release -- /maxcpucount:4 INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install URL_MD5 b9bb5e11d579425154a9f97ed44be9b8 ) @@ -82,7 +82,7 @@ if (WIN32) CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/gtest -A x64 -Dgtest_force_shared_crt=on -DBUILD_GMOCK=OFF SOURCE_DIR ${CMAKE_BINARY_DIR}/src/gtest-lib BUILD_IN_SOURCE 1 - BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE} -- j4 + BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE} -- /maxcpucount:4 INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE} --target install URL_MD5 82358affdd7ab94854c8ee73a180fc53 ) @@ -126,7 +126,7 @@ if (TARS_PROTOBUF) CONFIGURE_COMMAND ${CMAKE_COMMAND} cmake -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/protobuf -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON SOURCE_DIR ${CMAKE_BINARY_DIR}/src/protobuf-lib BUILD_IN_SOURCE 1 - BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release -- j4 + BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release -- /maxcpucount:4 INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install URL_MD5 fb59398329002c98d4d92238324c4187 ) @@ -219,7 +219,7 @@ if (TARS_MYSQL) 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 -- j4 + BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release -- /maxcpucount:4 INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install URL_MD5 bad636fe9bcc9bb62e3f5b784495a9b5 ) @@ -265,7 +265,7 @@ if (TARS_GZIP) CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/zlib SOURCE_DIR ${CMAKE_BINARY_DIR}/src/zlib-lib BUILD_IN_SOURCE 1 - BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release -- j4 + BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release -- /maxcpucount:4 INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install URL_MD5 1c9f62f0778697a09d36121ead88e08e ) @@ -313,7 +313,7 @@ if (TARS_HTTP2) CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/nghttp2 -DENABLE_LIB_ONLY=ON SOURCE_DIR ${CMAKE_BINARY_DIR}/src/nghttp2-lib BUILD_IN_SOURCE 1 - BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release -- j4 + BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release -- /maxcpucount:4 INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install URL_MD5 5df375bbd532fcaa7cd4044b54b1188d ) From 26d99a8df6fbc6b53b35e4d8800e064bdfc4deff Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Sun, 27 Oct 2024 21:17:47 +0800 Subject: [PATCH 44/44] fix windows enableshard and ssl compiler error --- cmake/BuildTarsCpp.cmake | 4 ---- cmake/Thirdparty.cmake | 8 ++++++-- mock/CMakeLists.txt | 20 ++++++++++---------- mock/DbHandle.cpp | 8 ++++---- mock/DbHandle.h | 18 +++++++++--------- servant/CMakeLists.txt | 11 ++++++++++- tools/CMakeLists.txt | 3 +++ util/src/CMakeLists.txt | 5 ++++- 8 files changed, 46 insertions(+), 31 deletions(-) diff --git a/cmake/BuildTarsCpp.cmake b/cmake/BuildTarsCpp.cmake index b12af256..d58bc22b 100755 --- a/cmake/BuildTarsCpp.cmake +++ b/cmake/BuildTarsCpp.cmake @@ -98,10 +98,6 @@ macro(build_tars_server MODULE DEPS) target_link_libraries(${MODULE} ${LIB_HTTP2} ${LIB_PROTOBUF}) endif() -# if(TARS_GPERF) -# target_link_libraries(${MODULE} ${LIB_GPERF}) -# endif(TARS_GPERF) - SET(MODULE-TGZ "${CMAKE_BINARY_DIR}/${MODULE}.tgz") SET(RUN_DEPLOY_COMMAND_FILE "${PROJECT_BINARY_DIR}/run-deploy-${MODULE}.cmake") FILE(WRITE ${RUN_DEPLOY_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/deploy/${MODULE})\n") diff --git a/cmake/Thirdparty.cmake b/cmake/Thirdparty.cmake index 366056ae..8d2cce95 100755 --- a/cmake/Thirdparty.cmake +++ b/cmake/Thirdparty.cmake @@ -255,7 +255,7 @@ if (TARS_GZIP) link_directories(${GZIP_DIR_LIB}) if (WIN32) - set(LIB_GZIP "libz") + set(LIB_GZIP "zlib") ExternalProject_Add(ADD_${LIB_GZIP} URL http://cdn.tarsyun.com/src/zlib-1.2.11.tar.gz @@ -302,7 +302,11 @@ if (TARS_HTTP2) link_directories(${NGHTTP2_DIR_LIB}) link_directories(${NGHTTP2_DIR_LIB64}) - set(LIB_HTTP2 "nghttp2_static") + if(ENABLE_SHARED) + set(LIB_HTTP2 "nghttp2") + else() + set(LIB_HTTP2 "nghttp2_static") + endif() if (WIN32) ExternalProject_Add(ADD_${LIB_HTTP2} diff --git a/mock/CMakeLists.txt b/mock/CMakeLists.txt index b1627906..f200f5a7 100755 --- a/mock/CMakeLists.txt +++ b/mock/CMakeLists.txt @@ -9,16 +9,16 @@ install(DIRECTORY . DESTINATION include/mock FILES_MATCHING PATTERN "*.h") install(TARGETS tarsmock RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) -if(ENABLE_SHARED) - add_library(tarsmock_shared SHARED ${SRC_FILES}) - target_compile_definitions(tarsmock_shared PRIVATE SVT_USE_DLL UTIL_USE_DLL) - target_link_libraries(tarsmock_shared tarsservant_shared tarsutil_shared) - add_dependencies(tarsmock_shared tarsservant_shared) +# if(ENABLE_SHARED) +# add_library(tarsmock_shared SHARED ${SRC_FILES}) +# target_compile_definitions(tarsmock_shared PRIVATE SVT_USE_DLL UTIL_USE_DLL) +# target_link_libraries(tarsmock_shared tarsservant_shared tarsutil_shared) +# add_dependencies(tarsmock_shared tarsservant_shared) - install(TARGETS tarsmock_shared RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) +# install(TARGETS tarsmock_shared RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) - if (WIN32) - install(FILES $ DESTINATION bin) - endif() +# if (WIN32) +# install(FILES $ DESTINATION bin) +# endif() -endif() +# endif() diff --git a/mock/DbHandle.cpp b/mock/DbHandle.cpp index b2efef07..a8ac1661 100755 --- a/mock/DbHandle.cpp +++ b/mock/DbHandle.cpp @@ -8,12 +8,12 @@ static ObjectsCache _objectsCache; -CDbHandle::SetDivisionCache CDbHandle::_setDivisionCache; -std::map CDbHandle::_mapGroupPriority; -std::mutex CDbHandle::_mutex; +static CDbHandle::SetDivisionCache _setDivisionCache; +static std::map _mapGroupPriority; +static std::mutex _mutex; //key-ip, value-组编号 -map CDbHandle::_groupIdMap; +map _groupIdMap; //key-group_name, value-组编号 //map CDbHandle::_groupNameMap; diff --git a/mock/DbHandle.h b/mock/DbHandle.h index dfa97b07..6c315c94 100755 --- a/mock/DbHandle.h +++ b/mock/DbHandle.h @@ -26,7 +26,7 @@ typedef map ObjectsCache; */ class UTIL_DLL_API CDbHandle { -private: +public: struct GroupPriorityEntry { std::string sGroupID; @@ -199,14 +199,14 @@ class UTIL_DLL_API CDbHandle vector getEpsByGroupId(const vector & vecEps, const GroupUseSelect GroupSelect, const set & setGroupID, ostringstream & os); -protected: +// protected: - static std::mutex _mutex; - //set划分缓存 - static SetDivisionCache _setDivisionCache; - //优先级的序列 - static std::map _mapGroupPriority; - //分组信息 - static map _groupIdMap; +// UTIL_DLL_API static std::mutex _mutex; +// //set划分缓存 +// UTIL_DLL_API static SetDivisionCache _setDivisionCache; +// //优先级的序列 +// UTIL_DLL_API static std::map _mapGroupPriority; +// //分组信息 +// UTIL_DLL_API static map _groupIdMap; }; diff --git a/servant/CMakeLists.txt b/servant/CMakeLists.txt index eec543f4..1b629ec6 100644 --- a/servant/CMakeLists.txt +++ b/servant/CMakeLists.txt @@ -37,13 +37,22 @@ macro(complice_tars OUT_DEPENDS_LIST HEADER INCLUDE) set(TARS_IN ${FILE}) set(TARS_H ${NAME_WE}.h) + if(ENABLE_SHARED AND TARS_SSL) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${TARS_H} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS tars2cpp ${FILE} + COMMAND ${CMAKE_COMMAND} -E env PATH=${CMAKE_BINARY_DIR}/src/openssl/bin/ ${TARS2CPP} --with-tars ${HEADER_STRING} ${INCLUDE_STRING} ${TARS_IN} + COMMENT "${TARS2CPP} --with-tars ${HEADER_STRING} ${INCLUDE_STRING} ${TARS_IN}") + else() add_custom_command( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${TARS_H} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS tars2cpp ${FILE} COMMAND ${TARS2CPP} --with-tars ${HEADER_STRING} ${INCLUDE_STRING} ${TARS_IN} COMMENT "${TARS2CPP} --with-tars ${HEADER_STRING} ${INCLUDE_STRING} ${TARS_IN}") - + endif() + list(APPEND DEPENDS_LIST ${CMAKE_CURRENT_SOURCE_DIR}/${TARS_H}) #设置需要清除的文件 diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 9bfb929a..b07e6e7e 100755 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -19,6 +19,9 @@ function(tars2language TARGET) target_link_libraries(${TARGET} tarsutil tarsparse) + if(TARS_SSL AND ENABLE_SHARED) + target_link_libraries(${TARGET} ${LIB_SSL} ${LIB_CRYPTO}) + endif() install(TARGETS ${TARGET} RUNTIME DESTINATION tools) endfunction() diff --git a/util/src/CMakeLists.txt b/util/src/CMakeLists.txt index 9e52e9e6..f6cc731e 100644 --- a/util/src/CMakeLists.txt +++ b/util/src/CMakeLists.txt @@ -48,8 +48,11 @@ if(ENABLE_SHARED) endif() if(TARS_HTTP2) - target_link_libraries(tarsutil_shared nghttp2) + target_link_libraries(tarsutil_shared nghttp2) endif() + if(TARS_GZIP) + target_link_libraries(tarsutil_shared ${LIB_GZIP}) + endif() add_dependencies(tarsutil_shared thirdparty) install(TARGETS tarsutil_shared