qface icon indicating copy to clipboard operation
qface copied to clipboard

provide support for defining default values in the interface files

Open jryannel opened this issue 8 years ago • 3 comments

It shall be possible to define default values for properties, struct members, enums, flags. E.g.

int value(10);

or using decorators

@default(10)
int value;

jryannel avatar Dec 07 '16 08:12 jryannel

There shall be a documented rules for the different generators for default values (e.g. int => 0, real => 0.0, string => "". Are default values specific to the generator? For example for python it is True not true. So the IDL would need to define own default value syntax and a destination generator might need to transform them.

jryannel avatar Jan 15 '17 17:01 jryannel

or using assignments:

int value = 0

Seems the easiest one.

struct {
  int value = 0; // define 0 as default value when struct is initialised
  list<string> = [ "hello"] // defines an array of values
}

interface Hello {
  int add(int a=0, int b=1) = 0; // return 0 if not implemented
}

jryannel avatar Feb 03 '17 10:02 jryannel

If we would introduce YAML format for annotations we can use the same format for default values.

int value = 0;
Status status = Status.Loading;

jryannel avatar Mar 29 '17 08:03 jryannel