Example #1
0
def output(p, f):
    tmp_file = '__tmp'
    tfile = open(tmp_file, 'w')
    for e in sorted(list(set(p))):
        tfile.write(e)
    tfile.close()
    compare_srcfile(tmp_file, f)
Example #2
0
def function_declaration():
    tmp_file = '__tmp'
    for name in all_c_files():
        skip_re = re.compile(r'DO NOT EDIT: automatically built')
        s = open(name, 'r').read()
        if skip_re.search(s):
            continue

        # Read through the file, and for each function, do a style pass over
        # the local declarations. Quit tracking declarations as soon as we
        # find anything we don't understand, leaving it untouched.
        with open(name, 'r') as f:
            tfile = open(tmp_file, 'w')
            tracking = False
            for line in f:
                if not tracking:
                    tfile.write(line)
                    if re.search('^{$', line):
                        list = [[] for i in range(len(types))]
                        static_list = [[] for i in range(len(types))]
                        tracking = True
                    continue

                found, n = function_args(name, line)
                if found:
                    # List statics first.
                    if re.search("^\sstatic", line):
                        static_list[n].append(line)
                        continue

                    # Disallow assignments in the declaration. Ignore braces
                    # to allow automatic array initialization using constant
                    # initializers (and we've already skipped statics, which
                    # are also typically initialized in the declaration).
                    if re.search("\s=\s[-\w]", line):
                        print >>sys.stderr, \
                            name + ": assignment in string: " + line.strip()
                        sys.exit(1)

                    list[n].append(line)
                else:
                    # Sort the resulting lines (we don't yet sort declarations
                    # within a single line). It's two passes, first to catch
                    # the statics, then to catch everything else.
                    for arg in filter(None, static_list):
                        for p in sorted(arg, key=function_args_alpha):
                            tfile.write(p)
                    for arg in filter(None, list):
                        for p in sorted(arg, key=function_args_alpha):
                            tfile.write(p)
                    tfile.write(line)
                    tracking = False
                    continue

            tfile.close()
            compare_srcfile(tmp_file, name)
Example #3
0
def function_declaration():
    tmp_file = '__tmp'
    for name in all_c_files():
        skip_re = re.compile(r'DO NOT EDIT: automatically built')
        s = open(name, 'r').read()
        if skip_re.search(s):
            continue

        # Read through the file, and for each function, do a style pass over
        # the local declarations. Quit tracking declarations as soon as we
        # find anything we don't understand, leaving it untouched.
        with open(name, 'r') as f:
            tfile = open(tmp_file, 'w')
            tracking = False
            for line in f:
                if not tracking:
                    tfile.write(line)
                    if re.search('^{$', line):
                        list = [[] for i in range(len(types))]
                        static_list = [[] for i in range(len(types))]
                        tracking = True;
                    continue

                found,n = function_args(name, line)
                if found:
                    # List statics first.
                    if re.search("^\sstatic", line):
                        static_list[n].append(line)
                        continue

                    # Disallow assignments in the declaration. Ignore braces
                    # to allow automatic array initialization using constant
                    # initializers (and we've already skipped statics, which
                    # are also typically initialized in the declaration).
                    if re.search("\s=\s[-\w]", line):
                        print >>sys.stderr, \
                            name + ": assignment in string: " + line.strip()
                        sys.exit(1);

                    list[n].append(line)
                else:
                    # Sort the resulting lines (we don't yet sort declarations
                    # within a single line). It's two passes, first to catch
                    # the statics, then to catch everything else.
                    for arg in filter(None, static_list):
                        for p in sorted(arg, key=function_args_alpha):
                            tfile.write(p)
                    for arg in filter(None, list):
                        for p in sorted(arg, key=function_args_alpha):
                            tfile.write(p)
                    tfile.write(line)
                    tracking = False
                    continue

            tfile.close()
            compare_srcfile(tmp_file, name)
Example #4
0
def output(fns, tests, f):
    tmp_file = '__tmp'
    tfile = open(tmp_file, 'w')
    for e in sorted(list(set(fns))):
        tfile.write(e)

    tfile.write('\n#ifdef HAVE_UNITTEST\n')
    for e in sorted(list(set(tests))):
        tfile.write(e)
    tfile.write('\n#endif\n')

    tfile.close()
    format_srcfile(tmp_file)
    compare_srcfile(tmp_file, f)
