Skip to content

Commit efa3ab9

Browse files
committed
revert it to build with C++11, and replace the possible keyword: module
1 parent 0c983e5 commit efa3ab9

7 files changed

+21
-21
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
1212
endif()
1313
message(STATUS "redis-protobuf build type: ${CMAKE_BUILD_TYPE}")
1414

15-
set(CMAKE_CXX_FLAGS "-std=c++17 -Wall -Wextra -Werror -fPIC -Wno-unused-parameter")
15+
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra -Werror -fPIC -Wno-unused-parameter")
1616

1717
set(PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR}/src/sw/redis-protobuf)
1818

src/sw/redis-protobuf/append_command.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ int AppendCommand::run(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
3737
auto key = api::open_key(ctx, args.key_name, api::KeyMode::WRITEONLY);
3838
assert(key);
3939

40-
auto &module = RedisProtobuf::instance();
40+
auto &m = RedisProtobuf::instance();
4141

4242
long long len = 0;
43-
if (!api::key_exists(key.get(), module.type())) {
44-
auto msg = module.proto_factory()->create(path.type());
43+
if (!api::key_exists(key.get(), m.type())) {
44+
auto msg = m.proto_factory()->create(path.type());
4545
MutableFieldRef field(msg.get(), path);
4646
len = _append(field, args.elements);
4747

4848
if (RedisModule_ModuleTypeSetValue(key.get(),
49-
module.type(),
49+
m.type(),
5050
msg.get()) != REDISMODULE_OK) {
5151
throw Error("failed to set message");
5252
}

src/sw/redis-protobuf/import_command.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ int ImportCommand::run(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
3232

3333
auto args = _parse_args(argv, argc);
3434

35-
auto &module = RedisProtobuf::instance();
36-
module.proto_factory()->load(args.filename, args.content);
35+
auto &m= RedisProtobuf::instance();
36+
m.proto_factory()->load(args.filename, args.content);
3737

3838
RedisModule_ReplicateVerbatim(ctx);
3939

src/sw/redis-protobuf/last_import_command.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ int LastImportCommand::run(RedisModuleCtx *ctx, RedisModuleString ** /*argv*/, i
3030
try {
3131
assert(ctx != nullptr);
3232

33-
auto &module = RedisProtobuf::instance();
34-
auto last_loaded_files = module.proto_factory()->last_loaded();
33+
auto &m = RedisProtobuf::instance();
34+
auto last_loaded_files = m.proto_factory()->last_loaded();
3535

3636
RedisModule_ReplyWithArray(ctx, last_loaded_files.size() * 2);
3737

src/sw/redis-protobuf/module_entry.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
2626
using namespace sw::redis::pb;
2727

2828
try {
29-
auto &module = RedisProtobuf::instance();
29+
auto &m = RedisProtobuf::instance();
3030

31-
module.load(ctx, argv, argc);
31+
m.load(ctx, argv, argc);
3232
} catch (const Error &e) {
3333
api::warning(ctx, "%s", e.what());
3434
return REDISMODULE_ERR;

src/sw/redis-protobuf/redis_protobuf.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ void* RedisProtobuf::_rdb_load(RedisModuleIO *rdb, int encver) {
9797
try {
9898
assert(rdb != nullptr);
9999

100-
auto &module = RedisProtobuf::instance();
100+
auto &m = RedisProtobuf::instance();
101101

102-
if (encver != module.encoding_version()) {
102+
if (encver != m.encoding_version()) {
103103
throw Error("cannot load data of version: " + std::to_string(encver));
104104
}
105105

@@ -109,7 +109,7 @@ void* RedisProtobuf::_rdb_load(RedisModuleIO *rdb, int encver) {
109109

110110
auto type = std::string(type_str.str.get(), type_str.len);
111111

112-
auto *factory = module.proto_factory();
112+
auto *factory = m.proto_factory();
113113

114114
assert(factory != nullptr);
115115

src/sw/redis-protobuf/set_command.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,16 @@ void SetCommand::_create_msg(RedisModuleKey &key,
169169
const Path &path,
170170
const StringView &val) const {
171171
MsgUPtr msg;
172-
auto &module = RedisProtobuf::instance();
172+
auto &m = RedisProtobuf::instance();
173173
if (path.empty()) {
174-
msg = module.proto_factory()->create(path.type(), val);
174+
msg = m.proto_factory()->create(path.type(), val);
175175
} else {
176-
msg = module.proto_factory()->create(path.type());
176+
msg = m.proto_factory()->create(path.type());
177177
MutableFieldRef field(msg.get(), path);
178178
_set_field(field, val);
179179
}
180180

181-
if (RedisModule_ModuleTypeSetValue(&key, module.type(), msg.get()) != REDISMODULE_OK) {
181+
if (RedisModule_ModuleTypeSetValue(&key, m.type(), msg.get()) != REDISMODULE_OK) {
182182
throw Error("failed to set message");
183183
}
184184

@@ -197,9 +197,9 @@ void SetCommand::_set_msg(RedisModuleKey &key,
197197
throw Error("type mismatch");
198198
}
199199

200-
auto &module = RedisProtobuf::instance();
201-
auto msg = module.proto_factory()->create(path.type(), val);
202-
if (RedisModule_ModuleTypeSetValue(&key, module.type(), msg.get()) != REDISMODULE_OK) {
200+
auto &m = RedisProtobuf::instance();
201+
auto msg = m.proto_factory()->create(path.type(), val);
202+
if (RedisModule_ModuleTypeSetValue(&key, m.type(), msg.get()) != REDISMODULE_OK) {
203203
throw Error("failed to set message");
204204
}
205205

0 commit comments

Comments
 (0)