Commits

ariovistus  committed 0721f95

fix setup.py for python 3

also don't copy everything into build

  • Participants
  • Parent commits c61874d

Comments (0)

Files changed (25)

File build_manifest.py

 import os, os.path
+import itertools
+import sys
+import re
 
 
 FORBIDDEN_EXTENSIONS = [
   ]
 
 FORBIDDEN_DIRECTORIES = [
-    lambda d: d.lower() in ('.svn', 'cvs', 'build', 'dist', '.hg', '.git'),
+    lambda d: d.lower() in ('.svn', 'cvs', 'build', 'dist', '.hg', '.git', '.tup'),
     lambda d: d.startswith('__'),
   ]
 
     'setup.py',
   ]
 
-EXCLUDE_PATHS = [
-    'MANIFEST',
-  ]
+def split_complete(path):
+    folders = []
+    while True:
+        path, p2 = os.path.split(path)
+        if p2 != '':
+            folders.append(p2)
+        else:
+            if path!='':
+                folders.append(path)
+            break
+    return list(reversed(folders))
+def include_path(path):
+    pathsubs = split_complete(path)
+    assert pathsubs
+    filebase, ext = os.path.splitext(pathsubs[-1])
+    if pathsubs[0] == 'infrastructure':
+        if pathsubs == ['infrastructure','pyd','LICENSE']:
+            return True
+        if pathsubs == ['infrastructure','python','python.d']:
+            return False
+        if ext.lower() == '.d':
+            return True
+        if (sys.platform.lower().startswith('win') and
+                re.match("python.._digitalmars\\.lib",pathsubs[-1])):
+            return True
+        return False
+    if len(pathsubs) == 1 and ext.lower() == '.py':
+        return True
+    return False
 
 
 def buildManifest(outputStream, isForSourceDist):
     includedPaths, excludedPaths = listFiles(isForSourceDist)
     for path in includedPaths:
         # print >> outputStream, 'include "%s"' % convertPathToDistutilsStandard(path)
-        print >> outputStream, convertPathToDistutilsStandard(path)
+        outputStream.write(convertPathToDistutilsStandard(path))
+        outputStream.write("\n")
 
 
 def convertPathToDistutilsStandard(path):
                 includedPaths.remove(path)
                 excludedPaths.append(path)
 
-    for path in EXCLUDE_PATHS:
-        if path in includedPaths:
-            includedPaths.remove(path)
-            excludedPaths.append(path)
+    excludedPaths.extend([path for path in includedPaths if not include_path(path)])
+    includedPaths = [path for path in includedPaths if include_path(path)]
 
     return includedPaths, excludedPaths
 

File infrastructure/pyd/generators/argtypes.py

-MAX_ARGS = 10
-
-import sys
-old_stdout = sys.stdout
-sys.stdout = open('argtypes.txt', 'w')
-
-def arglist(n):
-    parts = []
-    for i in range(n):
-        parts.append(', A%s' % i)
-    return "".join(parts)
-
-def typeidList(n):
-    parts = []
-    for i in range(n):
-        parts.append('typeid(A%s)' % i)
-    return ", ".join(parts)
-
-for i in range(MAX_ARGS+1):
-    print "public"
-    print "template ArgTypes(Tr%s) {" % arglist(i)
-    print "    TypeInfo[] ArgTypes(Tr function(%s) fn) {" % arglist(i)[2:]
-    print "        return arrayOf!(TypeInfo)(%s);" % typeidList(i)
-    print "    }"
-    print "}"
-    print
-
-sys.stdout = old_stdout

File infrastructure/pyd/generators/argtypes.txt

-public
-template ArgTypes(Tr) {
-    TypeInfo[] ArgTypes(Tr function() fn) {
-        return arrayOf!(TypeInfo)();
-    }
-}
-
-public
-template ArgTypes(Tr, A0) {
-    TypeInfo[] ArgTypes(Tr function(A0) fn) {
-        return arrayOf!(TypeInfo)(typeid(A0));
-    }
-}
-
-public
-template ArgTypes(Tr, A0, A1) {
-    TypeInfo[] ArgTypes(Tr function(A0, A1) fn) {
-        return arrayOf!(TypeInfo)(typeid(A0), typeid(A1));
-    }
-}
-
-public
-template ArgTypes(Tr, A0, A1, A2) {
-    TypeInfo[] ArgTypes(Tr function(A0, A1, A2) fn) {
-        return arrayOf!(TypeInfo)(typeid(A0), typeid(A1), typeid(A2));
-    }
-}
-
-public
-template ArgTypes(Tr, A0, A1, A2, A3) {
-    TypeInfo[] ArgTypes(Tr function(A0, A1, A2, A3) fn) {
-        return arrayOf!(TypeInfo)(typeid(A0), typeid(A1), typeid(A2), typeid(A3));
-    }
-}
-
-public
-template ArgTypes(Tr, A0, A1, A2, A3, A4) {
-    TypeInfo[] ArgTypes(Tr function(A0, A1, A2, A3, A4) fn) {
-        return arrayOf!(TypeInfo)(typeid(A0), typeid(A1), typeid(A2), typeid(A3), typeid(A4));
-    }
-}
-
-public
-template ArgTypes(Tr, A0, A1, A2, A3, A4, A5) {
-    TypeInfo[] ArgTypes(Tr function(A0, A1, A2, A3, A4, A5) fn) {
-        return arrayOf!(TypeInfo)(typeid(A0), typeid(A1), typeid(A2), typeid(A3), typeid(A4), typeid(A5));
-    }
-}
-
-public
-template ArgTypes(Tr, A0, A1, A2, A3, A4, A5, A6) {
-    TypeInfo[] ArgTypes(Tr function(A0, A1, A2, A3, A4, A5, A6) fn) {
-        return arrayOf!(TypeInfo)(typeid(A0), typeid(A1), typeid(A2), typeid(A3), typeid(A4), typeid(A5), typeid(A6));
-    }
-}
-
-public
-template ArgTypes(Tr, A0, A1, A2, A3, A4, A5, A6, A7) {
-    TypeInfo[] ArgTypes(Tr function(A0, A1, A2, A3, A4, A5, A6, A7) fn) {
-        return arrayOf!(TypeInfo)(typeid(A0), typeid(A1), typeid(A2), typeid(A3), typeid(A4), typeid(A5), typeid(A6), typeid(A7));
-    }
-}
-
-public
-template ArgTypes(Tr, A0, A1, A2, A3, A4, A5, A6, A7, A8) {
-    TypeInfo[] ArgTypes(Tr function(A0, A1, A2, A3, A4, A5, A6, A7, A8) fn) {
-        return arrayOf!(TypeInfo)(typeid(A0), typeid(A1), typeid(A2), typeid(A3), typeid(A4), typeid(A5), typeid(A6), typeid(A7), typeid(A8));
-    }
-}
-
-public
-template ArgTypes(Tr, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9) {
-    TypeInfo[] ArgTypes(Tr function(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9) fn) {
-        return arrayOf!(TypeInfo)(typeid(A0), typeid(A1), typeid(A2), typeid(A3), typeid(A4), typeid(A5), typeid(A6), typeid(A7), typeid(A8), typeid(A9));
-    }
-}
-

File infrastructure/pyd/generators/callable_wrap.py

-import sys
-old_stdout = sys.stdout
-sys.stdout = open('callable_wrap.txt', 'w')
-
-template = """\
-    Tr fn(Tr, %s)(%s) {
-        return boilerplate!(Tr)(call(%s));
-    }
-"""
-
-for i in range(1, 11):
-    t_args = []
-    f_args = []
-    c_args = []
-    for j in range(1, i+1):
-        t_args.append("T%s" % j)
-        f_args.append("T%s t%s" % (j, j))
-        c_args.append("t%s" % j)
-    print template % (", ".join(t_args), ", ".join(f_args), ", ".join(c_args))
-
-sys.stdout = old_stdout

File infrastructure/pyd/generators/callable_wrap.txt

-    Tr fn(Tr, T1)(T1 t1) {
-        return boilerplate!(Tr)(call(t1));
-    }
-
-    Tr fn(Tr, T1, T2)(T1 t1, T2 t2) {
-        return boilerplate!(Tr)(call(t1, t2));
-    }
-
-    Tr fn(Tr, T1, T2, T3)(T1 t1, T2 t2, T3 t3) {
-        return boilerplate!(Tr)(call(t1, t2, t3));
-    }
-
-    Tr fn(Tr, T1, T2, T3, T4)(T1 t1, T2 t2, T3 t3, T4 t4) {
-        return boilerplate!(Tr)(call(t1, t2, t3, t4));
-    }
-
-    Tr fn(Tr, T1, T2, T3, T4, T5)(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) {
-        return boilerplate!(Tr)(call(t1, t2, t3, t4, t5));
-    }
-
-    Tr fn(Tr, T1, T2, T3, T4, T5, T6)(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) {
-        return boilerplate!(Tr)(call(t1, t2, t3, t4, t5, t6));
-    }
-
-    Tr fn(Tr, T1, T2, T3, T4, T5, T6, T7)(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) {
-        return boilerplate!(Tr)(call(t1, t2, t3, t4, t5, t6, t7));
-    }
-
-    Tr fn(Tr, T1, T2, T3, T4, T5, T6, T7, T8)(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) {
-        return boilerplate!(Tr)(call(t1, t2, t3, t4, t5, t6, t7, t8));
-    }
-
-    Tr fn(Tr, T1, T2, T3, T4, T5, T6, T7, T8, T9)(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9) {
-        return boilerplate!(Tr)(call(t1, t2, t3, t4, t5, t6, t7, t8, t9));
-    }
-
-    Tr fn(Tr, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10) {
-        return boilerplate!(Tr)(call(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10));
-    }
-

