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
|
#!/usr/bin/env python
import os, re, sys, textwrap
import log_data
from dist import compare_srcfile
# Temporary file.
tmp_file = '__tmp'
# Map log record types to C
c_types = {
'string' : 'const char *',
}
# Map log record types to format strings
fmt_types = {
'string' : 'S',
}
#####################################################################
# Create log.i with inline functions for each log record type.
#####################################################################
f='../src/include/log.i'
tfile = open(tmp_file, 'w')
tfile.write('/* DO NOT EDIT: automatically built by dist/log.py. */\n')
for t in log_data.types:
tfile.write('''
static inline int
__wt_logput_%(name)s(WT_SESSION_IMPL *session, %(param_decl)s)
{
return (__wt_log_put(session, &__wt_logdesc_%(name)s, %(param_list)s));
}
''' % {
'name' : t.name,
'param_decl' : ', '.join(
'%s %s' % (c_types.get(t, t), n) for t, n in t.fields),
'param_list' : ', '.join(n for t, n in t.fields),
})
tfile.close()
compare_srcfile(tmp_file, f)
#####################################################################
# Create log_desc.c with descriptors for each log record type.
#####################################################################
f='../src/log/log_desc.c'
tfile = open(tmp_file, 'w')
tfile.write('''/* DO NOT EDIT: automatically built by dist/log.py. */
#include "wt_internal.h"
''')
for t in log_data.types:
tfile.write('''
WT_LOGREC_DESC
__wt_logdesc_%(name)s =
{
"%(fmt)s", { %(field_list)s, NULL }
};
''' % {
'name' : t.name,
'fmt' : ''.join(fmt_types[t] for t, n in t.fields),
'field_list' : ', '.join('"%s"' % n for t, n in t.fields),
})
tfile.close()
compare_srcfile(tmp_file, f)
|