| 64 | |
| 65 | |
| 66 | void OutputType(FILE* out, Type* type, bool isReturnType = false, bool isCallback = false) |
| 67 | { |
| 68 | switch (type->GetClass()) |
| 69 | { |
| 70 | case BoolTypeClass: |
| 71 | fprintf(out, "ctypes.c_bool"); |
| 72 | break; |
| 73 | case IntegerTypeClass: |
| 74 | switch (type->GetWidth()) |
| 75 | { |
| 76 | case 1: |
| 77 | if (type->IsSigned()) |
| 78 | fprintf(out, "ctypes.c_byte"); |
| 79 | else |
| 80 | fprintf(out, "ctypes.c_ubyte"); |
| 81 | break; |
| 82 | case 2: |
| 83 | if (type->IsSigned()) |
| 84 | fprintf(out, "ctypes.c_short"); |
| 85 | else |
| 86 | fprintf(out, "ctypes.c_ushort"); |
| 87 | break; |
| 88 | case 4: |
| 89 | if (type->IsSigned()) |
| 90 | fprintf(out, "ctypes.c_int"); |
| 91 | else |
| 92 | fprintf(out, "ctypes.c_uint"); |
| 93 | break; |
| 94 | default: |
| 95 | if (type->IsSigned()) |
| 96 | fprintf(out, "ctypes.c_longlong"); |
| 97 | else |
| 98 | fprintf(out, "ctypes.c_ulonglong"); |
| 99 | break; |
| 100 | } |
| 101 | break; |
| 102 | case FloatTypeClass: |
| 103 | if (type->GetWidth() == 4) |
| 104 | fprintf(out, "ctypes.c_float"); |
| 105 | else |
| 106 | fprintf(out, "ctypes.c_double"); |
| 107 | break; |
| 108 | case NamedTypeReferenceClass: |
| 109 | if (type->GetNamedTypeReference()->GetTypeReferenceClass() == EnumNamedTypeClass) |
| 110 | { |
| 111 | string name = type->GetNamedTypeReference()->GetName().GetString(); |
| 112 | if (name.size() > 16 && name.substr(0, 11) == "_BNDebugger") |
| 113 | name = name.substr(3); |
| 114 | else if (name.size() > 15 && name.substr(0, 10) == "BNDebugger") |
| 115 | name = name.substr(2); |
| 116 | else if (name.size() > 15 && name.substr(0, 7) == "BNDebug") |
| 117 | name = name.substr(2); |
| 118 | else if (name.size() > 2 && name.substr(0, 2) == "BN") |
| 119 | name = name.substr(2); |
| 120 | fprintf(out, "%sEnum", name.c_str()); |
| 121 | } |
| 122 | else |
| 123 | { |
no test coverage detected