File infrastructure/pyd/generators/ctor_wrap.py

-f = open('ctor_wrap.txt', 'w')
-
-template = "d_type!(Ctor.arg%s)(PyTuple_GetItem(args, %s))"
-
-for i in range(2, 11):
-    f.write("        } else static if (Ctor.ARGS == %s) {\n" % i)
-    f.write("            T t = new T(\n")
-    for j in range(i):
-        f.write("                " + template % (j+1, j))
-        if j < i-1:
-            f.write(',')
-        f.write('\n')
-    f.write("            );\n")
-f.write ("        }")

File infrastructure/pyd/generators/ctor_wrap.txt

-        } else static if (Ctor.ARGS == 2) {
-            T t = new T(
-                d_type!(Ctor.arg1)(PyTuple_GetItem(args, 0)),
-                d_type!(Ctor.arg2)(PyTuple_GetItem(args, 1))
-            );
-        } else static if (Ctor.ARGS == 3) {
-            T t = new T(
-                d_type!(Ctor.arg1)(PyTuple_GetItem(args, 0)),
-                d_type!(Ctor.arg2)(PyTuple_GetItem(args, 1)),
-                d_type!(Ctor.arg3)(PyTuple_GetItem(args, 2))
-            );
-        } else static if (Ctor.ARGS == 4) {
-            T t = new T(
-                d_type!(Ctor.arg1)(PyTuple_GetItem(args, 0)),
-                d_type!(Ctor.arg2)(PyTuple_GetItem(args, 1)),
-                d_type!(Ctor.arg3)(PyTuple_GetItem(args, 2)),
-                d_type!(Ctor.arg4)(PyTuple_GetItem(args, 3))
-            );
-        } else static if (Ctor.ARGS == 5) {
-            T t = new T(
-                d_type!(Ctor.arg1)(PyTuple_GetItem(args, 0)),
-                d_type!(Ctor.arg2)(PyTuple_GetItem(args, 1)),
-                d_type!(Ctor.arg3)(PyTuple_GetItem(args, 2)),
-                d_type!(Ctor.arg4)(PyTuple_GetItem(args, 3)),
-                d_type!(Ctor.arg5)(PyTuple_GetItem(args, 4))
-            );
-        } else static if (Ctor.ARGS == 6) {
-            T t = new T(
-                d_type!(Ctor.arg1)(PyTuple_GetItem(args, 0)),
-                d_type!(Ctor.arg2)(PyTuple_GetItem(args, 1)),
-                d_type!(Ctor.arg3)(PyTuple_GetItem(args, 2)),
-                d_type!(Ctor.arg4)(PyTuple_GetItem(args, 3)),
-                d_type!(Ctor.arg5)(PyTuple_GetItem(args, 4)),
-                d_type!(Ctor.arg6)(PyTuple_GetItem(args, 5))
-            );
-        } else static if (Ctor.ARGS == 7) {
-            T t = new T(
-                d_type!(Ctor.arg1)(PyTuple_GetItem(args, 0)),
-                d_type!(Ctor.arg2)(PyTuple_GetItem(args, 1)),
-                d_type!(Ctor.arg3)(PyTuple_GetItem(args, 2)),
-                d_type!(Ctor.arg4)(PyTuple_GetItem(args, 3)),
-                d_type!(Ctor.arg5)(PyTuple_GetItem(args, 4)),
-                d_type!(Ctor.arg6)(PyTuple_GetItem(args, 5)),
-                d_type!(Ctor.arg7)(PyTuple_GetItem(args, 6))
-            );
-        } else static if (Ctor.ARGS == 8) {
-            T t = new T(
-                d_type!(Ctor.arg1)(PyTuple_GetItem(args, 0)),
-                d_type!(Ctor.arg2)(PyTuple_GetItem(args, 1)),
-                d_type!(Ctor.arg3)(PyTuple_GetItem(args, 2)),
-                d_type!(Ctor.arg4)(PyTuple_GetItem(args, 3)),
-                d_type!(Ctor.arg5)(PyTuple_GetItem(args, 4)),
-                d_type!(Ctor.arg6)(PyTuple_GetItem(args, 5)),
-                d_type!(Ctor.arg7)(PyTuple_GetItem(args, 6)),
-                d_type!(Ctor.arg8)(PyTuple_GetItem(args, 7))
-            );
-        } else static if (Ctor.ARGS == 9) {
-            T t = new T(
-                d_type!(Ctor.arg1)(PyTuple_GetItem(args, 0)),
-                d_type!(Ctor.arg2)(PyTuple_GetItem(args, 1)),
-                d_type!(Ctor.arg3)(PyTuple_GetItem(args, 2)),
-                d_type!(Ctor.arg4)(PyTuple_GetItem(args, 3)),
-                d_type!(Ctor.arg5)(PyTuple_GetItem(args, 4)),
-                d_type!(Ctor.arg6)(PyTuple_GetItem(args, 5)),
-                d_type!(Ctor.arg7)(PyTuple_GetItem(args, 6)),
-                d_type!(Ctor.arg8)(PyTuple_GetItem(args, 7)),
-                d_type!(Ctor.arg9)(PyTuple_GetItem(args, 8))
-            );
-        } else static if (Ctor.ARGS == 10) {
-            T t = new T(
-                d_type!(Ctor.arg1)(PyTuple_GetItem(args, 0)),
-                d_type!(Ctor.arg2)(PyTuple_GetItem(args, 1)),
-                d_type!(Ctor.arg3)(PyTuple_GetItem(args, 2)),
-                d_type!(Ctor.arg4)(PyTuple_GetItem(args, 3)),
-                d_type!(Ctor.arg5)(PyTuple_GetItem(args, 4)),
-                d_type!(Ctor.arg6)(PyTuple_GetItem(args, 5)),
-                d_type!(Ctor.arg7)(PyTuple_GetItem(args, 6)),
-                d_type!(Ctor.arg8)(PyTuple_GetItem(args, 7)),
-                d_type!(Ctor.arg9)(PyTuple_GetItem(args, 8)),
-                d_type!(Ctor.arg10)(PyTuple_GetItem(args, 9))
-            );
-        }

File infrastructure/pyd/generators/fn_to_dg.py

-f = open('fn_to_dg.txt', 'w')
-
-template = """\
-    } else static if (ARGS == %s) {
-        alias RetType delegate(%s) type;
-"""
-
-inner_template = """ArgType!(Fn, %s)"""
-
-for i in range(1, 11):
-    inner_parts = []
-    for j in range(1, i+1):
-        inner_parts.append(inner_template % j)
-    f.write(template % (i, ', '.join(inner_parts)))
-f.write("    }")

File infrastructure/pyd/generators/fn_to_dg.txt

-    } else static if (ARGS == 1) {
-        alias RetType delegate(ArgType!(Fn, 1)) type;
-    } else static if (ARGS == 2) {
-        alias RetType delegate(ArgType!(Fn, 1), ArgType!(Fn, 2)) type;
-    } else static if (ARGS == 3) {
-        alias RetType delegate(ArgType!(Fn, 1), ArgType!(Fn, 2), ArgType!(Fn, 3)) type;
-    } else static if (ARGS == 4) {
-        alias RetType delegate(ArgType!(Fn, 1), ArgType!(Fn, 2), ArgType!(Fn, 3), ArgType!(Fn, 4)) type;
-    } else static if (ARGS == 5) {
-        alias RetType delegate(ArgType!(Fn, 1), ArgType!(Fn, 2), ArgType!(Fn, 3), ArgType!(Fn, 4), ArgType!(Fn, 5)) type;
-    } else static if (ARGS == 6) {
-        alias RetType delegate(ArgType!(Fn, 1), ArgType!(Fn, 2), ArgType!(Fn, 3), ArgType!(Fn, 4), ArgType!(Fn, 5), ArgType!(Fn, 6)) type;
-    } else static if (ARGS == 7) {
-        alias RetType delegate(ArgType!(Fn, 1), ArgType!(Fn, 2), ArgType!(Fn, 3), ArgType!(Fn, 4), ArgType!(Fn, 5), ArgType!(Fn, 6), ArgType!(Fn, 7)) type;
-    } else static if (ARGS == 8) {
-        alias RetType delegate(ArgType!(Fn, 1), ArgType!(Fn, 2), ArgType!(Fn, 3), ArgType!(Fn, 4), ArgType!(Fn, 5), ArgType!(Fn, 6), ArgType!(Fn, 7), ArgType!(Fn, 8)) type;
-    } else static if (ARGS == 9) {
-        alias RetType delegate(ArgType!(Fn, 1), ArgType!(Fn, 2), ArgType!(Fn, 3), ArgType!(Fn, 4), ArgType!(Fn, 5), ArgType!(Fn, 6), ArgType!(Fn, 7), ArgType!(Fn, 8), ArgType!(Fn, 9)) type;
-    } else static if (ARGS == 10) {
-        alias RetType delegate(ArgType!(Fn, 1), ArgType!(Fn, 2), ArgType!(Fn, 3), ArgType!(Fn, 4), ArgType!(Fn, 5), ArgType!(Fn, 6), ArgType!(Fn, 7), ArgType!(Fn, 8), ArgType!(Fn, 9), ArgType!(Fn, 10)) type;
-    }

