dropbox / djinni

A tool for generating cross-language type declarations and interface bindings.
Apache License 2.0
2.88k stars 487 forks source link

Constant values are not being generated #403

Closed lordzsolt closed 6 years ago

lordzsolt commented 6 years ago

Based on the documentation, and based on #354, I had the impression that I should be able to generate constants with values.

However, with the following .djinni file

Foo = interface +c {
    static version(): string;

    const major_version: i32 = 0;
    const minor_version: i32 = 1;
    const patch_version: i32 = 0;
}

The following .hpp is generated:

class PROJECT_EXPORT Foo {
public:
    virtual ~Foo() {}

    static int32_t const MAJOR_VERSION;

    static int32_t const MINOR_VERSION;

    static int32_t const PATCH_VERSION;
}

And I have to define the values in some implementation in order to not get linked error.

Looking at the code in #354, my understanding is this

constants_interface = interface +c {
    const i8_constant: i8 = 1;
    const i16_constant: i16 = 2;
    # i32_constant has documentation.
    const i32_constant: i32 = 3;
}

is supposed to generate this

class ConstantsInterface {
public:
    virtual ~ConstantsInterface() {}

    static constexpr int8_t I8_CONSTANT = 1;

    static constexpr int16_t I16_CONSTANT = 2;

    /** i32_constant has documentation. */
    static constexpr int32_t I32_CONSTANT = 3;
}

Any suggestions on what I might be missing?

lordzsolt commented 6 years ago

Figured it out, we were using an internal version of Djinni 🤦‍♂️ cause "reasons".