Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

refactor: make json_helper decoupled from dsn_runtime #527

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

levy5307
Copy link
Contributor

@levy5307 levy5307 commented Jul 2, 2020

No description provided.

@@ -214,11 +214,11 @@
}

#define NON_MEMBER_JSON_SERIALIZATION(type, ...) \
inline void json_encode(dsn::json::JsonWriter &output, const type &t) \
void json_encode(dsn::json::JsonWriter &output, const type &t) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove inline?

Copy link
Contributor Author

@levy5307 levy5307 Jul 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In cpp, inline function must be defined in .h, but not .cpp. And we should move json_code function of gpid to gpid.cpp.

Comment on lines +342 to +343
void json_encode(JsonWriter &out, const dsn::gpid &pid);
bool json_decode(const dsn::json::JsonObject &in, dsn::gpid &pid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the declaration to gpid.h.

Suggested change
void json_encode(JsonWriter &out, const dsn::gpid &pid);
bool json_decode(const dsn::json::JsonObject &in, dsn::gpid &pid);
namespace json {
class JsonWriter;
class JsonObject;
} // namespace json
void json_encode(JsonWriter &out, const gpid &pid);
bool json_decode(const JsonObject &in, gpid &pid);

Do the same to other types.

Copy link
Contributor Author

@levy5307 levy5307 Jul 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why move the declaration to gpid.h? I think placed them centrally in one file is ok.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module itself should be responsible for its related code. There's no modularity if everything is in a central file.

@levy5307 levy5307 marked this pull request as draft July 8, 2020 06:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants