| 73 | } |
| 74 | |
| 75 | FunctionResult ClassRegistry::call_method_with_args( |
| 76 | const std::string& qualified_name, |
| 77 | const std::string& method_name, |
| 78 | const FunctionArgs& args) const { |
| 79 | auto it = classes_.find(qualified_name); |
| 80 | if (it == classes_.end()) { |
| 81 | PADDLE_THROW(common::errors::NotFound("Class %s not found in registry!", |
| 82 | qualified_name.c_str())); |
| 83 | } |
| 84 | |
| 85 | auto& class_reg = it->second; |
| 86 | auto method_it = class_reg->methods.find(method_name); |
| 87 | if (method_it == class_reg->methods.end()) { |
| 88 | PADDLE_THROW(common::errors::NotFound("Method %s not found in class %s!", |
| 89 | method_name.c_str(), |
| 90 | qualified_name.c_str())); |
| 91 | } |
| 92 | |
| 93 | try { |
| 94 | VLOG(3) << "Executing " << qualified_name << "::" << method_name |
| 95 | << " (instance) with " << args.size() << " args"; |
| 96 | auto result = method_it->second->call_with_args(args); |
| 97 | |
| 98 | if (result.has_value()) { |
| 99 | VLOG(3) << "Instance method executed successfully with return value"; |
| 100 | } else { |
| 101 | VLOG(3) << "Instance method executed successfully (void)"; |
| 102 | } |
| 103 | return result; |
| 104 | } catch (const std::exception& e) { |
| 105 | VLOG(3) << "Instance method execution failed: " << e.what(); |
| 106 | throw; |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | FunctionResult ClassRegistry::call_method_with_args( |
| 111 | const std::string& qualified_name, |