Commit Graph

5 Commits

Author SHA1 Message Date
William S Fulton ebd01b75c0 Remove need for additional %rename for std::function
When using D, JavaScript, Lua, PHP, R

Perhaps some better language specific uses of %namewarn/%keywordwarn
for keyword handling could instead be implemented??
2026-05-03 19:00:24 +01:00
William S Fulton 23a3f1de5b Final fixes and tweaks to std::function wrappers
- Add final CHANGES.current entry for std::function.
- Adjust example to how std::function should work going forwards.
2026-05-03 19:00:24 +01:00
William S Fulton 25475e8c21 Fix partial template specialization for function-typed arguments
Partial template specializations whose argument is a function type
(eg std::function<RET(ARGS...)>) were not matched: the primary template
was chosen instead.

In Source/CParse/templ.c, does_parm_match and resolve_partial_args now
handle function types by decomposing them with SwigType_pop_function
into a return type and a parameter list, recursing on the return type
and matching the argument list with full support for trailing parameter
packs (v.$N absorbing remaining concrete arguments as a parmlist).
The parmlist match/bind logic shared with the existing template-wrapper
case is factored out into two new helpers, match_partial_parmlists and
resolve_partial_arglists, and the template-wrapper branch is refactored
to use them.

Lib/std/std_function.i is updated to use the standard C++ forward
declaration of std::function, and adds %rename(call) for operator() so
target languages that cannot wrap operator() get a usable name.

Assisted-by: Claude Code (Opus 4.7)
2026-05-03 19:00:24 +01:00
William S Fulton d4868b0556 std::function refactor and test improvements
Move std::function implementation out of Lib/typemaps directory noting
that there are no typemaps for the implementation.

Rename _SWIG_call_std_function to SWIG_call_std_function to be standards
compliant.

Remove redundant %rename in cpp11_std_function testcase.

Add java and python runtime tests based on javascript test for cpp11_std_function testcase.

Add some observations on specialization bug when using std::function.
2026-05-03 19:00:24 +01:00
Momtchil Momtchev 379bf1054d Support wrapping std::function
- Split out (keep) std::function wrapping fix from pull request #3298.
- Add clang-format fixes.

Fixes #341.
Partially fixes #3297.

Enhances SwigType_variadic_replace to expand template packs (used in new std_function.i) to generate corrected wrapper code such as:
  SwigValueWrapper< Object< int,int,int > > arg1 ;
instead of incorrect code:
  SwigValueWrapper< Object< int,int ... > > arg1 ;

- Split out std::function wrapping fix from pull request 3298.
- Added clang-format fixes.
2026-05-03 19:00:24 +01:00