|
An IDL file like the following will produce C++ code that cannot compile:
structs:
|
int_basic_ranges:
|
description: Struct using basic range validators on ints
|
fields:
|
positive_int:
|
type: int
|
validator: { gt: 0 }
|
|
chained_callback_validators:
|
description: Uses a chained struct that includes fields with validators
|
chained_structs:
|
int_basic_ranges: int_basic_ranges
|
The generated Chained_callback_validators class will define the required validatePositive_int() method in its cpp file, but it will not declare the method in its header, leading to a compilation error.
The following rule in generator.py's _CppHeaderFileWriter.generate is to blame:
if [field for field in struct.fields if field.validator]:
|
self.write_unindented_line('private:')
|
for field in struct.fields:
|
if not field.ignore and not struct.immutable and \
|
not field.chained_struct_field and field.validator:
|
self.gen_validators(field)
|
We have no IDL structs today that include structs with field validators. (I discovered the problem while creating such a struct, then changed my mind about whether I needed that struct.) Let's fix the bug anyway, while we understand it.
|