Skip to content

Add Protected Method Getter in extension.Module #10364

Closed
@zhenyan-zhang-meta

Description

@zhenyan-zhang-meta

Context

This issue is the first step of #9638.

In #9638, we want to have extension.Module as the single source of implementation in pybindings, which means that pybindings.PyModule should use extension.Module rather than its own pybindings.Module.

The issue is that pybindings.PyModule is dependent on the method getter from pybindings.Module, which extension.Module do not have. Since we don't want to expose method getter in extension.Module, we have to protect the getter, wrap the functions that is dependent on it and use the protected getter there, ultimately decouple pybindings from a method getter.

Proposal

Although we are decoupling the method getter from pybindings implementation, method itself is still needed for bundled programs. To keep having the method getter while not exposing it, we can create a protected method getter to confine its usage inside a wrapper class inheriting extension.Module that we are about to create.

// In extension.module
class Module {
    // Everything else keeps same

protected:
  /**
   * Get a method by method name.
   *
   * @param[in] method_name The name of the method to get.
   *
   * @returns A Result object containing either a pointer to the requested
   *          method or an error to indicate failure.
   */
  ET_NODISCARD inline runtime::Result<Method*> get_method(
      const std::string& method_name);
}

Metadata

Metadata

Labels

module: extensionIssues related to code under extension/triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions