| 1 |
import sys |
|---|
| 2 |
old_stdout = sys.stdout |
|---|
| 3 |
sys.stdout = open('op_wrap.txt', 'w') |
|---|
| 4 |
|
|---|
| 5 |
binops = [ |
|---|
| 6 |
'Add', 'Sub', 'Mul', 'Div', 'Mod', 'And', 'Or', 'Xor', 'Shl', 'Shr', |
|---|
| 7 |
'UShr', 'Cat', 'AddAssign', 'SubAssign', 'MulAssign', 'DivAssign', |
|---|
| 8 |
'ModAssign', 'AndAssign', 'OrAssign', 'XorAssign', 'ShlAssign', 'ShrAssign', |
|---|
| 9 |
'UShrAssign', 'CatAssign', 'In', |
|---|
| 10 |
] |
|---|
| 11 |
|
|---|
| 12 |
uniops = [ |
|---|
| 13 |
'Neg', 'Pos', 'Com', |
|---|
| 14 |
] |
|---|
| 15 |
|
|---|
| 16 |
bin_template = """\ |
|---|
| 17 |
template op%s_wrap(T) { |
|---|
| 18 |
static if (is(typeof(&T.op%s))) { |
|---|
| 19 |
const binaryfunc op%s_wrap = &opfunc_binary_wrap!(T, T.op%s).func; |
|---|
| 20 |
} else { |
|---|
| 21 |
const binaryfunc op%s_wrap = null; |
|---|
| 22 |
} |
|---|
| 23 |
} |
|---|
| 24 |
|
|---|
| 25 |
""" |
|---|
| 26 |
|
|---|
| 27 |
uni_template = """\ |
|---|
| 28 |
template op%s_wrap(T) { |
|---|
| 29 |
static if (is(typeof(&T.op%s))) { |
|---|
| 30 |
const unaryfunc op%s_wrap = &opfunc_unary_wrap!(T, T.op%s).func; |
|---|
| 31 |
} else { |
|---|
| 32 |
const unaryfunc op%s_wrap = null; |
|---|
| 33 |
} |
|---|
| 34 |
} |
|---|
| 35 |
""" |
|---|
| 36 |
|
|---|
| 37 |
for op in binops: |
|---|
| 38 |
print bin_template % (op, op, op, op, op) |
|---|
| 39 |
|
|---|
| 40 |
for op in uniops: |
|---|
| 41 |
print uni_template % (op, op, op, op, op) |
|---|
| 42 |
|
|---|
| 43 |
sys.stdout = old_stdout |
|---|