Swift codegen: add predicate properties

Properties marked with `predicate` in the schema are now accepted.

* in the dbscheme, they will translate to a table with a single `id`
  column (and the table name will not be pluralized)
* in C++ classes, they will translate to `bool` fields
* in QL classes, they will translate to predicates

Closes https://github.com/github/codeql-c-team/issues/1016
This commit is contained in:
Paolo Tranquilli
2022-05-09 17:50:49 +02:00
parent effa9ee207
commit c08e6fdc1e
17 changed files with 179 additions and 60 deletions

View File

@@ -92,6 +92,17 @@ def test_class_with_field(generate, type, expected, property_cls, optional, repe
]
def test_class_with_predicate(generate):
assert generate([
schema.Class(name="MyClass", properties=[schema.PredicateProperty("prop")]),
]) == [
cpp.Class(name="MyClass",
fields=[cpp.Field("prop", "bool", trap_name="MyClassProp", is_predicate=True)],
trap_name="MyClasses",
final=True)
]
@pytest.mark.parametrize("name",
["start_line", "start_column", "end_line", "end_column", "index", "num_whatever", "width"])
def test_class_with_overridden_unsigned_field(generate, name):