Example #5
0
def flag_declare(name):
    tmp_file = '__tmp'
    with open(name, 'r') as f:
        tfile = open(tmp_file, 'w')

        lcnt = 0
        parsing = False
        for line in f:
            lcnt = lcnt + 1
            if line.find('AUTOMATIC FLAG VALUE GENERATION START') != -1:
                header = line
                defines = []
                parsing = True
            elif line.find('AUTOMATIC FLAG VALUE GENERATION STOP') != -1:
                # We only support 64 bits.
                if len(defines) > 64:
                    print >>sys.stderr, name + ": line " +\
                        str(lcnt) + ": exceeds maximum 64 bit flags"
                    sys.exit(1)

                # Calculate number of hex bytes, create format string
                fmt = "0x%%0%dxu" % ((len(defines) + 3) / 4)

                tfile.write(header)
                v = 1
                for d in sorted(defines):
                    tfile.write(re.sub("0x[01248u]*", fmt % v, d))
                    v = v * 2
                tfile.write(line)

                parsing = False
            elif parsing and line.find('#define') == -1:
                print >>sys.stderr, name + ": line " +\
                    str(lcnt) + ": unexpected flag line, no #define"
                sys.exit(1)
            elif parsing:
                defines.append(line)
            else:
                tfile.write(line)

        tfile.close()
        compare_srcfile(tmp_file, name)
Example #6
0
def flag_declare(name):
    tmp_file = '__tmp'
    with open(name, 'r') as f:
        tfile = open(tmp_file, 'w')

        lcnt = 0
        parsing = False
        for line in f:
            lcnt = lcnt + 1
            if line.find('AUTOMATIC FLAG VALUE GENERATION START') != -1:
                header = line
                defines = []
                parsing = True
            elif line.find('AUTOMATIC FLAG VALUE GENERATION STOP') != -1:
                # We only support 64 bits.
                if len(defines) > 64:
                    print(name + ": line " + str(lcnt) +\
                          ": exceeds maximum 64 bit flags", file=sys.stderr)
                    sys.exit(1)

                # Calculate number of hex bytes, create format string
                fmt = "0x%%0%dxu" % ((len(defines) + 3) / 4)

                tfile.write(header)
                v = 1
                for d in sorted(defines):
                    tfile.write(re.sub("0x[01248u]*", fmt % v, d))
                    v = v * 2
                tfile.write(line)

                parsing = False
            elif parsing and line.find('#define') == -1:
                print(name + ": line " + str(lcnt) +\
                      ": unexpected flag line, no #define", file=sys.stderr)
                sys.exit(1)
            elif parsing:
                defines.append(line)
            else:
                tfile.write(line)

        tfile.close()
        compare_srcfile(tmp_file, name)
Example #7
0
def function_declaration():
    tmp_file = '__tmp'
    for name in all_c_files():
        skip_re = re.compile(r'DO NOT EDIT: automatically built')
        s = open(name, 'r').read()
        if skip_re.search(s):
            continue

        # Read through the file, and for each function, do a style pass over
        # the local declarations. Quit tracking declarations as soon as we
        # find anything we don't understand, leaving it untouched.
        with open(name, 'r') as f:
            tfile = open(tmp_file, 'w')
            tracking = False
            for line in f:
                if not tracking:
                    tfile.write(line)
                    if re.search('^{$', line):
                        r = [[] for i in range(len(types))]
                        tracking = True
                    continue

                found, n = function_args(line)
                if found:
                    r[n].append(line)
                else:
                    # Sort the resulting lines (we don't yet sort declarations
                    # within a single line).
                    for arg in filter(None, r):
                        for p in sorted(arg, key=function_args_alpha):
                            tfile.write(p)
                    tfile.write(line)
                    tracking = False
                    continue

            tfile.close()
            compare_srcfile(tmp_file, name)
Example #8
0
def flag_declare(name):
    tmp_file = '__tmp'
    with open(name, 'r') as f:
        tfile = open(tmp_file, 'w')

        lcnt = 0
        max_flags = 0
        parsing = False
        start = 0
        stopped = ''
        for line in f:
            lcnt = lcnt + 1
            if stopped != '':
                stopped = ''
                m = re.search("\d+", line)
                if m != None:
                    fld_size = int(m.group(0))
                    if max_flags > fld_size:
                        print("file: " + name + " line: " + str(lcnt))
                        print("Flag stop value of " + str(max_flags) \
                                + " is larger than field size " + str(fld_size))
                        sys.exit(1)
            if line.find('AUTOMATIC FLAG VALUE GENERATION START') != -1:
                m = re.search("\d+", line)
                if m == None:
                    print(name + ": automatic flag generation start at line " +
                          str(lcnt) +
                          " needs start value e.g. AUTOMATIC FLAG VALUE" +
                          " GENERATION START 0",
                          file=sys.stderr)
                    sys.exit(1)
                start = int(m.group(0))
                header = line
                defines = []
                parsing = True
            elif line.find('AUTOMATIC FLAG VALUE GENERATION STOP') != -1:
                m = re.search("\d+", line)
                if m == None:
                    print(name + ": automatic flag generation stop at line " +
                          str(lcnt) +
                          " needs stop value e.g. AUTOMATIC FLAG VALUE" +
                          " GENERATION STOP 32",
                          file=sys.stderr)
                    sys.exit(1)
                end = int(m.group(0))

                poweroftwo = (end != 0) and ((end & (end - 1)) == 0)
                if not poweroftwo and end != 12:
                    print(name + ": line " + str(lcnt) + ", the stop value " +
                          str(end) + " is not a power of 2",
                          file=sys.stderr)
                    sys.exit(1)
                # Compare the number of flags defined and against the number
                # of flags allowed
                max_flags = len(defines)
                if max_flags > end - start:
                    print(name + ": line " + str(lcnt) +\
                          ": exceeds maximum {0} limit bit flags".format(end), file=sys.stderr)
                    sys.exit(1)

                # Calculate number of hex bytes, create format string
                fmt = "0x%%0%dxu" % ((start + max_flags + 3) / 4)

                # Generate the flags starting from an offset set from the start value.
                tfile.write(header)
                v = 1 << start
                for d in sorted(defines):
                    tfile.write(re.sub("0x[01248u]*", fmt % v, d))
                    v = v * 2
                tfile.write(line)

                parsing = False
                start = 0
                stopped = line
                continue
            elif parsing and line.find('#define') == -1:
                print(name + ": line " + str(lcnt) +\
                      ": unexpected flag line, no #define", file=sys.stderr)
                sys.exit(1)
            elif parsing:
                defines.append(line)
            else:
                tfile.write(line)
            stopped = ''

        tfile.close()
        compare_srcfile(tmp_file, name)
Example #9
0
            end_found = True
            in_section = False

        elif line.find(start_tag) != -1:
            assert not start_found and not end_found, 'Duplicate tag'

            start_found = True
            in_section = True

            escape_char = ''
            if line.strip().endswith('\\'):
                escape_char = '\\'

            indentation = len(line) - len(line.lstrip())

            for category in verbose_categories:
                line_tmp += indentation * ' ' + "\"" + category + "\", %s\n" % escape_char

        elif in_section:
            continue

        tfile.write(line_tmp)

    assert not in_section and start_found and end_found, 'File syntax incorrect'

    tfile.close()
    compare_srcfile(tmp_file, filename)

f.close()
Example #10
0
        # Deal with duplicates: with complex configurations (like
        # WT_SESSION::create), it's simpler to deal with duplicates here than
        # manually in api_data.py.
        if name == lastname:
            continue
        lastname = name
        if "undoc" in c.flags:
            continue
        output = parseconfig(c)
        for l in w.wrap(output):
            tfile.write(prefix + l.replace("\n", "\n" + prefix) + "\n")

    tfile.write(prefix + "@configend\n")

tfile.close()
compare_srcfile(tmp_file, f)

#####################################################################
# Create config_def.c with defaults for each config string
#####################################################################
f = "../src/config/config_def.c"
tfile = open(tmp_file, "w")

tfile.write(
    """/* DO NOT EDIT: automatically built by dist/api_config.py. */

#include "wt_internal.h"
"""
)

# Make a TextWrapper that can wrap at commas.
Example #11
0
        # Deal with duplicates: with complex configurations (like
        # WT_SESSION::create), it's simpler to deal with duplicates here than
        # manually in api_data.py.
        if name == lastname:
            continue
        lastname = name
        if 'undoc' in c.flags:
            continue
        output = parseconfig(c, config_name)
        for l in w.wrap(output):
            tfile.write(prefix + l.replace('\n', '\n' + prefix) + '\n')

    tfile.write(prefix + '@configend\n')

tfile.close()
compare_srcfile(tmp_file, f)

#####################################################################
# Create config_def.c with defaults for each config string
#####################################################################
f='../src/config/config_def.c'
tfile = open(tmp_file, 'w')

tfile.write('''/* DO NOT EDIT: automatically built by dist/api_config.py. */

#include "wt_internal.h"
''')

# Make a TextWrapper that wraps at commas.
w = textwrap.TextWrapper(width=64, break_on_hyphens=False)
w.wordsep_re = w.wordsep_simple_re = re.compile(r'(,)')
Example #12
0
\t__wt_page_modify_set(session, page);

\treturn (0);
}

