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

Header parser explicit constructors support #17017

Merged

Conversation

VadimLevin
Copy link
Contributor

@VadimLevin VadimLevin commented Apr 8, 2020

explicit keyword is removed from the function declaration string.

Resolves: #16988.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under OpenCV (BSD) License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake
allow_multiple_commits=1

@alalek
Copy link
Member

alalek commented Apr 8, 2020

because simple addition of explicit keyword to batch_replace list in parse_func_decl may result to unwanted consequences

Issue is here because Java bindings tests don't cover VideoCapture constructor.
This is why we need bindings tests. They are minimal tests covering these cases:

  • required functionality is wrapped
  • parameters/results/errors/exceptions are properly passed to/from C++.

Validation of bindings generator changes can be performed by comparing generated code with and without the patch. Changes are reviewed manually.

- It is safe to remove `explicit` keyword for constructors with 1
argument, because it is C++ specific keyword and does not affect any of
the generated binding.
@VadimLevin VadimLevin force-pushed the dev/vlevin/header-parser-explicit-support branch from 20226ff to 1d8c73c Compare April 15, 2020 11:28
@VadimLevin
Copy link
Contributor Author

Constructors with explicit keyword are exported.
Verified with:
javap -classpath ./bin/opencv-430.jar org/opencv/videoio/VideoCapture

Output Before:

Compiled from "VideoCapture.java"
public class org.opencv.videoio.VideoCapture {
  protected final long nativeObj;
  protected org.opencv.videoio.VideoCapture(long);
  public long getNativeObjAddr();
  public static org.opencv.videoio.VideoCapture __fromPtr__(long);
  public org.opencv.videoio.VideoCapture();
  public java.lang.String getBackendName();
  public boolean getExceptionMode();
  public boolean grab();
  public boolean isOpened();
  public boolean open(java.lang.String, int);
  public boolean open(java.lang.String);
  public boolean open(int, int);
  public boolean open(int);
  public boolean read(org.opencv.core.Mat);
  public boolean retrieve(org.opencv.core.Mat, int);
  public boolean retrieve(org.opencv.core.Mat);
  public boolean set(int, double);
  public double get(int);
  public void release();
  public void setExceptionMode(boolean);
  protected void finalize() throws java.lang.Throwable;
}

Output after:

Compiled from "VideoCapture.java"
public class org.opencv.videoio.VideoCapture {
  protected final long nativeObj;
  protected org.opencv.videoio.VideoCapture(long);
  public long getNativeObjAddr();
  public static org.opencv.videoio.VideoCapture __fromPtr__(long);
  public org.opencv.videoio.VideoCapture(java.lang.String, int);
  public org.opencv.videoio.VideoCapture(java.lang.String);
  public org.opencv.videoio.VideoCapture(int, int);
  public org.opencv.videoio.VideoCapture(int);
  public org.opencv.videoio.VideoCapture();
  public java.lang.String getBackendName();
  public boolean getExceptionMode();
  public boolean grab();
  public boolean isOpened();
  public boolean open(java.lang.String, int);
  public boolean open(java.lang.String);
  public boolean open(int, int);
  public boolean open(int);
  public boolean read(org.opencv.core.Mat);
  public boolean retrieve(org.opencv.core.Mat, int);
  public boolean retrieve(org.opencv.core.Mat);
  public boolean set(int, double);
  public double get(int);
  public void release();
  public void setExceptionMode(boolean);
  protected void finalize() throws java.lang.Throwable;
}

@VadimLevin VadimLevin changed the title WIP: Tests for header parser Header parser explicit constructors support Apr 15, 2020
@VadimLevin VadimLevin requested a review from alalek April 15, 2020 12:42
Copy link
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Well done! Thank you 👍

Validated through generated code:

  • modules/java_bindings_generator (ctors are restored)
  • modules/python_bindings_generator (no changes)

@opencv-pushbot opencv-pushbot merged commit 98e38b2 into opencv:3.4 Apr 15, 2020
@alalek alalek mentioned this pull request Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some VideoCapture Constructors are missing in OpenCV4.3.0 Java wrapper.
3 participants