# type

Deals with target type declaration and defines target class which supports typed targets.

1. `rule register ( type : suffixes * : base-type ? )`

   Registers a target type, possible derived from a `base-type`. Providing a list of suffixes here is a shortcut for separately calling the register-suffixes rule with the given suffixes and the set-generated-target-suffix rule with the first given suffix.

2. `rule register-suffixes ( suffixes + : type )`

   Specifies that files with suffix from `suffixes` be recognized as targets of type `type`. Issues an error if a different type is already specified for any of the suffixes.

3. `rule registered ( type )`

   Returns true iff type has been registered.

4. `rule validate ( type )`

   Issues an error if `type` is unknown.

5. `rule set-scanner ( type : scanner )`

   Sets a scanner class that will be used for this type.

6. `rule get-scanner ( type : property-set )`

   Returns a scanner instance appropriate to `type` and `property-set`.

7. `rule base ( type )`

   Returns a base type for the given type or nothing in case the given type is not derived.

8. `rule all-bases ( type )`

   Returns the given type and all of its base types in order of their distance from type.

9. `rule all-derived ( type )`

   Returns the given type and all of its derived types in order of their distance from type.

10. `rule is-derived ( type base )`

    Returns true if `type` is equal to `base` or has `base` as its direct or indirect base.

11. `rule set-generated-target-suffix ( type : properties * : suffix )`

    Sets a file suffix to be used when generating a target of `type` with the specified properties. Can be called with no properties if no suffix has already been specified for the `type`. The `suffix` parameter can be an empty string (`""`) to indicate that no suffix should be used.

    Note that this does not cause files with `suffix` to be automatically recognized as being of `type`. Two different types can use the same suffix for their generated files but only one type can be auto-detected for a file with that suffix. User should explicitly specify which one using the register-suffixes rule.

12. `rule change-generated-target-suffix ( type : properties * : suffix )`

    Change the suffix previously registered for this type/properties combination. If suffix is not yet specified, sets it.

13. `rule generated-target-suffix ( type : property-set )`

    Returns the suffix used when generating a file of `type` with the given properties.

14. `rule set-generated-target-prefix ( type : properties * : prefix )`

    Sets a target prefix that should be used when generating targets of `type` with the specified properties. Can be called with empty properties if no prefix for `type` has been specified yet.

    The `prefix` parameter can be empty string (`""`) to indicate that no prefix should be used.

    Usage example: library names use the `"lib"` prefix on unix.

15. `rule change-generated-target-prefix ( type : properties * : prefix )`

    Change the prefix previously registered for this type/properties combination. If prefix is not yet specified, sets it.

16. `rule generated-target-prefix ( type : property-set )`

    Returns the prefix used when generating a file of `type` with the given properties.

17. `rule type ( filename )`

    Returns file type given its name. If there are several dots in filename, tries each suffix. E.g. for name of "file.so.1.2" suffixes "2", "1", and "so" will be tried.