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

implement URLPattern #785

Open
wants to merge 128 commits into
base: main
Choose a base branch
from
Open

implement URLPattern #785

wants to merge 128 commits into from

Conversation

anonrig
Copy link
Member

@anonrig anonrig commented Nov 30, 2024

This implements URLPattern from scratch. I'm adding TODO: Optimization opportunity notes in places I think an optimization can be done. The goal is to merge this once there is no TODO: Implement this comments.

TODOs

@anonrig anonrig requested review from lemire and jasnell November 30, 2024 17:53
@anonrig anonrig force-pushed the yagiz/add-url-pattern branch from 89f46f0 to 02492e1 Compare November 30, 2024 18:18
@anonrig anonrig mentioned this pull request Nov 30, 2024
9 tasks
@anonrig anonrig force-pushed the yagiz/add-url-pattern branch from 0ccd6d3 to d2cd4f8 Compare November 30, 2024 22:07
@lemire
Copy link
Member

lemire commented Dec 3, 2024

@anonrig Just to confirm... is this the spec? https://urlpattern.spec.whatwg.org

@anonrig
Copy link
Member Author

anonrig commented Dec 3, 2024

@anonrig Just to confirm... is this the spec? https://urlpattern.spec.whatwg.org

Yes that's correct @lemire

@anonrig anonrig force-pushed the yagiz/add-url-pattern branch 3 times, most recently from e51503f to 524cb73 Compare December 4, 2024 01:29
@anonrig anonrig changed the title implement URLPattern skeleton implement URLPattern Dec 4, 2024
include/ada/url_pattern.h Outdated Show resolved Hide resolved
include/ada/url_pattern.h Outdated Show resolved Hide resolved
include/ada/url_pattern.h Outdated Show resolved Hide resolved
@anonrig anonrig force-pushed the yagiz/add-url-pattern branch from 1a98cc9 to 18ef1a6 Compare December 4, 2024 16:42
@anonrig anonrig requested a review from jasnell December 4, 2024 16:42
@lemire
Copy link
Member

lemire commented Dec 7, 2024

I don't particular mind, but please be aware that you are changing the coding convention. The C++ standard library uses all-lowercase with underscores names. You are using Camel case. If you merge this, it will mean that within the same library, we mix two conventions.

@anonrig anonrig force-pushed the yagiz/add-url-pattern branch 3 times, most recently from 380d57e to 880e260 Compare December 12, 2024 18:06
@anonrig anonrig force-pushed the yagiz/add-url-pattern branch 5 times, most recently from 51690eb to 010bc69 Compare December 12, 2024 21:11
@anonrig
Copy link
Member Author

anonrig commented Dec 12, 2024

@jasnell @lemire would you mind taking a look? we're getting close to the finish line (although the test runner is missing).

@anonrig anonrig force-pushed the yagiz/add-url-pattern branch 2 times, most recently from bf191ce to ce6c27d Compare December 29, 2024 22:11
@anonrig anonrig force-pushed the yagiz/add-url-pattern branch from ce6c27d to e7c580d Compare December 29, 2024 22:21
}

template <url_pattern_encoding_callback F>
Token* url_pattern_parser<F>::try_consume_modifier_token() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are returning a pointer to an instance of Token here. Who owns the Token instance? I recommend documenting it.

}

template <url_pattern_encoding_callback F>
Token* url_pattern_parser<F>::try_consume_regexp_or_wildcard_token(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend documenting who owns the pointer to a Token instance here.

}

template <url_pattern_encoding_callback F>
Token* url_pattern_parser<F>::try_consume_token(token_type type) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend documenting who owns the pointer to a Token instance here.


// @see https://urlpattern.spec.whatwg.org/#pattern-parser
template <url_pattern_encoding_callback F>
class url_pattern_parser {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instance of the template class url_pattern_parser appear to own tokens. We want to make sure that the token pointers never survive beyond the lifetime of their originator.

// Let parser be a new pattern parser whose encoding callback is encoding
// callback and segment wildcard regexp is the result of running generate a
// segment wildcard regexp given options.
auto parser = url_pattern_parser<F>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parser's scope is limited to this function, this means that the pointers to the token we generate within this function only lives for the duration of the function. We need to make sure that this is not a problem. It should be documented that no pointer to a token escapes this function.

@anonrig anonrig force-pushed the yagiz/add-url-pattern branch 2 times, most recently from f76e3ee to c3adedb Compare December 31, 2024 14:49
@anonrig anonrig force-pushed the yagiz/add-url-pattern branch from c3adedb to 674c0bb Compare December 31, 2024 14:51
@anonrig anonrig force-pushed the yagiz/add-url-pattern branch 2 times, most recently from 1e8c75f to 8292933 Compare December 31, 2024 15:24
@anonrig anonrig force-pushed the yagiz/add-url-pattern branch from 8292933 to 3aad757 Compare December 31, 2024 15:29
@anonrig anonrig force-pushed the yagiz/add-url-pattern branch from ccd1734 to c0db9c8 Compare December 31, 2024 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants