================ @@ -103,24 +139,79 @@ class ScriptedPythonInterface : virtual public ScriptedInterface { "Resulting object is not initialized."); std::apply( - [&method, &expected_return_object](auto &&...args) { + [&init, &expected_return_object](auto &&...args) { llvm::consumeError(expected_return_object.takeError()); - expected_return_object = method(args...); + expected_return_object = init(args...); }, transformed_args); - if (llvm::Error e = expected_return_object.takeError()) - return std::move(e); - result = std::move(expected_return_object.get()); + if (!expected_return_object) + return expected_return_object.takeError(); + result = expected_return_object.get(); } - if (!result.IsValid()) + if (!result.IsValid() || !result.HasAttribute("__class__")) + return llvm::createStringError( + llvm::inconvertibleErrorCode(), + "Resulting object is not a valid Python Object."); + + PythonObject obj_class = result.GetAttributeValue("__class__"); + + PythonString obj_class_name = + obj_class.GetAttributeValue("__name__").AsType<PythonString>(); + + PythonObject object_class_mapping_proxy = + obj_class.GetAttributeValue("__dict__"); + + PythonCallable dict_converter = PythonModule::BuiltinsModule() + .ResolveName("dict") + .AsType<PythonCallable>(); + if (!dict_converter.IsAllocated()) + return llvm::createStringError( + llvm::inconvertibleErrorCode(), + "Resulting object is not a valid Python Object."); + + PythonDictionary object_class_dict = + dict_converter(object_class_mapping_proxy).AsType<PythonDictionary>(); + if (!object_class_dict.IsAllocated()) return llvm::createStringError( llvm::inconvertibleErrorCode(), "Resulting object is not a valid Python Object."); + auto checker_or_err = CheckAbstractMethodImplementation(object_class_dict); + if (!checker_or_err) + return checker_or_err.takeError(); + +#define LOG_ABSTRACT_METHOD_STATUS(state) \ + LLDB_LOG(GetLog(LLDBLog::Script), "Abstract method {0}.{1} " #state ".", \ + obj_class_name.GetString(), method_checker.first) ---------------- bulbazord wrote:
I don't think you need to do preprocessor string concatenation here. I also don't think it's a good idea because it leads to code that looks wrong but isn't, e.g. `LOG_ABSTRACT_METHOD_STATUS(not implemented)` doesn't look like valid C++ until you look at the macro. https://github.com/llvm/llvm-project/pull/71260 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits