MCPcopy Create free account
hub / github.com/Vector35/debugger / OutputSwizzledType

Function OutputSwizzledType

api/python/generator.cpp:169–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167
168
169void OutputSwizzledType(FILE* out, Type* type)
170{
171 switch (type->GetClass())
172 {
173 case BoolTypeClass:
174 fprintf(out, "bool");
175 break;
176 case IntegerTypeClass:
177 fprintf(out, "int");
178 break;
179 case FloatTypeClass:
180 fprintf(out, "float");
181 break;
182 case NamedTypeReferenceClass:
183 if (type->GetNamedTypeReference()->GetTypeReferenceClass() == EnumNamedTypeClass)
184 {
185 string name = type->GetNamedTypeReference()->GetName().GetString();
186 if (name.size() > 16 && name.substr(0, 11) == "_BNDebugger")
187 name = name.substr(3);
188 else if (name.size() > 15 && name.substr(0, 10) == "BNDebugger")
189 name = name.substr(2);
190 else if (name.size() > 15 && name.substr(0, 7) == "BNDebug")
191 name = name.substr(2);
192 else if (name.size() > 2 && name.substr(0, 2) == "BN")
193 name = name.substr(2);
194 fprintf(out, "%sEnum", name.c_str());
195 }
196 else
197 {
198 fprintf(out, "%s", type->GetNamedTypeReference()->GetName().GetString().c_str());
199 }
200 break;
201 case PointerTypeClass:
202 if (type->GetChildType()->GetClass() == VoidTypeClass)
203 {
204 fprintf(out, "Optional[ctypes.c_void_p]");
205 break;
206 }
207 else if ((type->GetChildType()->GetClass() == IntegerTypeClass) &&
208 (type->GetChildType()->GetWidth() == 1) && (type->GetChildType()->IsSigned()))
209 {
210 fprintf(out, "Optional[str]");
211 break;
212 }
213 else if (type->GetChildType()->GetClass() == FunctionTypeClass)
214 {
215 fprintf(out, "ctypes.CFUNCTYPE(");
216 OutputType(out, type->GetChildType()->GetChildType(), true, true);
217 for (auto& i : type->GetChildType()->GetParameters())
218 {
219 fprintf(out, ", ");
220 OutputType(out, i.type);
221 }
222 fprintf(out, ")");
223 break;
224 }
225 fprintf(out, "ctypes.POINTER(");
226 OutputType(out, type->GetChildType());

Callers 1

mainFunction · 0.85

Calls 3

OutputTypeFunction · 0.85
GetNameMethod · 0.80
sizeMethod · 0.80

Tested by

no test coverage detected