Skip to content

Updating code generating scripts

Ira Rosen edited this page Jan 3, 2017 · 3 revisions

All the scripts and input files can be found in Swift-Kuery/Scripts.

The file runScripts.h contains the script to run all the code generating scripts for Swift-Kuery. Add a new script here in order to run it with:

$ Scripts/runScripts.h
  • simpleOperators.sh generates global operators for simple conditions (listed in SimpleOperators.txt) that return Filter and Having clauses. The file FilterAndHavingTypes.txt contains the list of all the types: each line is (Filter/Having, LHS type, RHS type) - the rest is ignored. A special case here is Bool, that can be used only for equals/not equals operators, therefore, there are different input files for Bool: FilterAndHavingBoolOperators.txt and FilterAndHavingBoolTypes.txt. The generated code is in Sources/SwiftKuery/FilterAndHaving_GlobalFunctions.swift.

  • columnExtensions.sh generates extensions for Column, ScalarColumnExpression and AggregateColumnExpression for (NOT)LIKE, (NOT)BETWEEN, and (NOT)IN operators. The pairs of (Filter/Having, type to extend) are in ColumnExtensionClauses.txt. The file ColumnExtensionOperands.txt contains the types of the operands for (NOT)BETWEEN, and (NOT)IN operators. The generated code is in Sources/SwiftKuery/ColumnAndExpressions_Extensions.swift.

  • specialOperators.sh contains the code for the same operators as columnExtensions.sh (i.e., (NOT)LIKE, (NOT)BETWEEN, and (NOT)IN), but the generated extensions are for Int, Double, String, Bool, Float and Parameter (listed in ColumnExtensionOperands.txt). The generated code is in Sources/SwiftKuery/SpecialOperators_Extensions.swift.

  • subqueries.sh generates global operators with subqueries (i.e. 'expression operator ANY/ALL(subquery)'), and extensions for (NOT)IN operator with a subquery. The operators are listed in SimpleOperators.txt. The types for the operators are in SubqueriesTypes.txt as (Filter/Having, LHS type (the type of the expression), RHS type (a Filter/HavingPredicate for ANY or ALL applied on a subquery). For (NOT)IN operator types we use InSelectTypes.txt. The resulting generated code is in Sources/SwiftKuery/Subqueries_GlobalFunctionsAndExtensions.swift.

  • filterAndHavingExtensions.sh generates extensions for Filter and Having for IS (NOT) NULL operators. The generated code is in FilterAndHaving_Extensions.swift

  • The following scripts generate tests:

    • testSimpleOperators.sh tests the code generated by simpleOperators.sh using the same input files. The generated test is TestFilterAndHaving.swift.
    • testAggregate.sh tests aggregate functions. It creates TestAggregateFunctions.swift.
    • testSpecialOperators.sh tests the code generated by specialOperators.sh using the same input files. The generated test is TestSpecialOperators.swift.
    • testSubqueries.sh tests the code generated by subqueries.sh using the same input files. The generated test is TestSubqueries.swift.
Clone this wiki locally