text: # Copyright 2020 Victor Sales
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #      https://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  import itertools
  import pathlib
  import sys
  
  all_idxs = [
      ['x', 'y', 'z', 'w'],
      ['r', 'g', 'b', 'a'],
      ['s', 't', 'p', 'q'],
  ]
  
  vec_n = int(sys.argv[1])
  
  all_idxs = [idxs[:vec_n] for idxs in all_idxs]
  index_map = {i: n for idxs in all_idxs for n, i in enumerate(idxs)}
  
  # License boilerplate
  out = """// Copyright 2020 Victor Sales
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //      https://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  """
  
  file_name = pathlib.Path(__file__).name
  out += f'\n// Code auto generated by ${{VSCGE_SOURCE_ROOT}}/tool/{file_name}\n\n'
  
  for idxs in all_idxs:
      for i in range(4):
          combinations = itertools.product(idxs, repeat=i+1)
          for combination in combinations:
              swizzle_indexes = [index_map[index] for index in combination]
              if all(index < vec_n-1 for index in swizzle_indexes):
                  continue
              vec_type = f'{"detail::" if i == 0 else ""}Vec{i+1}Base'
              indexes_str = ', '.join(str(index)
                                      for index in swizzle_indexes)
              out += f'detail::Swizzle<{vec_type}, Elem, {indexes_str}> {"".join(combination)};\n'
  
  print(out, end='')
  