File infrastructure/pyd/generators/ftype.py

-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-#
-# ftype.py
-# An evil hack in under 400 lines.
-# Written by Daniel Keep
-# Released to public domain—share and enjoy (just leave my name in it, pretty
-# please).
-#
-
-# TODO:
-# * Better error messages when you try to use a function with too many
-#   arguments (it currently barfs with an unhelpful cascade of errors).
-
-# This number controls the maximum number of arguments these templates will be
-# able to process.  The higher you set this, the larger the output file
-# becomes.
-MAX_ARGS = 10
-
-# This is the file the module will be output to.
-OUT_FILE = "ftype.txt"
-
-# This is the full name of the module.
-MODULE_PATH = "pyd.ftype"
-
-#
-# Everything from here on isn't very interesting :)
-#
-
-# Redirect output to ftype.d
-import sys
-old_stdout = sys.stdout
-sys.stdout = file(OUT_FILE, 'wt')
-
-def typename(i):
-    if i == 0:
-        return "Tr"
-    else:
-        return "Ta%d" % i
-
-def typenameinout(i):
-    if i == 0:
-        return "Tr"
-    else:
-        return "inout Ta%d" % i
-
-def typeargs(n, omit_first=False):
-    if omit_first:
-        xs = range(1,n+1)
-    else:
-        xs = range(n+1)
-        
-    return ", ".join(typename(x) for x in xs)
-
-def typeargsinout(n, omit_first=False):
-    if omit_first:
-        xs = range(1,n+1)
-    else:
-        xs = range(n+1)
-        
-    return ", ".join(typenameinout(x) for x in xs)
-
-def typefptr(n):
-    return "%s function(%s)" % (typename(0), typeargs(n, True))
-
-def typefninout(n):
-    return "%s function(%s)" % (typenameinout(0), typeargsinout(n, True))
-
-def typedelegate(n):
-    return "%s delegate(%s)" % (typename(0), typeargs(n, True))
-
-typefn = typefptr
-
-#callable_types = ('F',typefptr), ('D',typedelegate)
-
-#
-# Module header
-#
-
-print """/**
- * This module contains template for inferring the number of arguments,
- * the return type, and argument types of an arbitrary function pointer.
- * 
- * This module was automatically generated by ftype.py
- * 
- * Written by Daniel Keep.
- * Released to public domain—share and enjoy (just leave my name in it,
- * pretty please).
- */
-module %s;
-private:""" % MODULE_PATH
-
-#
-# Support templates
-#
-
-##print """
-##/*
-## * This template tests whether a particular type is a function pointer.
-## *
-## * Borrowed from the traits library.
-## */
-##template
-##IsFunctionPtr(Tf)
-##{
-##    const bool IsFunctionPtr = is( typeof(*Tf) == function );
-##}"""
-##
-##print """
-##/*
-## * This template tests whether a particular type is a delegate.
-## *
-## * Borrowed from the traits library.
-## */
-##template
-##IsDelegate(Tf)
-##{
-##    const bool IsDelegate = is( Tf == delegate );
-##}"""
-
-#
-# NumberOfArgs(Tf)
-#
-
-print """
-/* *** NumberOfArgs(Tf) *** */
-"""
-
-for i in range(MAX_ARGS+1):
-    print "typedef uint Arglen%d = %d;" % (i, i)
-
-for i in range(MAX_ARGS+1):
-    print ""
-    print "template"
-    print "ArglenT(%s)" % typeargs(i)
-    print "{"
-    print "    Arglen%d" % i
-    print "    ArglenT(%s fn) { assert(false); }" % typefn(i)
-    print "}"
-
-print """
-template
-ArglenConvT(T)
-{
-    const uint ArglenConvT = T.init;
-}"""
-
-print """
-template
-NumberOfArgsT(Tf)
-{
-    private Tf fptr;
-    alias typeof(ArglenT(fptr)) type;
-}"""
-
-print """
-template
-NumberOfArgsSwitchT(Tf)
-{
-    static if( is( typeof(*Tf) == function ) )
-        alias NumberOfArgsT!(Tf).type type;
-    else static if( is( Tf U == delegate ) )
-        alias NumberOfArgsSwitchT!(U*).type type;
-}"""
-
-print """
-/**
- * This template will attempt to determine the number of arguments the
- * supplied function pointer or delegate type takes.  It supports a maximum of
- * %d arguments.
- *
- * Example:
- * ----------------------------------------
- * void fnWithThreeArgs(byte a, short b, int c) {}
- * const uint numArgs = NumberOfArgs!(typeof(&fnWithThreeArgs));
- * ----------------------------------------
- */
-public
-template
-NumberOfArgs(Tf)
-{
-    const uint NumberOfArgs = ArglenConvT!(NumberOfArgsSwitchT!(Tf).type);
-}""" % MAX_ARGS
-
-#
-# NumberOfArgsInout
-#
-for i in range(MAX_ARGS+1):
-    print ""
-    print "template"
-    print "ArgleninoutT(%s)" % typeargs(i)
-    print "{"
-    print "    Arglen%d" % i
-    print "    ArgleninoutT(%s fn) { assert(false); }" % typefninout(i)
-    print "}"
-
-print """
-template
-NumberOfArgsInoutT(Tf)
-{
-    private Tf fptr;
-    alias typeof(ArgleninoutT(fptr)) type;
-}"""
-
-print """
-template
-NumberOfArgsSwitchInoutT(Tf)
-{
-    static if( is( typeof(*Tf) == function ) )
-        alias NumberOfArgsInoutT!(Tf).type type;
-    else static if( is( Tf U == delegate ) )
-        alias NumberOfArgsSwitchInoutT!(U*).type type;
-}"""
-
-print """
-public
-template
-NumberOfArgsInout(Tf)
-{
-    const uint NumberOfArgsInout = ArglenConvT!(NumberOfArgsSwitchInoutT!(Tf).type);
-}"""
-
-#
-# ReturnType(Tf)
-#
-
-##print """
-##/* *** ReturnType(Tf) *** */"""
-##
-##for i in range(MAX_ARGS+1):
-##    for typecode,typefn in callable_types:
-##        print ""
-##        print "template"
-##        print "RetType%sT(%s)" % (typecode,typeargs(i))
-##        print "{"
-##        print "    %s" % typename(0)
-##        print "    RetType%sT(%s fn) { assert(false); }" % (typecode,typefn(i))
-##        print "}"
-
-print """
-template
-ReturnTypeT(Tf)
-{
-    private Tf fptr;
-    static if( is( typeof(*Tf) U == function ) )
-        alias U type;
-    else static if( is( Tf U == delegate ) )
-        alias ReturnType!(U*) type;
-    else
-        static assert(false, "ReturnType argument must be function pointer"
-                " or delegate.");
-}"""
-
-print """
-/**
- * This template will attempt to discern the return type of the supplied
- * function pointer or delegate type.  It supports callables with a maximum of
- * %d arguments.
- *
- * Example:
- * ----------------------------------------
- * uint returnsANumber() { return 42; }
- * alias ReturnType!(typeof(&returnsANumber)) RType; // RType == uint
- * ----------------------------------------
- */
-public
-template
-ReturnType(Tf)
-{
-    alias ReturnTypeT!(Tf).type ReturnType;
-}""" % MAX_ARGS
-
-#
-# ArgType(Tf, n)
-#
-
-print """
-/* *** ArgType(Tf, n) *** */"""
-
-for n in range(1, MAX_ARGS+1):
-    for i in range(n, MAX_ARGS+1):
-        print ""
-        print "template"
-        print "Arg%dTypeT(%s)" % (n, typeargs(i))
-        print "{"
-        print "    %s Arg%dTypeT(%s fn) { assert(false); }" % (
-            typename(n), n, typefn(i))
-        print "}"
-
-print """
-template
-ArgTypeT(Tf, uint n)
-{
-    private Tf fptr;"""
-
-for n in range(1, MAX_ARGS+1):
-    if n == 1:
-        print "    static if( n == %d )" % n
-    else:
-        print "    else static if( n == %d )" % n
-    print "        alias typeof(Arg%dTypeT(fptr)) type;" % n
-
-print """    else
-        static assert(false,
-                \"Maximum of %d arguments supported.\");
-}""" % MAX_ARGS
-
-print """
-template
-ArgTypeSwitchT(Tf, uint n)
-{
-    static if( is( typeof(*Tf) == function ) )
-        alias ArgTypeT!(Tf, n).type type;
-    else static if( is( Tf U == delegate ) )
-        alias ArgTypeSwitchT!(U*, n).type type;
-    else
-        static assert(false, "ArgType argument must be a function pointer"
-                " or a delegate.");
-}"""
-
-print """
-/**
- * This template will attempt to extract the type of the nth argument of the
- * given function pointer or delegate type.  It supports callables with up to
- * %d arguments.
- *
- * Example:
- * ----------------------------------------
- * void intShortBool(int a, short b, bool c) {}
- * alias ArgType!(typeof(&intShortBool), 2) TArg2; // TArg2 == short
- * ----------------------------------------
- */
-public
-template
-ArgType(Tf, uint n)
-{
-    alias ArgTypeSwitchT!(Tf, n).type ArgType;
-}""" % MAX_ARGS
-
-#
-# Unit tests
-#
-
-print """
-/* *** Unit tests *** */"""
-
-print """
-unittest
-{
-    alias int function()                                    fn_0args;
-    alias byte[] function(char)                             fn_1arg;
-    alias float[dchar] function(int, int[])                 fn_2args;
-    alias void function(int, float[char[]], ifloat[byte])   fn_3args;
-
-    alias int[] delegate()                                  dg_0args;
-    alias real delegate(uint[])                             dg_1arg;
-    alias void delegate(char[][char[]], bool[short])        dg_2args;
-    alias dchar[wchar] delegate(byte, short, int)           dg_3args;
-
-    // ** Test NumberOfArgs(Tf) ** //
-
-    static assert( NumberOfArgs!(fn_0args) == 0 );
-    static assert( NumberOfArgs!(fn_1arg) == 1 );
-    static assert( NumberOfArgs!(fn_2args) == 2 );
-    static assert( NumberOfArgs!(fn_3args) == 3 );
-    static assert( NumberOfArgs!(dg_0args) == 0 );
-    static assert( NumberOfArgs!(dg_1arg) == 1 );
-    static assert( NumberOfArgs!(dg_2args) == 2 );
-    static assert( NumberOfArgs!(dg_3args) == 3 );
-
-    // ** Test ReturnType(Tf) ** //
-
-    static assert( is( ReturnType!(fn_0args) == int ) );
-    static assert( is( ReturnType!(fn_1arg) == byte[] ) );
-    static assert( is( ReturnType!(fn_2args) == float[dchar] ) );
-    static assert( is( ReturnType!(fn_3args) == void ) );
-    static assert( is( ReturnType!(dg_0args) == int[] ) );
-    static assert( is( ReturnType!(dg_1arg) == real ) );
-    static assert( is( ReturnType!(dg_2args) == void ) );
-    static assert( is( ReturnType!(dg_3args) == dchar[wchar] ) );
-
-    // ** Test ArgType(Tf, n) ** //
-
-    static assert( is( ArgType!(fn_1arg, 1) == char ) );
-    static assert( is( ArgType!(fn_2args, 2) == int[] ) );
-    static assert( is( ArgType!(fn_3args, 3) == ifloat[byte] ) );
-    static assert( is( ArgType!(dg_2args, 1) == char[][char[]] ) );
-    static assert( is( ArgType!(dg_3args, 1) == byte ) );
-    static assert( is( ArgType!(dg_3args, 2) == short ) );
-
-    pragma(msg, "ftype: passed static unit tests.");
-}
-"""
-
-# Restore stdout
-sys.stdout = old_stdout

