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

Feature-Request JNAerator 0.12 - support for JavaDoc style code comments, fix misuse of JD style #481

Closed
zsawyer opened this issue Mar 5, 2014 · 1 comment

Comments

@zsawyer
Copy link

zsawyer commented Mar 5, 2014

I like JavaDoc and am therefore using it in my C and C++ programs too. It works well, I can even generate (i.e. HTML) documentation using doxygen.

This is my C-Code:

    /**
     * sets and commits the identity
     *
     * Notice: The identity does not need to be updated every single frame. It
     * shouldn't change more than a few times per second if at all during a game.
     *
     *      see <code>setIdentity(...)</code> for details
     *
     * @param identity  unique id of the user in a given context
     *
     * @return  an error code, see <code>enum LINKAPI_ERROR_CODE</code>
     */
    LINKAPI_API
    LINKAPI_ERROR_CODE commitIdentity(const wchar_t identity[LINKAPI_MAX_IDENTITY_LENGTH]);

It is transferred into this (BridJ):

    /**
     * Original signature : <code>LINKAPI_ERROR_CODE setIdentity(const wchar_t[256])</code><br>
     * <i>native declaration : line 230</i>
     */
    native public static IntValuedEnum<LinkAPILibrary.LINKAPI_ERROR_CODE > setIdentity(Pointer<Character > identity);

I now have 2 problems:

  1. As the interface is part of an API that I want to distribute, it needs the documentation. But it was not transferred.
  2. Instead of the original documentation comments JNAerator generates a comment (which is also useful) about the original code. But it uses JavaDoc /** syntax.

To get my documentation to work and still keep the information of the origin (which the end user might not care about). I Manually edit and paste the JD-comment over from the C-code.

This is my result:

    /**
     * sets and commits the identity
     *
     * Notice: The identity does not need to be updated every single frame. It
     * shouldn't change more than a few times per second if at all during a game.
     *
     *      see <code>setIdentity(...)</code> for details
     *
     * @param identity  unique id of the user in a given context
     *
     * @return  an error code, see <code>enum LINKAPI_ERROR_CODE</code>
     */
    /*
     * Original signature : <code>LINKAPI_ERROR_CODE setIdentity(const wchar_t[256])</code><br>
     * <i>native declaration : line 230</i>
     */
    native public static IntValuedEnum<LinkAPILibrary.LINKAPI_ERROR_CODE > setIdentity(Pointer<Character > identity);

Note how it is not one comment but 2 and the BridJ comment was changed to use normal comment syntax (/*).

So I have 2 requests:

  1. Please have JNAerator reuse the JavaDoc type comments (already seems to work for enums).
  2. Please format the JNAerator comments to use /* instead of /** - This may be conditional to when JavaDoc comments are present and 1. was applied, but could in my opinion be done always
ochafik added a commit that referenced this issue Apr 27, 2014
… declaration, and remove leading * in oxygen comment lines (issue #481)
@ochafik
Copy link
Member

ochafik commented Apr 27, 2014

Hi @zsawyer,

Thanks for your detailed feature request, much appreciated!
JNAerator was already meant to reuse existing comments, but it turns out the comment-detection logic was a bit too conservative (it failed to go up two lines above a declaration to fetch its comments as in your example).
I've updated it so your example works fine (latest 0.12-SNAPSHOT), although I didn't follow your suggestion of 2) (I assume you meant to separate JNAerator's "original signature" comment in /* */ format from the original javadoc in /** */ format, but I'd much rather merge the two in a single comment instead so they both appear in the resulting javadoc).
Cheers

@ochafik ochafik closed this as completed Apr 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants