canon-sdk-java icon indicating copy to clipboard operation
canon-sdk-java copied to clipboard

Add support for macOS

Open mcix opened this issue 1 year ago • 1 comments

Hi Yoann

I am looking into adding support for macOS, I have ran into the following issue.

The NativeLong size is 4 bytes on Windows 64-bit, but on macOS 64-bit this is 8 bytes:

  +---------------------+---------------------+---------------------+
  | Property            | macOS               | Windows             |
  +---------------------+---------------------+---------------------+
  | OS Name             | Mac OS X            | Windows 11          |
  | OS Arch             | aarch64             | amd64               |
  | Java Version        | 17.0.14             | 21.0.1              |
  | JNA Platform        | 0                   | 2                   |
  | Is 64-bit           | true                | true                |
  +---------------------+---------------------+---------------------+
  | NativeLong.SIZE     | 8 bytes             | 4 bytes             |
  +---------------------+---------------------+---------------------+

For example, in EdsdkLibrary.java look at the EdsRetain. I have chosen this one because it has a good description about the return size in the Canon documentation

/**
     * -----------------------------------------------------------------------------<br>
     * //<br>
     * //  Function:   EdsRetain<br>
     * //<br>
     * //  Description:<br>
     * //      Increments the reference counter of existing objects.<br>
     * //<br>
     * //  Parameters:<br>
     * //       In:    inRef - The reference for the item.<br>
     * //      Out:    None<br>
     * //<br>
     * //  Returns:    Any of the sdk errors.<br>
     * -----------------------------------------------------------------------------<br>
     * Original signature : <code>__attribute__((dllimport)) EdsUInt32 EdsRetain(EdsBaseRef)</code><br>
     * <i>native declaration : sdk-header\EDSDK.h:105</i>
     *
     * @param inRef the reference for the item
     * @return any of the sdk errors
     */
    NativeLong EdsRetain(EdsBaseRef inRef);

Description from the Canon EDSDK pdf

Syntax
EdsUInt32 EdsRetain( EdsBaseRef inRef )

Return Values
Returns a reference counter if successful. For errors, returns 0xFFFFFFFF.
The return value is 4 bytes, and the maximum value of the reference counter is 65535.

Changing this is quite a big change, what do you think about this?

Best regards, Arnoud

mcix avatar Nov 27 '25 09:11 mcix

Hi, I have never tested on macOS so it is a bit hard to know. Is NativeLong not abstracting the fact that it is 4 or 8 bytes?

As for the Canon EDSDK max values; this is an unknown without testing. I cannot really help, I have no Canon on hand; I cannot test further on that.

Blackdread avatar Nov 30 '25 22:11 Blackdread