File infrastructure/pyd/generators/ftype.txt

-/**
- * This module contains template for inferring the number of arguments,
- * the return type, and argument types of an arbitrary function pointer.
- * 
- * This module was automatically generated by ftype.py
- * 
- * Written by Daniel Keep.
- * Released to public domain—share and enjoy (just leave my name in it,
- * pretty please).
- */
-module pyd.ftype;
-private:
-
-/* *** NumberOfArgs(Tf) *** */
-
-typedef uint Arglen0 = 0;
-typedef uint Arglen1 = 1;
-typedef uint Arglen2 = 2;
-typedef uint Arglen3 = 3;
-typedef uint Arglen4 = 4;
-typedef uint Arglen5 = 5;
-typedef uint Arglen6 = 6;
-typedef uint Arglen7 = 7;
-typedef uint Arglen8 = 8;
-typedef uint Arglen9 = 9;
-typedef uint Arglen10 = 10;
-
-template
-ArglenT(Tr)
-{
-    Arglen0
-    ArglenT(Tr function() fn) { assert(false); }
-}
-
-template
-ArglenT(Tr, Ta1)
-{
-    Arglen1
-    ArglenT(Tr function(Ta1) fn) { assert(false); }
-}
-
-template
-ArglenT(Tr, Ta1, Ta2)
-{
-    Arglen2
-    ArglenT(Tr function(Ta1, Ta2) fn) { assert(false); }
-}
-
-template
-ArglenT(Tr, Ta1, Ta2, Ta3)
-{
-    Arglen3
-    ArglenT(Tr function(Ta1, Ta2, Ta3) fn) { assert(false); }
-}
-
-template
-ArglenT(Tr, Ta1, Ta2, Ta3, Ta4)
-{
-    Arglen4
-    ArglenT(Tr function(Ta1, Ta2, Ta3, Ta4) fn) { assert(false); }
-}
-
-template
-ArglenT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5)
-{
-    Arglen5
-    ArglenT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5) fn) { assert(false); }
-}
-
-template
-ArglenT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6)
-{
-    Arglen6
-    ArglenT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6) fn) { assert(false); }
-}
-
-template
-ArglenT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7)
-{
-    Arglen7
-    ArglenT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7) fn) { assert(false); }
-}
-
-template
-ArglenT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8)
-{
-    Arglen8
-    ArglenT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8) fn) { assert(false); }
-}
-
-template
-ArglenT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9)
-{
-    Arglen9
-    ArglenT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9) fn) { assert(false); }
-}
-
-template
-ArglenT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10)
-{
-    Arglen10
-    ArglenT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10) fn) { assert(false); }
-}
-
-template
-ArglenConvT(T)
-{
-    const uint ArglenConvT = T.init;
-}
-
-template
-NumberOfArgsT(Tf)
-{
-    private Tf fptr;
-    alias typeof(ArglenT(fptr)) type;
-}
-
-template
-NumberOfArgsSwitchT(Tf)
-{
-    static if( is( typeof(*Tf) == function ) )
-        alias NumberOfArgsT!(Tf).type type;
-    else static if( is( Tf U == delegate ) )
-        alias NumberOfArgsSwitchT!(U*).type type;
-}
-
-/**
- * This template will attempt to determine the number of arguments the
- * supplied function pointer or delegate type takes.  It supports a maximum of
- * 10 arguments.
- *
- * Example:
- * ----------------------------------------
- * void fnWithThreeArgs(byte a, short b, int c) {}
- * const uint numArgs = NumberOfArgs!(typeof(&fnWithThreeArgs));
- * ----------------------------------------
- */
-public
-template
-NumberOfArgs(Tf)
-{
-    const uint NumberOfArgs = ArglenConvT!(NumberOfArgsSwitchT!(Tf).type);
-}
-
-template
-ArgleninoutT(Tr)
-{
-    Arglen0
-    ArgleninoutT(Tr function() fn) { assert(false); }
-}
-
-template
-ArgleninoutT(Tr, Ta1)
-{
-    Arglen1
-    ArgleninoutT(Tr function(inout Ta1) fn) { assert(false); }
-}
-
-template
-ArgleninoutT(Tr, Ta1, Ta2)
-{
-    Arglen2
-    ArgleninoutT(Tr function(inout Ta1, inout Ta2) fn) { assert(false); }
-}
-
-template
-ArgleninoutT(Tr, Ta1, Ta2, Ta3)
-{
-    Arglen3
-    ArgleninoutT(Tr function(inout Ta1, inout Ta2, inout Ta3) fn) { assert(false); }
-}
-
-template
-ArgleninoutT(Tr, Ta1, Ta2, Ta3, Ta4)
-{
-    Arglen4
-    ArgleninoutT(Tr function(inout Ta1, inout Ta2, inout Ta3, inout Ta4) fn) { assert(false); }
-}
-
-template
-ArgleninoutT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5)
-{
-    Arglen5
-    ArgleninoutT(Tr function(inout Ta1, inout Ta2, inout Ta3, inout Ta4, inout Ta5) fn) { assert(false); }
-}
-
-template
-ArgleninoutT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6)
-{
-    Arglen6
-    ArgleninoutT(Tr function(inout Ta1, inout Ta2, inout Ta3, inout Ta4, inout Ta5, inout Ta6) fn) { assert(false); }
-}
-
-template
-ArgleninoutT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7)
-{
-    Arglen7
-    ArgleninoutT(Tr function(inout Ta1, inout Ta2, inout Ta3, inout Ta4, inout Ta5, inout Ta6, inout Ta7) fn) { assert(false); }
-}
-
-template
-ArgleninoutT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8)
-{
-    Arglen8
-    ArgleninoutT(Tr function(inout Ta1, inout Ta2, inout Ta3, inout Ta4, inout Ta5, inout Ta6, inout Ta7, inout Ta8) fn) { assert(false); }
-}
-
-template
-ArgleninoutT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9)
-{
-    Arglen9
-    ArgleninoutT(Tr function(inout Ta1, inout Ta2, inout Ta3, inout Ta4, inout Ta5, inout Ta6, inout Ta7, inout Ta8, inout Ta9) fn) { assert(false); }
-}
-
-template
-ArgleninoutT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10)
-{
-    Arglen10
-    ArgleninoutT(Tr function(inout Ta1, inout Ta2, inout Ta3, inout Ta4, inout Ta5, inout Ta6, inout Ta7, inout Ta8, inout Ta9, inout Ta10) fn) { assert(false); }
-}
-
-template
-NumberOfArgsInoutT(Tf)
-{
-    private Tf fptr;
-    alias typeof(ArgleninoutT(fptr)) type;
-}
-
-template
-NumberOfArgsSwitchInoutT(Tf)
-{
-    static if( is( typeof(*Tf) == function ) )
-        alias NumberOfArgsInoutT!(Tf).type type;
-    else static if( is( Tf U == delegate ) )
-        alias NumberOfArgsSwitchInoutT!(U*).type type;
-}
-
-public
-template
-NumberOfArgsInout(Tf)
-{
-    const uint NumberOfArgsInout = ArglenConvT!(NumberOfArgsSwitchInoutT!(Tf).type);
-}
-
-template
-ReturnTypeT(Tf)
-{
-    private Tf fptr;
-    static if( is( typeof(*Tf) U == function ) )
-        alias U type;
-    else static if( is( Tf U == delegate ) )
-        alias ReturnType!(U*) type;
-    else
-        static assert(false, "ReturnType argument must be function pointer"
-                " or delegate.");
-}
-
-/**
- * This template will attempt to discern the return type of the supplied
- * function pointer or delegate type.  It supports callables with a maximum of
- * 10 arguments.
- *
- * Example:
- * ----------------------------------------
- * uint returnsANumber() { return 42; }
- * alias ReturnType!(typeof(&returnsANumber)) RType; // RType == uint
- * ----------------------------------------
- */
-public
-template
-ReturnType(Tf)
-{
-    alias ReturnTypeT!(Tf).type ReturnType;
-}
-
-/* *** ArgType(Tf, n) *** */
-
-template
-Arg1TypeT(Tr, Ta1)
-{
-    Ta1 Arg1TypeT(Tr function(Ta1) fn) { assert(false); }
-}
-
-template
-Arg1TypeT(Tr, Ta1, Ta2)
-{
-    Ta1 Arg1TypeT(Tr function(Ta1, Ta2) fn) { assert(false); }
-}
-
-template
-Arg1TypeT(Tr, Ta1, Ta2, Ta3)
-{
-    Ta1 Arg1TypeT(Tr function(Ta1, Ta2, Ta3) fn) { assert(false); }
-}
-
-template
-Arg1TypeT(Tr, Ta1, Ta2, Ta3, Ta4)
-{
-    Ta1 Arg1TypeT(Tr function(Ta1, Ta2, Ta3, Ta4) fn) { assert(false); }
-}
-
-template
-Arg1TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5)
-{
-    Ta1 Arg1TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5) fn) { assert(false); }
-}
-
-template
-Arg1TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6)
-{
-    Ta1 Arg1TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6) fn) { assert(false); }
-}
-
-template
-Arg1TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7)
-{
-    Ta1 Arg1TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7) fn) { assert(false); }
-}
-
-template
-Arg1TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8)
-{
-    Ta1 Arg1TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8) fn) { assert(false); }
-}
-
-template
-Arg1TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9)
-{
-    Ta1 Arg1TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9) fn) { assert(false); }
-}
-
-template
-Arg1TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10)
-{
-    Ta1 Arg1TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10) fn) { assert(false); }
-}
-
-template
-Arg2TypeT(Tr, Ta1, Ta2)
-{
-    Ta2 Arg2TypeT(Tr function(Ta1, Ta2) fn) { assert(false); }
-}
-
-template
-Arg2TypeT(Tr, Ta1, Ta2, Ta3)
-{
-    Ta2 Arg2TypeT(Tr function(Ta1, Ta2, Ta3) fn) { assert(false); }
-}
-
-template
-Arg2TypeT(Tr, Ta1, Ta2, Ta3, Ta4)
-{
-    Ta2 Arg2TypeT(Tr function(Ta1, Ta2, Ta3, Ta4) fn) { assert(false); }
-}
-
-template
-Arg2TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5)
-{
-    Ta2 Arg2TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5) fn) { assert(false); }
-}
-
-template
-Arg2TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6)
-{
-    Ta2 Arg2TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6) fn) { assert(false); }
-}
-
-template
-Arg2TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7)
-{
-    Ta2 Arg2TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7) fn) { assert(false); }
-}
-
-template
-Arg2TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8)
-{
-    Ta2 Arg2TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8) fn) { assert(false); }
-}
-
-template
-Arg2TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9)
-{
-    Ta2 Arg2TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9) fn) { assert(false); }
-}
-
-template
-Arg2TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10)
-{
-    Ta2 Arg2TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10) fn) { assert(false); }
-}
-
-template
-Arg3TypeT(Tr, Ta1, Ta2, Ta3)
-{
-    Ta3 Arg3TypeT(Tr function(Ta1, Ta2, Ta3) fn) { assert(false); }
-}
-
-template
-Arg3TypeT(Tr, Ta1, Ta2, Ta3, Ta4)
-{
-    Ta3 Arg3TypeT(Tr function(Ta1, Ta2, Ta3, Ta4) fn) { assert(false); }
-}
-
-template
-Arg3TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5)
-{
-    Ta3 Arg3TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5) fn) { assert(false); }
-}
-
-template
-Arg3TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6)
-{
-    Ta3 Arg3TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6) fn) { assert(false); }
-}
-
-template
-Arg3TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7)
-{
-    Ta3 Arg3TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7) fn) { assert(false); }
-}
-
-template
-Arg3TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8)
-{
-    Ta3 Arg3TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8) fn) { assert(false); }
-}
-
-template
-Arg3TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9)
-{
-    Ta3 Arg3TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9) fn) { assert(false); }
-}
-
-template
-Arg3TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10)
-{
-    Ta3 Arg3TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10) fn) { assert(false); }
-}
-
-template
-Arg4TypeT(Tr, Ta1, Ta2, Ta3, Ta4)
-{
-    Ta4 Arg4TypeT(Tr function(Ta1, Ta2, Ta3, Ta4) fn) { assert(false); }
-}
-
-template
-Arg4TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5)
-{
-    Ta4 Arg4TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5) fn) { assert(false); }
-}
-
-template
-Arg4TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6)
-{
-    Ta4 Arg4TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6) fn) { assert(false); }
-}
-
-template
-Arg4TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7)
-{
-    Ta4 Arg4TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7) fn) { assert(false); }
-}
-
-template
-Arg4TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8)
-{
-    Ta4 Arg4TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8) fn) { assert(false); }
-}
-
-template
-Arg4TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9)
-{
-    Ta4 Arg4TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9) fn) { assert(false); }
-}
-
-template
-Arg4TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10)
-{
-    Ta4 Arg4TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10) fn) { assert(false); }
-}
-
-template
-Arg5TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5)
-{
-    Ta5 Arg5TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5) fn) { assert(false); }
-}
-
-template
-Arg5TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6)
-{
-    Ta5 Arg5TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6) fn) { assert(false); }
-}
-
-template
-Arg5TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7)
-{
-    Ta5 Arg5TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7) fn) { assert(false); }
-}
-
-template
-Arg5TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8)
-{
-    Ta5 Arg5TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8) fn) { assert(false); }
-}
-
-template
-Arg5TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9)
-{
-    Ta5 Arg5TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9) fn) { assert(false); }
-}
-
-template
-Arg5TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10)
-{
-    Ta5 Arg5TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10) fn) { assert(false); }
-}
-
-template
-Arg6TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6)
-{
-    Ta6 Arg6TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6) fn) { assert(false); }
-}
-
-template
-Arg6TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7)
-{
-    Ta6 Arg6TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7) fn) { assert(false); }
-}
-
-template
-Arg6TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8)
-{
-    Ta6 Arg6TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8) fn) { assert(false); }
-}
-
-template
-Arg6TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9)
-{
-    Ta6 Arg6TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9) fn) { assert(false); }
-}
-
-template
-Arg6TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10)
-{
-    Ta6 Arg6TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10) fn) { assert(false); }
-}
-
-template
-Arg7TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7)
-{
-    Ta7 Arg7TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7) fn) { assert(false); }
-}
-
-template
-Arg7TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8)
-{
-    Ta7 Arg7TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8) fn) { assert(false); }
-}
-
-template
-Arg7TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9)
-{
-    Ta7 Arg7TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9) fn) { assert(false); }
-}
-
-template
-Arg7TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10)
-{
-    Ta7 Arg7TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10) fn) { assert(false); }
-}
-
-template
-Arg8TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8)
-{
-    Ta8 Arg8TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8) fn) { assert(false); }
-}
-
-template
-Arg8TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9)
-{
-    Ta8 Arg8TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9) fn) { assert(false); }
-}
-
-template
-Arg8TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10)
-{
-    Ta8 Arg8TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10) fn) { assert(false); }
-}
-
-template
-Arg9TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9)
-{
-    Ta9 Arg9TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9) fn) { assert(false); }
-}
-
-template
-Arg9TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10)
-{
-    Ta9 Arg9TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10) fn) { assert(false); }
-}
-
-template
-Arg10TypeT(Tr, Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10)
-{
-    Ta10 Arg10TypeT(Tr function(Ta1, Ta2, Ta3, Ta4, Ta5, Ta6, Ta7, Ta8, Ta9, Ta10) fn) { assert(false); }
-}
-
-template
-ArgTypeT(Tf, uint n)
-{
-    private Tf fptr;
-    static if( n == 1 )
-        alias typeof(Arg1TypeT(fptr)) type;
-    else static if( n == 2 )
-        alias typeof(Arg2TypeT(fptr)) type;
-    else static if( n == 3 )
-        alias typeof(Arg3TypeT(fptr)) type;
-    else static if( n == 4 )
-        alias typeof(Arg4TypeT(fptr)) type;
-    else static if( n == 5 )
-        alias typeof(Arg5TypeT(fptr)) type;
-    else static if( n == 6 )
-        alias typeof(Arg6TypeT(fptr)) type;
-    else static if( n == 7 )
-        alias typeof(Arg7TypeT(fptr)) type;
-    else static if( n == 8 )
-        alias typeof(Arg8TypeT(fptr)) type;
-    else static if( n == 9 )
-        alias typeof(Arg9TypeT(fptr)) type;
-    else static if( n == 10 )
-        alias typeof(Arg10TypeT(fptr)) type;
-    else
-        static assert(false,
-                "Maximum of 10 arguments supported.");
-}
-
-template
-ArgTypeSwitchT(Tf, uint n)
-{
-    static if( is( typeof(*Tf) == function ) )
-        alias ArgTypeT!(Tf, n).type type;
-    else static if( is( Tf U == delegate ) )
-        alias ArgTypeSwitchT!(U*, n).type type;
-    else
-        static assert(false, "ArgType argument must be a function pointer"
-                " or a delegate.");
-}
-
-/**
- * This template will attempt to extract the type of the nth argument of the
- * given function pointer or delegate type.  It supports callables with up to
- * 10 arguments.
- *
- * Example:
- * ----------------------------------------
- * void intShortBool(int a, short b, bool c) {}
- * alias ArgType!(typeof(&intShortBool), 2) TArg2; // TArg2 == short
- * ----------------------------------------
- */
-public
-template
-ArgType(Tf, uint n)
-{
-    alias ArgTypeSwitchT!(Tf, n).type ArgType;
-}
-
-/* *** Unit tests *** */
-
-unittest
-{
-    alias int function()                                    fn_0args;
-    alias byte[] function(char)                             fn_1arg;
-    alias float[dchar] function(int, int[])                 fn_2args;
-    alias void function(int, float[char[]], ifloat[byte])   fn_3args;
-
-    alias int[] delegate()                                  dg_0args;
-    alias real delegate(uint[])                             dg_1arg;
-    alias void delegate(char[][char[]], bool[short])        dg_2args;
-    alias dchar[wchar] delegate(byte, short, int)           dg_3args;
-
-    // ** Test NumberOfArgs(Tf) ** //
-
-    static assert( NumberOfArgs!(fn_0args) == 0 );
-    static assert( NumberOfArgs!(fn_1arg) == 1 );
-    static assert( NumberOfArgs!(fn_2args) == 2 );
-    static assert( NumberOfArgs!(fn_3args) == 3 );
-    static assert( NumberOfArgs!(dg_0args) == 0 );
-    static assert( NumberOfArgs!(dg_1arg) == 1 );
-    static assert( NumberOfArgs!(dg_2args) == 2 );
-    static assert( NumberOfArgs!(dg_3args) == 3 );
-
-    // ** Test ReturnType(Tf) ** //
-
-    static assert( is( ReturnType!(fn_0args) == int ) );
-    static assert( is( ReturnType!(fn_1arg) == byte[] ) );
-    static assert( is( ReturnType!(fn_2args) == float[dchar] ) );
-    static assert( is( ReturnType!(fn_3args) == void ) );
-    static assert( is( ReturnType!(dg_0args) == int[] ) );
-    static assert( is( ReturnType!(dg_1arg) == real ) );
-    static assert( is( ReturnType!(dg_2args) == void ) );
-    static assert( is( ReturnType!(dg_3args) == dchar[wchar] ) );
-
-    // ** Test ArgType(Tf, n) ** //
-
-    static assert( is( ArgType!(fn_1arg, 1) == char ) );
-    static assert( is( ArgType!(fn_2args, 2) == int[] ) );
-    static assert( is( ArgType!(fn_3args, 3) == ifloat[byte] ) );
-    static assert( is( ArgType!(dg_2args, 1) == char[][char[]] ) );
-    static assert( is( ArgType!(dg_3args, 1) == byte ) );
-    static assert( is( ArgType!(dg_3args, 2) == short ) );
-
-    pragma(msg, "ftype: passed static unit tests.");
-}
-

File infrastructure/pyd/generators/func_gen.py

-f = open('func_gen.txt', 'w')
-
-template = """\
-        static if (ARGS > %s) {
-            ArgType!(typeof(fn), %s) arg%s;
-        }
-"""
-
-for i in range(10):
-    f.write(template % (i, i+1, i+1))

File infrastructure/pyd/generators/func_gen.txt

-        static if (ARGS > 0) {
-            ArgType!(typeof(fn), 1) arg1;
-        }
-        static if (ARGS > 1) {
-            ArgType!(typeof(fn), 2) arg2;
-        }
-        static if (ARGS > 2) {
-            ArgType!(typeof(fn), 3) arg3;
-        }
-        static if (ARGS > 3) {
-            ArgType!(typeof(fn), 4) arg4;
-        }
-        static if (ARGS > 4) {
-            ArgType!(typeof(fn), 5) arg5;
-        }
-        static if (ARGS > 5) {
-            ArgType!(typeof(fn), 6) arg6;
-        }
-        static if (ARGS > 6) {
-            ArgType!(typeof(fn), 7) arg7;
-        }
-        static if (ARGS > 7) {
-            ArgType!(typeof(fn), 8) arg8;
-        }
-        static if (ARGS > 8) {
-            ArgType!(typeof(fn), 9) arg9;
-        }
-        static if (ARGS > 9) {
-            ArgType!(typeof(fn), 10) arg10;
-        }

