0

Is this code valid in Djinni, and some_record can be generated for objective c?

some_service = interface +c 
{
    do_some_action(): bool;
}

some_record = record 
{
    service: optional< some_service >;
}
Megamozg
  • 975
  • 9
  • 15
  • 1
    Can't you just try to run the djinni stuff and see if it accepts your snippet? – skypjack Jun 22 '18 at 06:48
  • @skypjack Unfortunately, can't check it for objective c code generation. – Megamozg Jun 22 '18 at 07:01
  • 1
    Why not? Even if you can't build the ObjC code because you're on Linux or something, you can still generate it, and Djinni won't generally let you generate invalid code. – Andrew Jun 23 '18 at 04:18

1 Answers1

1

It seems simple and valid to me (though without trying it I'm not confident there's not a gotcha case I'm missing.

Note that optional interfaces are pretty meaningless in Djinni unless you're also using non-nullable pointer support (see the cpp-nn-* arguments). Those depend on using a non-nullable template in C++ such as nn<> Without that, interfaces are all nullable by default anyway. With nn enabled, interfaces are non-nullable by default, and optional ends up as the nullable version.

Jon McClung
  • 1,619
  • 20
  • 28
Andrew
  • 1,073
  • 7
  • 6
  • Even though it actually seems valid it doesn't compile on mac os. Thank you for notice about meaningless optional interfaces. – Megamozg Jul 02 '18 at 05:00
  • Given optional interfaces aren't useful without nn<> it's quite possible it's a case we haven't tested and thus broke at some point. You're welcome to submit an issue on GitHub with a test case which demos it, or even better a PR to fix it, if you think you still want to use this particular feature. – Andrew Jul 03 '18 at 19:09