I define a C++ interface with djinni:
member = interface +c {
get_id(): string;
get_name(): string;
}
My inherited implementation uses const getters, i.e.
class MyMemeber: public Member {
private:
string id;
string name;
public:
string get_id() const override { return id; }
string get_name() const override { return name; }
}
This obviously fails to compile, because of const
attribute. Can I teach djinni to generate the base interface with const getters, too?
It is nowhere documented though from the very beginning djinni generates const methods (line 295 of src/source/CppGenerator.scala). Just add const in front of method signature in idl file:
member = interface +c {
const get_id(): string;
const get_name(): string;
}
I think it would be good idea to pull request tests for this feature (and some docs), currently only const fields are tested.