def wrap(func):
@functools.wraps(func, assigned=('<STR_LIT>', '<STR_LIT>'))<EOL>def wrapped(*args):<EOL><INDENT>if len(args) != len(func.argtypes):<EOL><INDENT>logger.warn("<STR_LIT>",<EOL>args, func.argtypes)<EOL><DEDENT>typed_args = []<EOL>for (arg, argtype) in zip(args, func.argtypes):<EOL><INDENT>if argtype == c_char_p:<EOL><INDENT>typed_arg = create_string_buffer(arg)<EOL><DEDENT>else:<EOL><INDENT>if hasattr(argtype, '<STR_LIT>'):<EOL><INDENT>typed_arg = argtype(argtype._type_(arg))<EOL><DEDENT>else:<EOL><INDENT>typed_arg = argtype(arg)<EOL><DEDENT><DEDENT>typed_args.append(typed_arg)<EOL><DEDENT>result = func(*typed_args)<EOL>if hasattr(result, '<STR_LIT>'):<EOL><INDENT>return result.contents<EOL><DEDENT>else:<EOL><INDENT>return result<EOL><DEDENT><DEDENT>return wrapped<EOL>
Return wrapped function with type conversion and sanity checks.