def gen_client (templates): for name, value in ops.items(): if name == 'getspec': # It's not real if it doesn't have a stub function. continue print(generate(templates['cbk'], name, cbk_subs)) print(generate(templates['cont-func'], name, fop_subs)) print(generate(templates['fop'], name, fop_subs))
def gen_cases(): code = "" for name, value in ops.items(): if "journal" not in [x[0] for x in value]: continue # Add the CASE fragment for this fop. code += generate(fragments["CASE"], name, fop_subs) return code
def gen_functions(): code = "" for name, value in ops.items(): if "journal" not in [x[0] for x in value]: continue fop_subs[name]["@FUNCTION_BODY@"] = get_special_subs(value) # Print the FOP fragment with @FUNCTION_BODY@ in the middle. code += generate(fragments["FOP"], name, fop_subs) return code
def gen_functions(): code = "" for name, value in ops.items(): fop_type = [x[1] for x in value if x[0] == "journal"] if not fop_type: continue body, links, syncop_args, cleanups = get_special_subs( name, value, fop_type[0]) fop_subs[name]["@FUNCTION_BODY@"] = body fop_subs[name]["@LINKS@"] = links fop_subs[name]["@SYNCOP_ARGS@"] = syncop_args fop_subs[name]["@CLEANUPS@"] = cleanups if name == "writev": # Take advantage of the fact that, *during reconciliation*, the # vector is always a single element. In normal I/O it's not. fop_subs[name]["@SUCCESS_VALUE@"] = "vector.iov_len" else: fop_subs[name]["@SUCCESS_VALUE@"] = "GFAPI_SUCCESS" # Print the FOP fragment with @FUNCTION_BODY@ in the middle. code += generate(fragments["FOP"], name, fop_subs) return code
def gen_fdl(): entrypoints = [] for name, value in ops.items(): if "journal" not in [x[0] for x in value]: continue # generate all functions for all the fops # except for the ones in selective_generate for which # generate only the functions mentioned in the # selective_generate table gen_funcs = "len,serialize,callback,continue,fop" if name in selective_generate: gen_funcs = selective_generate[name].split(",") len_code, ser_code = get_special_subs(value) fop_subs[name]["@LEN_CODE@"] = len_code[:-1] fop_subs[name]["@SER_CODE@"] = ser_code[:-1] if 'len' in gen_funcs: print(generate(LEN_TEMPLATE, name, fop_subs)) if 'serialize' in gen_funcs: print(generate(SER_TEMPLATE, name, fop_subs)) if name == 'writev': print("#define DESTAGE_ASYNC") if 'callback' in gen_funcs: print(generate(CBK_TEMPLATE, name, cbk_subs)) if 'continue' in gen_funcs: print(generate(CONTINUE_TEMPLATE, name, fop_subs)) if 'fop' in gen_funcs: print(generate(FOP_TEMPLATE, name, fop_subs)) if name == 'writev': print("#undef DESTAGE_ASYNC") entrypoints.append(name) print("struct xlator_fops fops = {") for ep in entrypoints: print("\t.%s = fdl_%s," % (ep, ep)) print("};")
def gen_defaults(): for name, value in ops.items(): if name == 'getspec': continue print(generate(OP_FOP_TEMPLATE, name, fop_subs))
def gen_defaults(): for name, value in ops.items(): if name in utime_ops: print(generate(OP_FOP_TEMPLATE, name, fop_subs))