File infrastructure/pyd/generators/func_wrap.py

-f = open('func_wrap.txt', 'w')
-
-template = "d_type!(ArgType!(fn_t, %s))(PyTuple_GetItem(args, %s))"
-
-for i in range(1, 11):
-    f.write(" " * 8 + "} static if (MIN_ARGS <= %s && MAX_ARGS >= %s) {\n" % (i, i))
-    f.write(" " * 12 + "if (ARGS == %s) {\n" % i)
-    f.write(" " * 16 +    "static if (is(RetType : void)) {\n")
-    f.write(" " * 20 +        "fn(\n")
-    for j in range(i):
-        f.write(" " * 24 + template % (j+1, j))
-        if j < i-1:
-            f.write(',')
-        f.write('\n')
-    f.write(" " * 20 +        ");\n")
-    f.write(" " * 20 +        "Py_INCREF(Py_None);\n")
-    f.write(" " * 20 +        "ret = Py_None;\n")
-    f.write(" " * 16 +    "} else {\n")
-    f.write(" " * 20 +        "ret = _py( fn(\n")
-    for j in range(i):
-        f.write(" " * 24 + template % (j+1, j))
-        if j < i-1:
-            f.write(',')
-        f.write('\n')
-    f.write(" " * 20 +        ") );\n")
-    f.write(" " * 16 +    "}\n")
-    f.write(" " * 12 + "}\n")
-f.write (" " * 8 + "}")

File infrastructure/pyd/generators/func_wrap.txt

