ada icon indicating copy to clipboard operation
ada copied to clipboard

C API for URLPattern

Open bungle opened this issue 10 months ago • 3 comments

What is the problem this feature will solve?

Is it possible to add C API for the recently added URLPattern?

What is the feature you are proposing to solve the problem?

It is in general a bit easier to interface with C API from other languages.

What alternatives have you considered?

Not yet any.

bungle avatar Feb 13 '25 20:02 bungle

I'm not sure what is the correct approach to add a C API and also use a template argument for the regex engine.

anonrig avatar Feb 13 '25 20:02 anonrig

I think you would add declarations for specific instances of the template function, right?

Once there are C bindings I can add Python calls for ada-python.

bbayles avatar Feb 13 '25 20:02 bbayles

@bbayles The challenge is that we do not provide the regular expression engine. The user must provide it.

Our implementation of URLPattern is not self-sufficient. It provides everything but the regex engine.

The standard C++ regex engine is a variation on ECMAScript, but not a proper ECMAScript implementation. Furthermore, it is unsafe. See my blog post: https://lemire.me/blog/2025/01/25/regular-expressions-can-blow-up/

You need a regex engine that supports the full ECMAScript regex specification in a safe manner. We do not have that in the library. So when Node.js uses URLPattern, they provide the regex engine.

I think you would add declarations for specific instances of the template function, right?

Yes, given a proper regex engine, which we do not have.

lemire avatar Feb 13 '25 21:02 lemire