Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify "named intercept" #1585

Merged
merged 9 commits into from
Jan 30, 2024
Merged

Simplify "named intercept" #1585

merged 9 commits into from
Jan 30, 2024

Commits on Jan 29, 2024

  1. Drive-by Cleanup: Rename serilaizedArgs -> args.

    The fact that they are serialized is implied by the type, `JsValue`, which always contains a serialized value.
    kentonv committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    31fb73a View commit details
    Browse the repository at this point in the history
  2. Drive-by Cleanup: Remove misleading kj::mv.

    `setV8Serialized()` is a capnp data setter. It will always make a copy, it does not take ownership.
    
    Also add a comment about avoiding the redundant copy in the future.
    kentonv committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    3b1a813 View commit details
    Browse the repository at this point in the history
  3. Delete: Remove ability to enumerate named intercept keys.

    This functionality is not used by JS RPC as we have no way to know in advance what methods actually exist at the remote end. Moreover, methods of a class are normally not expected to be enumerable anyway, so even if it could know what methods exist, it'd still be returning an empty list here.
    
    Since JS RPC is the only anticipated use case for named intercept at this time, I'd rather remove this unused functionality for now, to simplify further refactoring. We can bring it back in the future if a use case is found.
    kentonv committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    eabe13c View commit details
    Browse the repository at this point in the history
  4. Cleanup: Remove NamedIntercept class.

    There's no longer any need to inherit this. JSG_NAMED_INTERCEPT works fine without it, since it always invokes `getNamed()` directly on the particular subclass via templates.
    kentonv committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    f3020e0 View commit details
    Browse the repository at this point in the history
  5. Refactor: Allow JSG_NAMED_INTERCEPT to specify the method name.

    This makes the identifier `getNamed` no longer magic. Instead, the caller specifies whatever name they want.
    kentonv committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    d689db2 View commit details
    Browse the repository at this point in the history
  6. Refactor: Allow named intercept method to return any type.

    The type is wrapped just like the return value of any function would be.
    kentonv committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    e93bcfc View commit details
    Browse the repository at this point in the history
  7. Cleanup: Use liftKj in NamedInterceptorCallbacks.

    The named intercept callback is essentially the same as what `GetterCallback` handles, except with a name passed in. Aside from handling the name, there's no reason this code should be different from `GetterCallback`.
    kentonv committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    a5bff51 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    7bc97fe View commit details
    Browse the repository at this point in the history
  9. Rename: "Named intercept" -> "wildcard property"

    I think this is a much more intuitive name.
    kentonv committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    3d8789d View commit details
    Browse the repository at this point in the history