From c41f264a1dba68c89b4a224a70e3a5783f7fa879 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Tue, 24 Jun 2025 17:55:48 -0400 Subject: Remove implicit conversions from Confidence to underlying type, these can cause bugs and also issues with C++20 --- python/generator.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'python/generator.cpp') diff --git a/python/generator.cpp b/python/generator.cpp index 626efa12..3fdd2fe4 100644 --- a/python/generator.cpp +++ b/python/generator.cpp @@ -138,21 +138,21 @@ void OutputType(FILE* out, Type* type, bool isReturnType = false, bool isCallbac else if (type->GetChildType()->GetClass() == FunctionTypeClass) { fprintf(out, "ctypes.CFUNCTYPE("); - OutputType(out, type->GetChildType()->GetChildType(), true, true); + OutputType(out, type->GetChildType()->GetChildType().GetValue(), true, true); for (auto& i : type->GetChildType()->GetParameters()) { fprintf(out, ", "); - OutputType(out, i.type); + OutputType(out, i.type.GetValue()); } fprintf(out, ")"); break; } fprintf(out, "ctypes.POINTER("); - OutputType(out, type->GetChildType()); + OutputType(out, type->GetChildType().GetValue()); fprintf(out, ")"); break; case ArrayTypeClass: - OutputType(out, type->GetChildType()); + OutputType(out, type->GetChildType().GetValue()); fprintf(out, " * %" PRId64, type->GetElementCount()); break; default: @@ -203,21 +203,21 @@ void OutputSwizzledType(FILE* out, Type* type) else if (type->GetChildType()->GetClass() == FunctionTypeClass) { fprintf(out, "ctypes.CFUNCTYPE("); - OutputType(out, type->GetChildType()->GetChildType(), true, true); + OutputType(out, type->GetChildType()->GetChildType().GetValue(), true, true); for (auto& i : type->GetChildType()->GetParameters()) { fprintf(out, ", "); - OutputType(out, i.type); + OutputType(out, i.type.GetValue()); } fprintf(out, ")"); break; } fprintf(out, "ctypes.POINTER("); - OutputType(out, type->GetChildType()); + OutputType(out, type->GetChildType().GetValue()); fprintf(out, ")"); break; case ArrayTypeClass: - OutputType(out, type->GetChildType()); + OutputType(out, type->GetChildType().GetValue()); fprintf(out, " * %" PRId64, type->GetElementCount()); break; default: @@ -394,7 +394,7 @@ int main(int argc, char* argv[]) } else fprintf(out, "\t\t(\"%s\", ", j.name.c_str()); - OutputType(out, j.type); + OutputType(out, j.type.GetValue()); fprintf(out, "),\n"); } fprintf(out, "\t]\n"); @@ -459,7 +459,7 @@ int main(int argc, char* argv[]) fprintf(out, "# %s\n\n", funcName.c_str()); fprintf(out, "%s = core.%s\n", funcName.c_str(), name.c_str()); fprintf(out, "%s.restype = ", funcName.c_str()); - OutputType(out, i.second->GetChildType(), true, callbackConvention); + OutputType(out, i.second->GetChildType().GetValue(), true, callbackConvention); fprintf(out, "\n"); if (!i.second->HasVariableArguments()) { @@ -472,11 +472,11 @@ int main(int argc, char* argv[]) // BNFreeString expects a pointer to a string allocated by the core, so do not use // a c_char_p here, as that would be allocated by the Python runtime. This can // be enforced by outputting like a return value. - OutputType(out, j.type, true); + OutputType(out, j.type.GetValue(), true); } else { - OutputType(out, j.type); + OutputType(out, j.type.GetValue()); } fprintf(out, ",\n"); } @@ -521,16 +521,16 @@ int main(int argc, char* argv[]) fprintf(out, "\n\t\t"); fprintf(out, "%s: ", argName.c_str()); if (swizzleArgs) - OutputSwizzledType(out, arg.type); + OutputSwizzledType(out, arg.type.GetValue()); else - OutputType(out, arg.type); + OutputType(out, arg.type.GetValue()); argN++; } } fprintf(out, "\n\t\t) -> "); if (stringResult || pointerResult) fprintf(out, "Optional["); - OutputSwizzledType(out, i.second->GetChildType()); + OutputSwizzledType(out, i.second->GetChildType().GetValue()); if (stringResult || pointerResult) fprintf(out, "]"); fprintf(out, ":\n"); -- cgit v1.3.1