blob: 2debe8d5436c9d9015302b27cccbd3149f9f82eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
//
// Created by tea on 10.03.16.
//
#ifndef PROTOC_BNET_BNETSERVICEGENERATOR_H
#define PROTOC_BNET_BNETSERVICEGENERATOR_H
#include <google/protobuf/stubs/common.h>
#include <cstdint>
#include <string>
#include <map>
namespace google
{
namespace protobuf
{
class ServiceDescriptor;
namespace io
{
class Printer;
}
namespace compiler
{
namespace cpp
{
struct Options;
}
}
}
}
namespace pb = google::protobuf;
namespace pbcpp = pb::compiler::cpp;
class BnetServiceGenerator
{
public:
// See generator.cc for the meaning of dllexport_decl.
BnetServiceGenerator(const pb::ServiceDescriptor* descriptor,
const pbcpp::Options& options);
~BnetServiceGenerator();
// Header stuff.
// Generate the class definitions for the service's interface and the
// stub implementation.
void GenerateDeclarations(pb::io::Printer* printer);
// Source file stuff.
// Generate code that initializes the global variable storing the service's
// descriptor.
void GenerateDescriptorInitializer(pb::io::Printer* printer, int index);
// Generate implementations of everything declared by GenerateDeclarations().
void GenerateImplementation(pb::io::Printer* printer);
private:
// Header stuff.
// Generate the service abstract interface.
void GenerateInterface(pb::io::Printer* printer);
// Prints signatures for all methods in the
void GenerateClientMethodSignatures(pb::io::Printer* printer);
void GenerateServerMethodSignatures(pb::io::Printer* printer);
// Source file stuff.
void GenerateClientMethodImplementations(pb::io::Printer* printer);
// Generate the CallMethod() method of the service.
void GenerateServerCallMethod(pb::io::Printer* printer);
void GenerateServerImplementations(pb::io::Printer* printer);
std::uint32_t HashServiceName(std::string const& name);
const pb::ServiceDescriptor* descriptor_;
std::map<std::string, std::string> vars_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(BnetServiceGenerator);
};
#endif //PROTOC_BNET_BNETSERVICEGENERATOR_H
|