-        } static if (MIN_ARGS <= 1 && MAX_ARGS >= 1) {
-            if (ARGS == 1) {
-                static if (is(RetType : void)) {
-                    fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0))
-                    );
-                    Py_INCREF(Py_None);
-                    ret = Py_None;
-                } else {
-                    ret = _py( fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0))
-                    ) );
-                }
-            }
-        } static if (MIN_ARGS <= 2 && MAX_ARGS >= 2) {
-            if (ARGS == 2) {
-                static if (is(RetType : void)) {
-                    fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1))
-                    );
-                    Py_INCREF(Py_None);
-                    ret = Py_None;
-                } else {
-                    ret = _py( fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1))
-                    ) );
-                }
-            }
-        } static if (MIN_ARGS <= 3 && MAX_ARGS >= 3) {
-            if (ARGS == 3) {
-                static if (is(RetType : void)) {
-                    fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1)),
-                        d_type!(ArgType!(fn_t, 3))(PyTuple_GetItem(args, 2))
-                    );
-                    Py_INCREF(Py_None);
-                    ret = Py_None;
-                } else {
-                    ret = _py( fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1)),
-                        d_type!(ArgType!(fn_t, 3))(PyTuple_GetItem(args, 2))
-                    ) );
-                }
-            }
-        } static if (MIN_ARGS <= 4 && MAX_ARGS >= 4) {
-            if (ARGS == 4) {
-                static if (is(RetType : void)) {
-                    fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1)),
-                        d_type!(ArgType!(fn_t, 3))(PyTuple_GetItem(args, 2)),
-                        d_type!(ArgType!(fn_t, 4))(PyTuple_GetItem(args, 3))
-                    );
-                    Py_INCREF(Py_None);
-                    ret = Py_None;
-                } else {
-                    ret = _py( fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1)),
-                        d_type!(ArgType!(fn_t, 3))(PyTuple_GetItem(args, 2)),
-                        d_type!(ArgType!(fn_t, 4))(PyTuple_GetItem(args, 3))
-                    ) );
-                }
-            }
-        } static if (MIN_ARGS <= 5 && MAX_ARGS >= 5) {
-            if (ARGS == 5) {
-                static if (is(RetType : void)) {
-                    fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1)),
-                        d_type!(ArgType!(fn_t, 3))(PyTuple_GetItem(args, 2)),
-                        d_type!(ArgType!(fn_t, 4))(PyTuple_GetItem(args, 3)),
-                        d_type!(ArgType!(fn_t, 5))(PyTuple_GetItem(args, 4))
-                    );
-                    Py_INCREF(Py_None);
-                    ret = Py_None;
-                } else {
-                    ret = _py( fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1)),
-                        d_type!(ArgType!(fn_t, 3))(PyTuple_GetItem(args, 2)),
-                        d_type!(ArgType!(fn_t, 4))(PyTuple_GetItem(args, 3)),
-                        d_type!(ArgType!(fn_t, 5))(PyTuple_GetItem(args, 4))
-                    ) );
-                }
-            }
-        } static if (MIN_ARGS <= 6 && MAX_ARGS >= 6) {
-            if (ARGS == 6) {
-                static if (is(RetType : void)) {
-                    fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1)),
-                        d_type!(ArgType!(fn_t, 3))(PyTuple_GetItem(args, 2)),
-                        d_type!(ArgType!(fn_t, 4))(PyTuple_GetItem(args, 3)),
-                        d_type!(ArgType!(fn_t, 5))(PyTuple_GetItem(args, 4)),
-                        d_type!(ArgType!(fn_t, 6))(PyTuple_GetItem(args, 5))
-                    );
-                    Py_INCREF(Py_None);
-                    ret = Py_None;
-                } else {
-                    ret = _py( fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1)),
-                        d_type!(ArgType!(fn_t, 3))(PyTuple_GetItem(args, 2)),
-                        d_type!(ArgType!(fn_t, 4))(PyTuple_GetItem(args, 3)),
-                        d_type!(ArgType!(fn_t, 5))(PyTuple_GetItem(args, 4)),
-                        d_type!(ArgType!(fn_t, 6))(PyTuple_GetItem(args, 5))
-                    ) );
-                }
-            }
-        } static if (MIN_ARGS <= 7 && MAX_ARGS >= 7) {
-            if (ARGS == 7) {
-                static if (is(RetType : void)) {
-                    fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1)),
-                        d_type!(ArgType!(fn_t, 3))(PyTuple_GetItem(args, 2)),
-                        d_type!(ArgType!(fn_t, 4))(PyTuple_GetItem(args, 3)),
-                        d_type!(ArgType!(fn_t, 5))(PyTuple_GetItem(args, 4)),
-                        d_type!(ArgType!(fn_t, 6))(PyTuple_GetItem(args, 5)),
-                        d_type!(ArgType!(fn_t, 7))(PyTuple_GetItem(args, 6))
-                    );
-                    Py_INCREF(Py_None);
-                    ret = Py_None;
-                } else {
-                    ret = _py( fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1)),
-                        d_type!(ArgType!(fn_t, 3))(PyTuple_GetItem(args, 2)),
-                        d_type!(ArgType!(fn_t, 4))(PyTuple_GetItem(args, 3)),
-                        d_type!(ArgType!(fn_t, 5))(PyTuple_GetItem(args, 4)),
-                        d_type!(ArgType!(fn_t, 6))(PyTuple_GetItem(args, 5)),
-                        d_type!(ArgType!(fn_t, 7))(PyTuple_GetItem(args, 6))
-                    ) );
-                }
-            }
-        } static if (MIN_ARGS <= 8 && MAX_ARGS >= 8) {
-            if (ARGS == 8) {
-                static if (is(RetType : void)) {
-                    fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1)),
-                        d_type!(ArgType!(fn_t, 3))(PyTuple_GetItem(args, 2)),
-                        d_type!(ArgType!(fn_t, 4))(PyTuple_GetItem(args, 3)),
-                        d_type!(ArgType!(fn_t, 5))(PyTuple_GetItem(args, 4)),
-                        d_type!(ArgType!(fn_t, 6))(PyTuple_GetItem(args, 5)),
-                        d_type!(ArgType!(fn_t, 7))(PyTuple_GetItem(args, 6)),
-                        d_type!(ArgType!(fn_t, 8))(PyTuple_GetItem(args, 7))
-                    );
-                    Py_INCREF(Py_None);
-                    ret = Py_None;
-                } else {
-                    ret = _py( fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1)),
-                        d_type!(ArgType!(fn_t, 3))(PyTuple_GetItem(args, 2)),
-                        d_type!(ArgType!(fn_t, 4))(PyTuple_GetItem(args, 3)),
-                        d_type!(ArgType!(fn_t, 5))(PyTuple_GetItem(args, 4)),
-                        d_type!(ArgType!(fn_t, 6))(PyTuple_GetItem(args, 5)),
-                        d_type!(ArgType!(fn_t, 7))(PyTuple_GetItem(args, 6)),
-                        d_type!(ArgType!(fn_t, 8))(PyTuple_GetItem(args, 7))
-                    ) );
-                }
-            }
-        } static if (MIN_ARGS <= 9 && MAX_ARGS >= 9) {
-            if (ARGS == 9) {
-                static if (is(RetType : void)) {
-                    fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1)),
-                        d_type!(ArgType!(fn_t, 3))(PyTuple_GetItem(args, 2)),
-                        d_type!(ArgType!(fn_t, 4))(PyTuple_GetItem(args, 3)),
-                        d_type!(ArgType!(fn_t, 5))(PyTuple_GetItem(args, 4)),
-                        d_type!(ArgType!(fn_t, 6))(PyTuple_GetItem(args, 5)),
-                        d_type!(ArgType!(fn_t, 7))(PyTuple_GetItem(args, 6)),
-                        d_type!(ArgType!(fn_t, 8))(PyTuple_GetItem(args, 7)),
-                        d_type!(ArgType!(fn_t, 9))(PyTuple_GetItem(args, 8))
-                    );
-                    Py_INCREF(Py_None);
-                    ret = Py_None;
-                } else {
-                    ret = _py( fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1)),
-                        d_type!(ArgType!(fn_t, 3))(PyTuple_GetItem(args, 2)),
-                        d_type!(ArgType!(fn_t, 4))(PyTuple_GetItem(args, 3)),
-                        d_type!(ArgType!(fn_t, 5))(PyTuple_GetItem(args, 4)),
-                        d_type!(ArgType!(fn_t, 6))(PyTuple_GetItem(args, 5)),
-                        d_type!(ArgType!(fn_t, 7))(PyTuple_GetItem(args, 6)),
-                        d_type!(ArgType!(fn_t, 8))(PyTuple_GetItem(args, 7)),
-                        d_type!(ArgType!(fn_t, 9))(PyTuple_GetItem(args, 8))
-                    ) );
-                }
-            }
-        } static if (MIN_ARGS <= 10 && MAX_ARGS >= 10) {
-            if (ARGS == 10) {
-                static if (is(RetType : void)) {
-                    fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1)),
-                        d_type!(ArgType!(fn_t, 3))(PyTuple_GetItem(args, 2)),
-                        d_type!(ArgType!(fn_t, 4))(PyTuple_GetItem(args, 3)),
-                        d_type!(ArgType!(fn_t, 5))(PyTuple_GetItem(args, 4)),
-                        d_type!(ArgType!(fn_t, 6))(PyTuple_GetItem(args, 5)),
-                        d_type!(ArgType!(fn_t, 7))(PyTuple_GetItem(args, 6)),
-                        d_type!(ArgType!(fn_t, 8))(PyTuple_GetItem(args, 7)),
-                        d_type!(ArgType!(fn_t, 9))(PyTuple_GetItem(args, 8)),
-                        d_type!(ArgType!(fn_t, 10))(PyTuple_GetItem(args, 9))
-                    );
-                    Py_INCREF(Py_None);
-                    ret = Py_None;
-                } else {
-                    ret = _py( fn(
-                        d_type!(ArgType!(fn_t, 1))(PyTuple_GetItem(args, 0)),
-                        d_type!(ArgType!(fn_t, 2))(PyTuple_GetItem(args, 1)),
-                        d_type!(ArgType!(fn_t, 3))(PyTuple_GetItem(args, 2)),
-                        d_type!(ArgType!(fn_t, 4))(PyTuple_GetItem(args, 3)),
-                        d_type!(ArgType!(fn_t, 5))(PyTuple_GetItem(args, 4)),
-                        d_type!(ArgType!(fn_t, 6))(PyTuple_GetItem(args, 5)),
-                        d_type!(ArgType!(fn_t, 7))(PyTuple_GetItem(args, 6)),
-                        d_type!(ArgType!(fn_t, 8))(PyTuple_GetItem(args, 7)),
-                        d_type!(ArgType!(fn_t, 9))(PyTuple_GetItem(args, 8)),
-                        d_type!(ArgType!(fn_t, 10))(PyTuple_GetItem(args, 9))
-                    ) );
-                }
-            }
-        }

