Currently we call el_set directly to configure the editor in the libedit wrapper. There are some cases in which this causes extra casting, but we pass captureless lambdas as function pointers, which should work out of the box. Since el_set takes varargs, if the cast is incorrect or if the cast is not present, it causes a run time failure rather than compile error. This change makes it so a few different types of configuration is done inside a helper function to provide type safety and eliminate that casting. I didn't do all edit line configuration because I'm not sure how important it was in other cases and it might require something more general keep up with libedit's signature. I'm open to suggestions, though.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
LGTM, thanks!
I can to land this for you, but first let's wait a bit to see if anyone else has any comments.
LGTM. I wonder if we would want to wrap this in a macro to get rid of the EditLineConstString duplication while keeping the type safety.
Thanks! I looked into removing the EditLineConstString, but I wasn't a fan of having two preprocessor macro expansions. Maybe it could be a template function wchar_t or char. I also tried some template specialization where the functions to call into the edit line library could be instantiated when used, but it didn't really appear to save much because all the method signatures for edit line parameters have to be manually maintained, and some of them still take varargs even after specifying the edit line op parameter., e.g.:
template<int N> void editLineCaller();
template<>
void editLineCaller<EL_ADDFN>(param1Type param1, param2Type param2) {
el_set(EL_ADFN, param1, param2);
. . .
}
Friendly ping - let me know if I misunderstood the comments or if anything else is needed! Thanks again.
Thanks for the explanation, I don't have a strong opinion on the matter and the current patch is an improvement so let's ship it.