''')

#####################################################################
# Update serial.i.
#####################################################################
tmp_file = '__tmp'
tfile = open(tmp_file, 'w')
skip = 0
for line in open('../src/include/serial.i', 'r'):
	if not skip:
		tfile.write(line)
	if line.count('Serialization function section: END'):
		tfile.write(line)
		skip = 0
	elif line.count('Serialization function section: BEGIN'):
		tfile.write(' */\n\n')
		skip = 1

		for entry in msgtypes:
			output(entry, tfile)

		tfile.write('/*\n')

tfile.close()
compare_srcfile(tmp_file, '../src/include/serial.i')
Example #13
0
                + """_args *)untyped_args;

\targs->"""
                + l.name
                + """_taken = 1;

\tWT_ASSERT(session, args->"""
                + l.name
                + """_size != 0);
\t__wt_cache_page_inmem_incr(session, page, args->"""
                + l.name
                + """_size);
}
"""
            )


#####################################################################
# Update serial_funcs.i.
#####################################################################
tmp_file = "__tmp"
tfile = open(tmp_file, "w")
tfile.write("/* DO NOT EDIT: automatically built by dist/serial.py. */\n")

for entry in msgtypes:
    output(entry, tfile)

tfile.close()

compare_srcfile(tmp_file, "../src/include/serial_funcs.i")
Example #14
0
    for m in flag_name[f[0]]:
        name_mask[m] |= mask

# Print out the flag masks in hex.
# 	Assumes tab stops set to 8 characters.
flag_info = ""
for f in sorted(flag_cnt.items()):
    flag_info += "#define\tWT_%s%s%#010x\n" % (
        f[0],
        "\t" * max(1, 6 - int((len("WT_") + len(f[0])) / 8)),
        flag_bit[f[0]],
    )

# Update the wiredtiger.in file with the flags information.
tmp_file = "__tmp"
tfile = open(tmp_file, "w")
skip = 0
for line in open("../src/include/flags.h", "r"):
    if skip:
        if line.count("flags section: END"):
            tfile.write("/*\n" + line)
            skip = 0
    else:
        tfile.write(line)
    if line.count("flags section: BEGIN"):
        skip = 1
        tfile.write(" */\n")
        tfile.write(flag_info)
tfile.close()
compare_srcfile(tmp_file, "../src/include/flags.h")
Example #15
0
#####################################################################
f='../src/include/wiredtiger.in'
o='../lang/java/java_doc.i'
tfile = open(tmp_file, 'w')

tfile.write('''/* DO NOT EDIT: automatically built by dist/java_doc.py. */

''')

cclass_re = re.compile('^struct __([a-z_]*) {')
cfunc_re = re.compile('\t.*? __F\(([a-z_]*)\)')

curr_class = ""
for line in open(f, 'r'):

	m = cclass_re.match(line)
	if m:
		curr_class = m.group(1)

	if curr_class == "":
		continue

	m = cfunc_re.match(line)
	if m:
		tfile.write('COPYDOC(__' + curr_class.lower() + ', ' +
                curr_class.upper() + ', ' + m.group(1) + ')\n')

tfile.close()
compare_srcfile(tmp_file, o)

Example #16
0
\treturn (0);
}

''')


#####################################################################
# Update serial.i.
#####################################################################
tmp_file = '__tmp'
tfile = open(tmp_file, 'w')
skip = 0
for line in open('../src/include/serial.i', 'r'):
    if not skip:
        tfile.write(line)
    if line.count('Serialization function section: END'):
        tfile.write(line)
        skip = 0
    elif line.count('Serialization function section: BEGIN'):
        tfile.write(' */\n\n')
        skip = 1

        for entry in msgtypes:
            output(entry, tfile)

        tfile.write('/*\n')

tfile.close()
compare_srcfile(tmp_file, '../src/include/serial.i')
Example #17
0
		for err in api_data.errors:
			if 'undoc' in err.flags:
				tfile.write('/*! @cond internal */\n')
			tfile.write('/*!%s.%s */\n' %
			    (('\n * ' if err.long_desc else ' ') +
                    err.desc[0].upper() + err.desc[1:],
			    ''.join('\n * ' + l for l in textwrap.wrap(
                    textwrap.dedent(err.long_desc).strip(), 77)) +
                '\n' if err.long_desc else ''))
			tfile.write('#define\t%s\t%d\n' % (err.name, v))
			v -= 1
			if 'undoc' in err.flags:
				tfile.write('/*! @endcond */\n')
		tfile.write('/*\n')
tfile.close()
compare_srcfile(tmp_file, '../src/include/wiredtiger.in')

# Output the wiredtiger_strerror code.
tmp_file = '__tmp'
tfile = open(tmp_file, 'w')
tfile.write('''/* DO NOT EDIT: automatically built by dist/api_err.py. */

#include "wt_internal.h"

/*
 * wiredtiger_strerror --
 *	Return a string for any error value.
 */
const char *
wiredtiger_strerror(int error)
{
Example #18
0
	flag_bit[f[0]] = mask
	for m in flag_name[f[0]]:
		name_mask[m] |= mask

# Print out the flag masks in hex.
#	Assumes tab stops set to 8 characters.
flag_info = ''
for f in sorted(flag_cnt.items()):
	flag_info += "#define\tWT_%s%s%#010x\n" %\
	    (f[0],\
	    "\t" * max(1, 6 - int((len('WT_') + len(f[0])) / 8)),\
	    flag_bit[f[0]])

# Update the wiredtiger.in file with the flags information.
tmp_file = '__tmp'
tfile = open(tmp_file, 'w')
skip = 0
for line in open('../src/include/api.h', 'r'):
	if skip:
		if line.count('API flags section: END'):
			tfile.write('/*\n' + line)
			skip = 0
	else:
		tfile.write(line)
	if line.count('API flags section: BEGIN'):
		skip = 1
		tfile.write(' */\n')
		tfile.write(flag_info)
tfile.close()
compare_srcfile(tmp_file, '../src/include/api.h')
Example #19
0
for line in open('../src/include/stat.h', 'r'):
    if not skip:
        f.write(line)
    if line.count('Statistics section: END'):
        f.write(line)
        skip = 0
    elif line.count('Statistics section: BEGIN'):
        f.write('\n')
        skip = 1
        print_struct('connections', 'connection', 1000, connection_statistics)
        print_struct('data sources', 'dsrc', 2000, dsrc_statistics)
        print_struct('join cursors', 'join', 3000, join_stats)
        print_struct('session', 'session', 4000, session_stats)
f.close()
format_srcfile(tmp_file)
compare_srcfile(tmp_file, '../src/include/stat.h')


def print_defines_one(capname, base, stats):
    for v, l in enumerate(stats, base):
        desc = l.desc
        if 'cache_walk' in l.flags:
            desc += \
                ', only reported if cache_walk or all statistics are enabled'
        if 'tree_walk' in l.flags:
            desc += ', only reported if tree_walk or all statistics are enabled'
        if len(textwrap.wrap(desc, 70)) > 1:
            f.write('/*!\n')
            f.write(' * %s\n' % '\n * '.join(textwrap.wrap(desc, 70)))
            f.write(' */\n')
        else:
Example #20
0
def flag_declare(name):
    tmp_file = '__tmp'
    with open(name, 'r') as f:
        tfile = open(tmp_file, 'w')

        lcnt = 0
        parsing = False
        start = 0
        for line in f:
            lcnt = lcnt + 1
            if line.find('AUTOMATIC FLAG VALUE GENERATION START') != -1:
                m = re.search("\d+", line)
                if m == None:
                    print(name + ": automatic flag generation start at line " +
                          str(lcnt) +
                          " needs start value e.g. AUTOMATIC FLAG VALUE" +
                          " GENERATION START 0",
                          file=sys.stderr)
                    sys.exit(1)
                start = int(m.group(0))
                header = line
                defines = []
                parsing = True
            elif line.find('AUTOMATIC FLAG VALUE GENERATION STOP') != -1:
                m = re.search("\d+", line)
                if m == None:
                    print(name + ": automatic flag generation stop at line " +
                          str(lcnt) +
                          " needs stop value e.g. AUTOMATIC FLAG VALUE" +
                          " GENERATION STOP 32",
                          file=sys.stderr)
                    sys.exit(1)
                end = int(m.group(0))
                # Compare the number of flags defined and against the number
                # of flags allowed
                if len(defines) > end - start:
                    print(name + ": line " + str(lcnt) +\
                          ": exceeds maximum {0} limit bit flags".format(end), file=sys.stderr)
                    sys.exit(1)

                # Calculate number of hex bytes, create format string
                fmt = "0x%%0%dxu" % ((start + len(defines) + 3) / 4)

                # Generate the flags starting from an offset set from the start value.
                tfile.write(header)
                v = 1 << start
                for d in sorted(defines):
                    tfile.write(re.sub("0x[01248u]*", fmt % v, d))
                    v = v * 2
                tfile.write(line)

                parsing = False
                start = 0
            elif parsing and line.find('#define') == -1:
                print(name + ": line " + str(lcnt) +\
                      ": unexpected flag line, no #define", file=sys.stderr)
                sys.exit(1)
            elif parsing:
                defines.append(line)
            else:
                tfile.write(line)

        tfile.close()
        compare_srcfile(tmp_file, name)
Example #21
0
        # Deal with duplicates: with complex configurations (like
        # WT_SESSION::create), it's simpler to deal with duplicates here than
        # manually in api_data.py.
        if name == lastname:
            continue
        lastname = name
        if 'undoc' in c.flags:
            continue
        output = parseconfig(c, config_name)
        for l in w.wrap(output):
            tfile.write(prefix + l.replace('\n', '\n' + prefix) + '\n')

    tfile.write(prefix + '@configend\n')

tfile.close()
compare_srcfile(tmp_file, f)

#####################################################################
# Create config_def.c with defaults for each config string
#####################################################################
f = '../src/config/config_def.c'
tfile = open(tmp_file, 'w')

tfile.write('''/* DO NOT EDIT: automatically built by dist/api_config.py. */

#include "wt_internal.h"
''')

# Make a TextWrapper that wraps at commas.
w = textwrap.TextWrapper(width=64, break_on_hyphens=False)
w.wordsep_re = w.wordsep_simple_re = re.compile(r'(,)')
Example #22
0
f = open(tmp_file, 'w')
skip = 0
for line in open('../src/include/stat.h', 'r'):
    if not skip:
        f.write(line)
    if line.count('Statistics section: END'):
        f.write(line)
        skip = 0
    elif line.count('Statistics section: BEGIN'):
        f.write('\n')
        skip = 1
        print_struct(
            'connections', 'connection', 1000, connection_stats)
        print_struct('data sources', 'dsrc', 2000, dsrc_stats)
f.close()
compare_srcfile(tmp_file, '../src/include/stat.h')

def print_defines():
    '''Print the #defines for the wiredtiger.in file.'''
    f.write('''
/*!
 * @name Connection statistics
 * @anchor statistics_keys
 * @anchor statistics_conn
 * Statistics are accessed through cursors with \c "statistics:" URIs.
 * Individual statistics can be queried through the cursor using the following
 * keys.  See @ref data_statistics for more information.
 * @{
 */
''')
    for v, l in enumerate(connection_stats, 1000):
Example #23
0
{
\tuint32_t optype, opsize;

\t/* Peek at the size and the type. */
\tWT_RET(__wt_logop_read(session, pp, end, &optype, &opsize));
\tend = *pp + opsize;

\tswitch (optype) {''')

for optype in log_data.optypes:
    tfile.write(
        '''
\tcase %(macro)s:
\t\tWT_RET(%(print_func)s(session, pp, end, args));
\t\tbreak;
''' % {
            'macro': optype.macro_name(),
            'print_func': '__wt_logop_' + optype.name + '_print',
        })

tfile.write('''
\tdefault:\n\t\treturn (__wt_illegal_value(session, optype));
\t}

\treturn (0);
}
''')

tfile.close()
compare_srcfile(tmp_file, f)
Example #24
0
# Update wiredtiger.in with doxygen comments
#####################################################################
f = '../src/include/wiredtiger.in'
o = '../lang/java/java_doc.i'
tfile = open(tmp_file, 'w')

tfile.write('''/* DO NOT EDIT: automatically built by dist/java_doc.py. */

''')

cclass_re = re.compile('^struct __([a-z_]*) {')
cfunc_re = re.compile('\s+.*? __F\(([a-z_]*)\)')

curr_class = ""
for line in open(f, 'r'):

    m = cclass_re.match(line)
    if m:
        curr_class = m.group(1)

    if curr_class == "":
        continue

    m = cfunc_re.match(line)
    if m:
        tfile.write('COPYDOC(__' + curr_class.lower() + ', ' +
                    curr_class.upper() + ', ' + m.group(1) + ')\n')

tfile.close()
compare_srcfile(tmp_file, o)
Example #25
0
                                 replace_whitespace=False,
                                 fix_sentence_endings=True)
        # Separate at spaces, and after a set of non-breaking space indicators.
        w.wordsep_re = w.wordsep_simple_re = \
            re.compile(r'(\s+|(?<=&nbsp;)[\w_,.;:]+)')
        for c in api_data_def.methods[config_name].config:
            if 'undoc' in c.flags:
                continue
            output = parseconfig(c, config_name)
            for l in w.wrap(output):
                tfile.write(prefix + l.replace('\n', '\n' + prefix) + '\n')

        tfile.write(prefix + '@configend\n')

    tfile.close()
    compare_srcfile(tmp_file, f)

#####################################################################
# Create config_def.c with defaults for each config string
#####################################################################
f = '../src/config/config_def.c'
if test_config:
    f = '../src/config/test_config.c'
tfile = open(tmp_file, 'w')

tfile.write('''/* DO NOT EDIT: automatically built by dist/api_config.py. */

#include "wt_internal.h"
''')

# Make a TextWrapper that wraps at commas.
Example #26
0
        # Deal with duplicates: with complex configurations (like
        # WT_SESSION::create), it's simpler to deal with duplicates here than
        # manually in api_data.py.
        if name == lastname:
            continue
        lastname = name
        if "undoc" in c.flags:
            continue
        output = parseconfig(c)
        for l in w.wrap(output):
            tfile.write(prefix + l + "\n")

    tfile.write(prefix + "@configend\n")

tfile.close()
compare_srcfile(tmp_file, f)

#####################################################################
# Create config_def.c with defaults for each config string
#####################################################################
f = "../src/config/config_def.c"
tfile = open(tmp_file, "w")

tfile.write(
    """/* DO NOT EDIT: automatically built by dist/config.py. */

#include "wt_internal.h"
"""
)

# Make a TextWrapper that can wrap at commas.
Example #27
0
f = open(tmp_file, 'w')
skip = 0
for line in open('../src/include/stat.h', 'r'):
	if not skip:
		f.write(line)
	if line.count('Statistics section: END'):
		f.write(line)
		skip = 0
	elif line.count('Statistics section: BEGIN'):
		f.write('\n')
		skip = 1
		print_struct('BTREE', 'btree', btree_stats)
		print_struct('CONNECTION', 'connection', connection_stats)
		print_struct('LSM', 'lsm', lsm_stats)
f.close()
compare_srcfile(tmp_file, '../src/include/stat.h')

# print_define --
#	Print the #defines for the wiredtiger.in file.
def print_define():
	# Sort the structure fields by their description so they match
	# the structure lists.
	f.write('''
/*!
 * @name Statistics for connection handles
 * @anchor statistics_keys
 * @anchor statistics_conn
 * Statistics in WiredTiger are accessed through cursors with \c "statistics:"
 * URIs.  Individual statistics can be queried through the cursor using the
 * following keys.
 * @{
Example #28
0
skip = 0
for line in open('../src/include/wiredtiger.in', 'r'):
    if skip:
        if 'Log record declarations: END' in line:
            tfile.write('/*\n' + line)
            skip = 0
    else:
        tfile.write(line)
    if 'Log record declarations: BEGIN' in line:
        skip = 1
        tfile.write(' */\n')
        tfile.write('/*! invalid operation */\n')
        tfile.write('#define\tWT_LOGOP_INVALID\t0\n')
        tfile.write(log_defines)
tfile.close()
compare_srcfile(tmp_file, '../src/include/wiredtiger.in')

#####################################################################
# Create log_auto.c with handlers for each record / operation type.
#####################################################################
f='../src/log/log_auto.c'
tfile = open(tmp_file, 'w')

tfile.write('/* DO NOT EDIT: automatically built by dist/log.py. */\n')

tfile.write('''
#include "wt_internal.h"

int
__wt_logrec_alloc(WT_SESSION_IMPL *session, size_t size, WT_ITEM **logrecp)
{
Example #29
0
skip = 0
for line in open('../src/include/stat.h', 'r'):
    if not skip:
        f.write(line)
    if line.count('Statistics section: END'):
        f.write(line)
        skip = 0
    elif line.count('Statistics section: BEGIN'):
        f.write('\n')
        skip = 1
        print_struct(
            'connections', 'connection', 1000, connection_stats)
        print_struct('data sources', 'dsrc', 2000, dsrc_stats)
        print_struct('join cursors', 'join', 3000, join_stats)
f.close()
compare_srcfile(tmp_file, '../src/include/stat.h')

def print_defines_one(capname, base, stats):
    for v, l in enumerate(stats, base):
        f.write('/*! %s */\n' % '\n * '.join(textwrap.wrap(l.desc, 70)))
        f.write('#define\tWT_STAT_' + capname + '_' + l.name.upper() + "\t" *
            max(1, 6 - int((len('WT_STAT_' + capname + '_' + l.name)) / 8)) +
            str(v) + '\n')

def print_defines():
    '''Print the #defines for the wiredtiger.in file.'''
    f.write('''
/*!
 * @name Connection statistics
 * @anchor statistics_keys
 * @anchor statistics_conn
Example #30
0
            functionality = format_tag(current_tag[2])

        # Relative path to test files
        link = ""
        # Sort the filenames associated to the current tag
        tagged_files[tag].sort()
        for name in tagged_files[tag]:
            link += "[" + os.path.basename(name) + "](" + name + "), "
        # Remove the extra ", " at the end
        link = link[:-2]

        # Write to output
        tfile.write('|' + component + '|' + \
                        functionality + '|' + link + '\n')
tfile.close()
compare_srcfile(tmp_filename, "../test/test_coverage.md")
#####

##### STATS #####
if show_info == True:
    print("Tagged files:\t" + str(nb_valid_files - nb_ignored_files))
    print("Missing files:\t" + str(nb_missing_files))
    print("Ignored files:\t" + str(nb_ignored_files))
    print("Total files:\t" + str(nb_valid_files + nb_missing_files))
#####

# Enforce tagging
#if nb_missing_files > 0:
#    print("Files missing a tag: " + str(nb_missing_files))
#    if show_missing_files == False:
#        print("Call \'python test_tag.py -p\' to list all files with no tags")
Example #31
0
    flag_bit[f[0]] = mask
    for m in flag_name[f[0]]:
        name_mask[m] |= mask

# Print out the flag masks in hex.
#    Assumes tab stops set to 8 characters.
flag_info = ''
for f in sorted(flag_cnt.items()):
    flag_info += "#define\tWT_%s%s%#010x\n" %\
        (f[0],\
        "\t" * max(1, 6 - int((len('WT_') + len(f[0])) / 8)),\
        flag_bit[f[0]])

# Update the wiredtiger.in file with the flags information.
tmp_file = '__tmp'
tfile = open(tmp_file, 'w')
skip = 0
for line in open('../src/include/flags.h', 'r'):
    if skip:
        if line.count('flags section: END'):
            tfile.write('/*\n' + line)
            skip = 0
    else:
        tfile.write(line)
    if line.count('flags section: BEGIN'):
        skip = 1
        tfile.write(' */\n')
        tfile.write(flag_info)
tfile.close()
compare_srcfile(tmp_file, '../src/include/flags.h')
Example #32
0
		# package, so use an uncommon range, specifically, -31,800 to
		# -31,999.
		v = -31800
		for err in api_data.errors:
			if 'undoc' in err.flags:
				tfile.write('/*! @cond internal */\n')
			tfile.write('/*! %s.%s */\n' %
			    (err.desc[0].upper() + err.desc[1:],
			    ''.join('\n * ' + l for l in textwrap.wrap(textwrap.dedent(err.long_desc).strip(), 77)) + '\n' if err.long_desc else ''))
			tfile.write('#define\t%s\t%d\n' % (err.name, v))
			v -= 1
			if 'undoc' in err.flags:
				tfile.write('/*! @endcond */\n')
		tfile.write('/*\n')
tfile.close()
compare_srcfile(tmp_file, '../src/include/wiredtiger.in')

# Output the wiredtiger_strerror code.
tmp_file = '__tmp'
tfile = open(tmp_file, 'w')
tfile.write('''/* DO NOT EDIT: automatically built by dist/api_err.py. */

#include "wt_internal.h"

/*
 * wiredtiger_strerror --
 *	Return a string for any error value.
 */
const char *
wiredtiger_strerror(int error)
{
Example #33
0
    flag_bit[f[0]] = mask
    for m in flag_name[f[0]]:
        name_mask[m] |= mask

# Print out the flag masks in hex.
#    Assumes tab stops set to 8 characters.
flag_info = ''
for f in sorted(flag_cnt.items()):
    flag_info += "#define\tWT_%s%s%#010x\n" %\
        (f[0],\
        "\t" * max(1, 6 - int((len('WT_') + len(f[0])) / 8)),\
        flag_bit[f[0]])

# Update the wiredtiger.in file with the flags information.
tmp_file = '__tmp'
tfile = open(tmp_file, 'w')
skip = 0
for line in open('../src/include/flags.h', 'r'):
    if skip:
        if line.count('flags section: END'):
            tfile.write('/*\n' + line)
            skip = 0
    else:
        tfile.write(line)
    if line.count('flags section: BEGIN'):
        skip = 1
        tfile.write(' */\n')
        tfile.write(flag_info)
tfile.close()
compare_srcfile(tmp_file, '../src/include/flags.h')
Example #34
0
skip = 0
for line in open('../src/include/wiredtiger.in', 'r'):
    if skip:
        if 'Log record declarations: END' in line:
            tfile.write('/*\n' + line)
            skip = 0
    else:
        tfile.write(line)
    if 'Log record declarations: BEGIN' in line:
        skip = 1
        tfile.write(' */\n')
        tfile.write('/*! invalid operation */\n')
        tfile.write('#define\tWT_LOGOP_INVALID\t0\n')
        tfile.write(log_defines)
tfile.close()
compare_srcfile(tmp_file, '../src/include/wiredtiger.in')

#####################################################################
# Create log_auto.c with handlers for each record / operation type.
#####################################################################
f = '../src/log/log_auto.c'
tfile = open(tmp_file, 'w')

tfile.write('/* DO NOT EDIT: automatically built by dist/log.py. */\n')

tfile.write('''
#include "wt_internal.h"

int
__wt_logrec_alloc(WT_SESSION_IMPL *session, size_t size, WT_ITEM **logrecp)
{
Example #35
0
        for err in api_data.errors:
            if 'undoc' in err.flags:
                tfile.write('/*! @cond internal */\n')
            tfile.write(
                '/*!%s.%s */\n' %
                (('\n * ' if err.long_desc else ' ') + err.desc[0].upper() +
                 err.desc[1:], ''.join('\n * ' + l for l in textwrap.wrap(
                     textwrap.dedent(err.long_desc).strip(), 77)) +
                 '\n' if err.long_desc else ''))
            tfile.write('#define\t%s\t%d\n' % (err.name, v))
            v -= 1
            if 'undoc' in err.flags:
                tfile.write('/*! @endcond */\n')
        tfile.write('/*\n')
tfile.close()
compare_srcfile(tmp_file, '../src/include/wiredtiger.in')

# Output the wiredtiger_strerror code.
tmp_file = '__tmp'
tfile = open(tmp_file, 'w')
tfile.write('''/* DO NOT EDIT: automatically built by dist/api_err.py. */

#include "wt_internal.h"

/*
 * wiredtiger_strerror --
 *	Return a string for any error value.
 */
const char *
wiredtiger_strerror(int error)
{
Example #36
0
                tfile.write("/*! @cond internal */\n")
            tfile.write(
                "/*!%s.%s */\n"
                % (
                    ("\n * " if err.long_desc else " ") + err.desc[0].upper() + err.desc[1:],
                    "".join("\n * " + l for l in textwrap.wrap(textwrap.dedent(err.long_desc).strip(), 77)) + "\n"
                    if err.long_desc
                    else "",
                )
            )
            tfile.write("#define\t%s\t%d\n" % (err.name, err.value))
            if "undoc" in err.flags:
                tfile.write("/*! @endcond */\n")
        tfile.write("/*\n")
tfile.close()
compare_srcfile(tmp_file, "../src/include/wiredtiger.in")

# Output the wiredtiger_strerror and wiredtiger_sterror_r code.
tmp_file = "__tmp"
tfile = open(tmp_file, "w")
tfile.write(
    """/* DO NOT EDIT: automatically built by dist/api_err.py. */

#include "wt_internal.h"

/*
 * Historically, there was only the wiredtiger_strerror call because the POSIX
 * port didn't need anything more complex; Windows requires memory allocation
 * of error strings, so we added the WT_SESSION.strerror method. Because we
 * want wiredtiger_strerror to continue to be as thread-safe as possible, errors
 * are split into two categories: WiredTiger's or the system's constant strings