File infrastructure/pyd/generators/iterate.py

-import sys
-old_stdout = sys.stdout
-sys.stdout = file('iterate.txt', 'w')
-
-template = """\
-        } else static if (ARGS == %s) {
-            foreach (%s; t) {
-                temp = _make_pytuple(%s);
-                if (temp is null) StackContext.throwYield(new DPyYield(null));
-                StackContext.throwYield(new DPyYield(temp));
-            }"""
-
-def args(i):
-    return ['a%s' % i for i in range(0, i)]
-
-def pyargs(i):
-    return ['_py(%s)' % p for p in args(i)]
-
-for i in range(2, 11):
-    print template % (i, ', '.join(args(i)), ', '.join(pyargs(i)))
-print '        }'
-
-sys.stdout = old_stdout

File infrastructure/pyd/generators/iterate.txt

-        } else static if (ARGS == 2) {
-            foreach (a0, a1; t) {
-                temp = _make_pytuple(_py(a0), _py(a1));
-                if (temp is null) StackContext.throwYield(new DPyYield(null));
-                StackContext.throwYield(new DPyYield(temp));
-            }
-        } else static if (ARGS == 3) {
-            foreach (a0, a1, a2; t) {
-                temp = _make_pytuple(_py(a0), _py(a1), _py(a2));
-                if (temp is null) StackContext.throwYield(new DPyYield(null));
-                StackContext.throwYield(new DPyYield(temp));
-            }
-        } else static if (ARGS == 4) {
-            foreach (a0, a1, a2, a3; t) {
-                temp = _make_pytuple(_py(a0), _py(a1), _py(a2), _py(a3));
-                if (temp is null) StackContext.throwYield(new DPyYield(null));
-                StackContext.throwYield(new DPyYield(temp));
-            }
-        } else static if (ARGS == 5) {
-            foreach (a0, a1, a2, a3, a4; t) {
-                temp = _make_pytuple(_py(a0), _py(a1), _py(a2), _py(a3), _py(a4));
-                if (temp is null) StackContext.throwYield(new DPyYield(null));
-                StackContext.throwYield(new DPyYield(temp));
-            }
-        } else static if (ARGS == 6) {
-            foreach (a0, a1, a2, a3, a4, a5; t) {
-                temp = _make_pytuple(_py(a0), _py(a1), _py(a2), _py(a3), _py(a4), _py(a5));
-                if (temp is null) StackContext.throwYield(new DPyYield(null));
-                StackContext.throwYield(new DPyYield(temp));
-            }
-        } else static if (ARGS == 7) {
-            foreach (a0, a1, a2, a3, a4, a5, a6; t) {
-                temp = _make_pytuple(_py(a0), _py(a1), _py(a2), _py(a3), _py(a4), _py(a5), _py(a6));
-                if (temp is null) StackContext.throwYield(new DPyYield(null));
-                StackContext.throwYield(new DPyYield(temp));
-            }
-        } else static if (ARGS == 8) {
-            foreach (a0, a1, a2, a3, a4, a5, a6, a7; t) {
-                temp = _make_pytuple(_py(a0), _py(a1), _py(a2), _py(a3), _py(a4), _py(a5), _py(a6), _py(a7));
-                if (temp is null) StackContext.throwYield(new DPyYield(null));
-                StackContext.throwYield(new DPyYield(temp));
-            }
-        } else static if (ARGS == 9) {
-            foreach (a0, a1, a2, a3, a4, a5, a6, a7, a8; t) {
-                temp = _make_pytuple(_py(a0), _py(a1), _py(a2), _py(a3), _py(a4), _py(a5), _py(a6), _py(a7), _py(a8));
-                if (temp is null) StackContext.throwYield(new DPyYield(null));
-                StackContext.throwYield(new DPyYield(temp));
-            }
-        } else static if (ARGS == 10) {
-            foreach (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9; t) {
-                temp = _make_pytuple(_py(a0), _py(a1), _py(a2), _py(a3), _py(a4), _py(a5), _py(a6), _py(a7), _py(a8), _py(a9));
-                if (temp is null) StackContext.throwYield(new DPyYield(null));
-                StackContext.throwYield(new DPyYield(temp));
-            }
-        }

File infrastructure/pyd/generators/min_args.py

-import sys
-old_stdout = sys.stdout
-sys.stdout = open('min_args.txt', 'w')
-
-arg_template = """I!(%s)()"""
-
-template = """\
-\telse static if (is(typeof(fn(%s))))
-\t\tconst uint minArgs = %s;"""
-
-for i in range(21):
-    args = []
-    for j in range(i):
-        args.append(arg_template % (j,))
-    print template % (", ".join(args), i)
-
-sys.stdout = old_stdout
-

File infrastructure/pyd/generators/min_args.txt

-	else static if (is(typeof(fn())))
-		const uint minArgs = 0;
-	else static if (is(typeof(fn(I!(0)()))))
-		const uint minArgs = 1;
-	else static if (is(typeof(fn(I!(0)(), I!(1)()))))
-		const uint minArgs = 2;
-	else static if (is(typeof(fn(I!(0)(), I!(1)(), I!(2)()))))
-		const uint minArgs = 3;
-	else static if (is(typeof(fn(I!(0)(), I!(1)(), I!(2)(), I!(3)()))))
-		const uint minArgs = 4;
-	else static if (is(typeof(fn(I!(0)(), I!(1)(), I!(2)(), I!(3)(), I!(4)()))))
-		const uint minArgs = 5;
-	else static if (is(typeof(fn(I!(0)(), I!(1)(), I!(2)(), I!(3)(), I!(4)(), I!(5)()))))
-		const uint minArgs = 6;
-	else static if (is(typeof(fn(I!(0)(), I!(1)(), I!(2)(), I!(3)(), I!(4)(), I!(5)(), I!(6)()))))
-		const uint minArgs = 7;
-	else static if (is(typeof(fn(I!(0)(), I!(1)(), I!(2)(), I!(3)(), I!(4)(), I!(5)(), I!(6)(), I!(7)()))))
-		const uint minArgs = 8;
-	else static if (is(typeof(fn(I!(0)(), I!(1)(), I!(2)(), I!(3)(), I!(4)(), I!(5)(), I!(6)(), I!(7)(), I!(8)()))))
-		const uint minArgs = 9;
-	else static if (is(typeof(fn(I!(0)(), I!(1)(), I!(2)(), I!(3)(), I!(4)(), I!(5)(), I!(6)(), I!(7)(), I!(8)(), I!(9)()))))
-		const uint minArgs = 10;
-	else static if (is(typeof(fn(I!(0)(), I!(1)(), I!(2)(), I!(3)(), I!(4)(), I!(5)(), I!(6)(), I!(7)(), I!(8)(), I!(9)(), I!(10)()))))
-		const uint minArgs = 11;
-	else static if (is(typeof(fn(I!(0)(), I!(1)(), I!(2)(), I!(3)(), I!(4)(), I!(5)(), I!(6)(), I!(7)(), I!(8)(), I!(9)(), I!(10)(), I!(11)()))))
-		const uint minArgs = 12;
-	else static if (is(typeof(fn(I!(0)(), I!(1)(), I!(2)(), I!(3)(), I!(4)(), I!(5)(), I!(6)(), I!(7)(), I!(8)(), I!(9)(), I!(10)(), I!(11)(), I!(12)()))))
-		const uint minArgs = 13;
-	else static if (is(typeof(fn(I!(0)(), I!(1)(), I!(2)(), I!(3)(), I!(4)(), I!(5)(), I!(6)(), I!(7)(), I!(8)(), I!(9)(), I!(10)(), I!(11)(), I!(12)(), I!(13)()))))
-		const uint minArgs = 14;
-	else static if (is(typeof(fn(I!(0)(), I!(1)(), I!(2)(), I!(3)(), I!(4)(), I!(5)(), I!(6)(), I!(7)(), I!(8)(), I!(9)(), I!(10)(), I!(11)(), I!(12)(), I!(13)(), I!(14)()))))
-		const uint minArgs = 15;
-	else static if (is(typeof(fn(I!(0)(), I!(1)(), I!(2)(), I!(3)(), I!(4)(), I!(5)(), I!(6)(), I!(7)(), I!(8)(), I!(9)(), I!(10)(), I!(11)(), I!(12)(), I!(13)(), I!(14)(), I!(15)()))))