-
Notifications
You must be signed in to change notification settings - Fork 41
/
generate.c
61 lines (56 loc) · 1.55 KB
/
generate.c
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
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <uv.h>
#include <stdio.h>
#include <stdlib.h>
void print_err()
{
printf("using System;\n\nnamespace LibuvSharp\n{\n\tpublic enum UVErrorCode\n\t{\n");
printf("\t\tOK = 0,\n");
#define XX(value, description) printf("\t\t/// <summary>\n" \
"\t\t/// %s\n" \
"\t\t/// </summary>\n" \
"\t\t%s,\n", description, #value);
UV_ERRNO_MAP(XX)
#undef XX
printf("\t}\n}\n");
}
void print_req()
{
printf("using System;\n\nnamespace LibuvSharp\n{\n\tenum RequestType : int\n\t{\n");
printf("\t\tUV_UNKNOWN_REQ = 0,\n");
#define XX(uc, lc) printf("\t\tUV_%s,\n", #uc);
UV_REQ_TYPE_MAP(XX);
#undef XX
printf("\t\tUV_REQ_TYPE_PRIVATE,\n");
printf("\t\tUV_REQ_TYPE_MAX,\n");
printf("\t}\n}\n");
}
void print_handle()
{
printf("using System;\n\nnamespace LibuvSharp\n{\n\tpublic enum HandleType : int\n\t{\n");
printf("\t\tUV_UNKNOWN_HANDLE = 0,\n");
#define XX(uc, lc) printf("\t\tUV_%s,\n", #uc);
UV_HANDLE_TYPE_MAP(XX);
#undef XX
printf("\t\tUV_FILE,\n");
printf("\t\tUV_HANDLE_TYPE_PRIVATE,\n");
printf("\t\tUV_HANDLE_TYPE_MAX,\n");
printf("\t}\n}\n");
}
int main(int argc, char **argv)
{
if (argc < 2) {
printf("Provide at least on parameter (err, req, handle)\n");
exit(0);
}
if (!strcmp(argv[1], "err")) {
print_err();
} else if (!strcmp(argv[1], "req")) {
print_req();
} else if (!strcmp(argv[1], "handle")) {
print_handle();
}
return 0;
}