diff --git a/uft_dev_server/src/controllers/HelloHandler_v1.cpp b/uft_dev_server/src/controllers/HelloHandler_v1.cpp deleted file mode 100644 index 4c34f91..0000000 --- a/uft_dev_server/src/controllers/HelloHandler_v1.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// HelloHandler_v1.cpp -#include "HelloHandler_v1.h" - -std::string HelloHandler_v1::GetResponse() -{ - return "Hello, 这是热更新后的版本!"; -} - -REGISTERCLASS(HelloHandler_v1) \ No newline at end of file diff --git a/uft_dev_server/src/controllers/HelloHandler_v1.h b/uft_dev_server/src/controllers/HelloHandler_v1.h deleted file mode 100644 index 27e83e7..0000000 --- a/uft_dev_server/src/controllers/HelloHandler_v1.h +++ /dev/null @@ -1,21 +0,0 @@ -// HelloHandler_v1.cpp -#include "HelloWorldController.h" -#include "RuntimeObjectSystem/ObjectInterfacePerModule.h" -#include "StdioLogSystem.h" - -// 接口定义 -enum CustomInterfaceIDs -{ - IID_HELLO_HANDLER = IID_ENDInterfaceID + 1 -}; - -struct IHelloHandler : public IObject -{ - virtual std::string GetResponse() = 0; -}; - -class HelloHandler_v1 : public TInterface -{ -public: - std::string GetResponse() override; -}; diff --git a/uft_dev_server/src/controllers/HelloWorldController.cpp b/uft_dev_server/src/controllers/HelloWorldController.cpp index 2f5af19..5c5a322 100644 --- a/uft_dev_server/src/controllers/HelloWorldController.cpp +++ b/uft_dev_server/src/controllers/HelloWorldController.cpp @@ -1,58 +1,12 @@ #include "HelloWorldController.h" -#include "RuntimeObjectSystem/ObjectInterfacePerModule.h" -#include "StdioLogSystem.h" -#include "HelloHandler_v1.h" -// 构造函数实现 -HelloWorldController::HelloWorldController() - : m_pRuntimeSystem(nullptr), - m_pCompilerLogger(nullptr) -{ -} - -// 析构函数实现 -HelloWorldController::~HelloWorldController() -{ - delete m_pRuntimeSystem; - delete m_pCompilerLogger; -} +using namespace drogon; void HelloWorldController::asyncHandleHttpRequest( - const drogon::HttpRequestPtr &req, - std::function &&callback) + const HttpRequestPtr &req, + std::function &&callback) { - // 初始化检查 - if (!m_pRuntimeSystem) - { - m_pRuntimeSystem = new RuntimeObjectSystem; - m_pCompilerLogger = new StdioLogSystem(); - - if (!m_pRuntimeSystem->Initialise(m_pCompilerLogger, nullptr)) - { - auto resp = drogon::HttpResponse::newHttpResponse(); - resp->setBody("RCCPP Initialization failed"); - callback(resp); - return; - } - } - - // 获取构造器 - IObjectConstructor *pCtor = m_pRuntimeSystem->GetObjectFactorySystem()->GetConstructor("HelloHandler_v1"); - if (pCtor) - { - IObject *pObj = pCtor->Construct(); - m_ObjectId = pObj->GetObjectId(); - } - - // 获取处理器 - IHelloHandler *pHandler = nullptr; - if (IObject *pObj = m_pRuntimeSystem->GetObjectFactorySystem()->GetObject(m_ObjectId)) - { - pObj->GetInterface(&pHandler); - } - - // 生成响应 - auto resp = drogon::HttpResponse::newHttpResponse(); - resp->setBody(pHandler ? pHandler->GetResponse() : "Handler not available"); + auto resp = HttpResponse::newHttpResponse(); + resp->setBody("Hello, World!"); callback(resp); } \ No newline at end of file diff --git a/uft_dev_server/src/controllers/HelloWorldController.h b/uft_dev_server/src/controllers/HelloWorldController.h index 576df7e..7a88b3d 100644 --- a/uft_dev_server/src/controllers/HelloWorldController.h +++ b/uft_dev_server/src/controllers/HelloWorldController.h @@ -1,31 +1,15 @@ -#pragma once +#pragma once #include -#include "RuntimeObjectSystem/RuntimeObjectSystem.h" -#include "RuntimeObjectSystem/IObject.h" -#include "RuntimeObjectSystem/IObjectFactorySystem.h" // 新增 -// 前向声明 -struct IRuntimeObjectSystem; -struct IObject; -struct IObjectFactorySystem; // 新增 -struct ICompilerLogger; // 新增 +using namespace drogon; -class HelloWorldController : public drogon::HttpSimpleController +class HelloWorldController : public HttpSimpleController { public: - HelloWorldController(); // 显式声明构造函数 - ~HelloWorldController(); // 显式声明析构函数 - - virtual void asyncHandleHttpRequest( - const drogon::HttpRequestPtr &req, - std::function &&callback) override; - PATH_LIST_BEGIN - PATH_ADD("/hello", drogon::Get); + PATH_ADD("/hello", Get); PATH_LIST_END -private: - IRuntimeObjectSystem *m_pRuntimeSystem = nullptr; - ICompilerLogger *m_pCompilerLogger = nullptr; - ObjectId m_ObjectId; + void asyncHandleHttpRequest(const HttpRequestPtr &req, + std::function &&callback) override; }; \ No newline at end of file diff --git a/uft_dev_server/src/controllers/StdioLogSystem.cpp b/uft_dev_server/src/controllers/StdioLogSystem.cpp deleted file mode 100644 index 4e49883..0000000 --- a/uft_dev_server/src/controllers/StdioLogSystem.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// -// Copyright (c) 2010-2011 Matthew Jack and Doug Binks -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// 3. This notice may not be removed or altered from any source distribution. - -#include "StdioLogSystem.h" - -// Currently we create the file on first real output, and only close it on shutdown - -#include -#include -#include - -#ifdef _WIN32 -#include "RuntimeCompiler/FileSystemUtils.h" -#include "Windows.h" -#pragma warning(disable : 4996 4800) -#endif - -void StdioLogSystem::LogError(const char *format, ...) -{ - va_list args; - va_start(args, format); - LogInternal(format, args); -} - -void StdioLogSystem::LogWarning(const char *format, ...) -{ - va_list args; - va_start(args, format); - LogInternal(format, args); -} - -void StdioLogSystem::LogInfo(const char *format, ...) -{ - va_list args; - va_start(args, format); - LogInternal(format, args); -} -void StdioLogSystem::LogInternal(const char *format, va_list args) -{ - int result = vsnprintf(m_buff, LOGSYSTEM_MAX_BUFFER - 1, format, args); - // Make sure there's a limit to the amount of rubbish we can output - m_buff[LOGSYSTEM_MAX_BUFFER - 1] = '\0'; - - std::cout << m_buff; -#ifdef _WIN32 - std::string temp = m_buff; - // convert from utf-8 to Wide char - std::wstring tempW = FileSystemUtils::_Win32Utf8ToUtf16(temp); - OutputDebugStringW(tempW.c_str()); -#endif -} diff --git a/uft_dev_server/src/controllers/StdioLogSystem.h b/uft_dev_server/src/controllers/StdioLogSystem.h deleted file mode 100644 index d50731d..0000000 --- a/uft_dev_server/src/controllers/StdioLogSystem.h +++ /dev/null @@ -1,44 +0,0 @@ -// -// Copyright (c) 2010-2011 Matthew Jack and Doug Binks -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// 3. This notice may not be removed or altered from any source distribution. - -#pragma once - -#ifndef STDIOLOGSYSTEM_INCLUDED -#define STDIOLOGSYSTEM_INCLUDED - -#include "RuntimeCompiler/ICompilerLogger.h" - -#include -#include - -// StdioLogSystem for compiler - -const size_t LOGSYSTEM_MAX_BUFFER = 4096; - -class StdioLogSystem : public ICompilerLogger -{ -public: - virtual void LogError(const char *format, ...); - virtual void LogWarning(const char *format, ...); - virtual void LogInfo(const char *format, ...); - -protected: - void LogInternal(const char *format, va_list args); - char m_buff[LOGSYSTEM_MAX_BUFFER]; -}; - -#endif // STDIOLOGSYSTEM_INCLUDED \ No newline at end of file