bytedeco / javacpp

The missing bridge between Java and native C++
Other
4.46k stars 581 forks source link

Fix parsing of functions parameters in template arguments #693

Closed HGuillemet closed 1 year ago

HGuillemet commented 1 year ago

This PR proposes to call parameters from templateArguments when a function is found in order to correctly pass its prototype.

This solves two issues: the parsing of argument identifiers when present, and the resolution of namespaces.

Example:

namespace ns {
  struct S {
    int x;
  };

  std::function<void(int a)> a;
  std::function<S(S)> b;
}

Before, parsed as:

std::function<void(inta)>
std::function<ns::S(S)>

with the PR:

std::function<void(int)>
std::function<ns::S(ns::S)>

Some presets need to be adjusted to parse correctly with this PR (fixing of std::function parameters):

No changes in other presets. Not tested: libfreenect2, chilitags,hyperscan, tensorflow, ale, ngraph, qt, skia, videoinput, tritonserver, depthai

HGuillemet commented 1 year ago

That logic should probably be in type() instead. But then the returned Type should be able to represent a function type with its arguments (or a function pointer), which requires modifying the Type class.

saudet commented 1 year ago

Yeah, no, I think it's alright like this for now, thanks.

HGuillemet commented 1 year ago

Do you want a PR on javacpp-presets for the corresponding fixes ?

saudet commented 1 year ago

No need to, they'll get fixed when they get updated.