(method, classname, out, wow64)
| 1030 | |
| 1031 | |
| 1032 | def handle_method_cpp(method, classname, out, wow64): |
| 1033 | returns_void = method.result_type.kind == TypeKind.VOID |
| 1034 | returns_record = method.result_type.get_canonical().kind == TypeKind.RECORD |
| 1035 | prefix = "wow64_" if wow64 else "" |
| 1036 | |
| 1037 | names = [p.spelling if p.spelling != "" else f'_{chr(0x61 + i)}' |
| 1038 | for i, p in enumerate(method.get_arguments())] |
| 1039 | path_conv_wtou = PATH_CONV_METHODS_WTOU.get(f'{klass.name}_{method.spelling}', {}) |
| 1040 | outstr_param = OUTSTR_PARAMS.get(method.name, None) |
| 1041 | |
| 1042 | need_convert = {n: p for n, p in zip(names, method.get_arguments()) |
| 1043 | if param_needs_conversion(p, wow64) and n != outstr_param |
| 1044 | and n not in path_conv_wtou} |
| 1045 | manual_convert = {n: p for n, p in zip(names, method.get_arguments()) |
| 1046 | if underlying_type(p).spelling in MANUAL_TYPES |
| 1047 | or p.spelling in MANUAL_PARAMS} |
| 1048 | |
| 1049 | names = ['u_iface'] + names |
| 1050 | |
| 1051 | out(f'NTSTATUS {prefix}{method.full_name}( void *args )\n') |
| 1052 | out(u'{\n') |
| 1053 | out(f' struct {prefix}{method.full_name}_params *params = (struct {prefix}{method.full_name}_params *)args;\n') |
| 1054 | out(f' struct u_{klass.full_name} *iface = (struct u_{klass.full_name} *)params->u_iface;\n') |
| 1055 | if method.name in OUTSTR_PARAMS and OUTSTR_PARAMS[method.name] in names: |
| 1056 | out(u' char *u_str;\n') |
| 1057 | |
| 1058 | params = list(zip(names[1:], method.get_arguments())) |
| 1059 | for i, (name, param) in enumerate(params[:-1]): |
| 1060 | if underlying_type(param).kind != TypeKind.RECORD: |
| 1061 | continue |
| 1062 | next_name, next_param = params[i + 1] |
| 1063 | if not any(w in next_name.lower() for w in ('count', 'len', 'size', 'num')): |
| 1064 | continue |
| 1065 | assert underlying_typename(param) in SIZED_STRUCTS | EXEMPT_STRUCTS |
| 1066 | |
| 1067 | for i, (name, param) in enumerate(params[1:]): |
| 1068 | if underlying_type(param).kind != TypeKind.RECORD: |
| 1069 | continue |
| 1070 | prev_name, prev_param = params[i - 1] |
| 1071 | if not any(w in prev_name.lower() for w in ('count', 'len', 'size', 'num')): |
| 1072 | continue |
| 1073 | if underlying_typename(param) not in SIZED_STRUCTS | EXEMPT_STRUCTS: |
| 1074 | print('Warning:', underlying_typename(param), name, 'following', prev_name) |
| 1075 | |
| 1076 | for name, conv in filter(lambda x: x[0] in names, path_conv_wtou.items()): |
| 1077 | if conv['array']: |
| 1078 | out(f' const char **u_{name} = {prefix}steamclient_dos_to_unix_path_array( params->{name} );\n') |
| 1079 | else: |
| 1080 | out(f' char *u_{name} = steamclient_dos_to_unix_path( params->{name}, {int(conv["url"])} );\n') |
| 1081 | |
| 1082 | wow64_convert = {} |
| 1083 | need_output = {} |
| 1084 | |
| 1085 | for name, param in sorted(need_convert.items()): |
| 1086 | if param.type.kind != TypeKind.POINTER: |
| 1087 | out(f' {declspec(param.type, f"u_{name}", "u_")} = params->{name};\n') |
| 1088 | continue |
| 1089 |
no test coverage detected