简体   繁体   中英

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

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];
        };

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;
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM