Initial commit

This commit is contained in:
dev
2025-02-27 21:53:53 +08:00
commit 815e55e4c0
1291 changed files with 185445 additions and 0 deletions

39
src/fbs/macros/IStub.h Normal file
View File

@@ -0,0 +1,39 @@
#include "common/utils/Coroutine.h"
#ifdef DEFINE_FBS_SERVICE
#undef DEFINE_FBS_SERVICE
#endif
#define DEFINE_FBS_SERVICE(name, fbsns) \
class I##name##ServiceStub { \
public: \
using InterfaceType = I##name##ServiceStub; \
\
virtual ~I##name##ServiceStub() = default;
#ifdef FINISH_FBS_SERVICE
#undef FINISH_FBS_SERVICE
#endif
#define FINISH_FBS_SERVICE(name, fbsns) }
#ifdef DEFINE_FBS_SERVICE_METHOD
#undef DEFINE_FBS_SERVICE_METHOD
#endif
#define DEFINE_FBS_SERVICE_METHOD(svc, name, reqtype, rsptype, flatns) \
virtual CoTryTask<flatns::rsptype> name(const flatns::reqtype &req) = 0
#ifdef DEFINE_FBS_SERVICE_METHOD_VOID
#undef DEFINE_FBS_SERVICE_METHOD_VOID
#endif
#define DEFINE_FBS_SERVICE_METHOD_VOID(svc, name, reqtype, rsptype, flatns) \
DEFINE_FBS_SERVICE_METHOD(svc, name, reqtype, rsptype, flatns)
#ifdef DEFINE_FBS_SERVICE_METHOD_RETURNS
#undef DEFINE_FBS_SERVICE_METHOD_RETURNS
#endif
#define DEFINE_FBS_SERVICE_METHOD_RETURNS(svc, name, reqtype, rsptype, flatns, returns, rtype) \
DEFINE_FBS_SERVICE_METHOD(svc, name, reqtype, rsptype, flatns)

View File

@@ -0,0 +1,39 @@
#include "common/utils/Result.h"
#ifdef DEFINE_FBS_SERVICE
#undef DEFINE_FBS_SERVICE
#endif
#define DEFINE_FBS_SERVICE(name, fbsns) \
class I##name##ServiceStub { \
public: \
using InterfaceType = I##name##ServiceStub; \
\
virtual ~I##name##ServiceStub() = default;
#ifdef FINISH_FBS_SERVICE
#undef FINISH_FBS_SERVICE
#endif
#define FINISH_FBS_SERVICE(name, fbsns) }
#ifdef DEFINE_FBS_SERVICE_METHOD
#undef DEFINE_FBS_SERVICE_METHOD
#endif
#define DEFINE_FBS_SERVICE_METHOD(svc, name, reqtype, rsptype, flatns) \
virtual hf3fs::Result<flatns::rsptype> name(const flatns::reqtype &req) = 0
#ifdef DEFINE_FBS_SERVICE_METHOD_VOID
#undef DEFINE_FBS_SERVICE_METHOD_VOID
#endif
#define DEFINE_FBS_SERVICE_METHOD_VOID(svc, name, reqtype, rsptype, flatns) \
virtual hf3fs::Result<Void> name(const flatns::reqtype &req) = 0
#ifdef DEFINE_FBS_SERVICE_METHOD_RETURNS
#undef DEFINE_FBS_SERVICE_METHOD_RETURNS
#endif
#define DEFINE_FBS_SERVICE_METHOD_RETURNS(svc, name, reqtype, rsptype, flatns, returns, rtype) \
virtual hf3fs::Result<rtype> name(const flatns::reqtype &req) = 0

View File

@@ -0,0 +1,8 @@
#ifndef DEFINE_SERDE_SERVICE_METHOD_FULL
#define DEFINE_SERDE_SERVICE_METHOD_FULL(ServiceName, methodName, MethodName, MethodId, RequestType, ResponseType)
#endif
#ifndef DEFINE_SERDE_SERVICE_METHOD
#define DEFINE_SERDE_SERVICE_METHOD(ServiceName, methodName, MethodName, MethodId) \
DEFINE_SERDE_SERVICE_METHOD_FULL(ServiceName, methodName, MethodName, MethodId, MethodName##Req, MethodName##Rsp)
#endif

46
src/fbs/macros/Stub.h Normal file
View File

@@ -0,0 +1,46 @@
#include "common/utils/Coroutine.h"
#include "common/utils/Result.h"
#ifdef DEFINE_FBS_SERVICE
#undef DEFINE_FBS_SERVICE
#endif
#define DEFINE_FBS_SERVICE(name, fbsns) \
template <typename Ctx> \
class name##ServiceStub : public I##name##ServiceStub { \
public: \
using ContextType = Ctx; \
using name##Client = ::fbsns::name##Client<Ctx>; \
\
explicit name##ServiceStub(Ctx ctx) \
: client_(std::move(ctx)) {}
#ifdef FINISH_FBS_SERVICE
#undef FINISH_FBS_SERVICE
#endif
#define FINISH_FBS_SERVICE(name, fbsns) \
private: \
name##Client client_; \
}
#ifdef DEFINE_FBS_SERVICE_METHOD
#undef DEFINE_FBS_SERVICE_METHOD
#endif
#define DEFINE_FBS_SERVICE_METHOD(svc, name, reqtype, rsptype, flatns) \
CoTryTask<flatns::rsptype> name(const flatns::reqtype &req) override
#ifdef DEFINE_FBS_SERVICE_METHOD_VOID
#undef DEFINE_FBS_SERVICE_METHOD_VOID
#endif
#define DEFINE_FBS_SERVICE_METHOD_VOID(svc, name, reqtype, rsptype, flatns) \
DEFINE_FBS_SERVICE_METHOD(svc, name, reqtype, rsptype, flatns)
#ifdef DEFINE_FBS_SERVICE_METHOD_RETURNS
#undef DEFINE_FBS_SERVICE_METHOD_RETURNS
#endif
#define DEFINE_FBS_SERVICE_METHOD_RETURNS(svc, name, reqtype, rsptype, flatns, returns, rtype) \
DEFINE_FBS_SERVICE_METHOD(svc, name, reqtype, rsptype, flatns)

45
src/fbs/macros/SyncStub.h Normal file
View File

@@ -0,0 +1,45 @@
#include "common/utils/Result.h"
#ifdef DEFINE_FBS_SERVICE
#undef DEFINE_FBS_SERVICE
#endif
#define DEFINE_FBS_SERVICE(name, fbsns) \
template <typename Ctx> \
class name##ServiceStub : public I##name##ServiceStub { \
public: \
using ContextType = Ctx; \
using name##Client = ::fbsns::name##Client<Ctx>; \
\
explicit name##ServiceStub(Ctx ctx) \
: client_(std::move(ctx)) {}
#ifdef FINISH_FBS_SERVICE
#undef FINISH_FBS_SERVICE
#endif
#define FINISH_FBS_SERVICE(name, fbsns) \
private: \
name##Client client_; \
}
#ifdef DEFINE_FBS_SERVICE_METHOD
#undef DEFINE_FBS_SERVICE_METHOD
#endif
#define DEFINE_FBS_SERVICE_METHOD(svc, name, reqtype, rsptype, flatns) \
hf3fs::Result<flatns::rsptype> name(const flatns::reqtype &req) override
#ifdef DEFINE_FBS_SERVICE_METHOD_VOID
#undef DEFINE_FBS_SERVICE_METHOD_VOID
#endif
#define DEFINE_FBS_SERVICE_METHOD_VOID(svc, name, reqtype, rsptype, flatns) \
hf3fs::Result<Void> name(const flatns::reqtype &req) override
#ifdef DEFINE_FBS_SERVICE_METHOD_RETURNS
#undef DEFINE_FBS_SERVICE_METHOD_RETURNS
#endif
#define DEFINE_FBS_SERVICE_METHOD_RETURNS(svc, name, reqtype, rsptype, flatns, returns, rtype) \
hf3fs::Result<rtype> name(const flatns::reqtype &req) override

7
src/fbs/macros/Undef.h Normal file
View File

@@ -0,0 +1,7 @@
#ifdef DEFINE_SERDE_SERVICE_METHOD
#undef DEFINE_SERDE_SERVICE_METHOD
#endif
#ifdef DEFINE_SERDE_SERVICE_METHOD_FULL
#undef DEFINE_SERDE_SERVICE_METHOD_FULL
#endif