Emscripten: How to define webidl for C++ array type

454 Views Asked by At

Hi I'm trying to convert the QR library quirc to WASM. For that I wrote a C++ wrapper such that I can use webIDL to make the conversion more straight forward. However I am having troubles with defining array types in webIDL. What would be correct webIDL for the next snippet

        struct Point {
            int x;
            int y;
        };

        struct Code {
            /* The four corners of the QR-code, from top left, clockwise */
            Point corners[4];

            /* The number of cells across in the QR-code. The cell bitmap
            * is a bitmask giving the actual values of cells. If the cell
            * at (x, y) is black, then the following bit is set:
            *
            *     cell_bitmap[i >> 3] & (1 << (i & 7))
            *
            * where i = (y * size) + x.
            */
            int         size;
            uint8_t     cell_bitmap[QUIRC_MAX_BITMAP];
        };

1

There are 1 best solutions below

0
On

The below idl file works

interface Point {
    attribute long x;
    attribute long y;
};

interface Code {
    [Value] attribute Point[] corners;
    attribute long size;
    [BoundsChecked] attribute byte[] cell_bitmap;
};