Skip to content

Commit e1a3e4a

Browse files
committed
trying to fix clang msvc issue
1 parent f831cb6 commit e1a3e4a

3 files changed

Lines changed: 39 additions & 9 deletions

File tree

include/pythonic/pythonicDispatch.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ namespace pythonic
9797
{
9898
};
9999

100+
// Explicit specialization declarations
101+
#include "pythonicDispatchDeclarations.hpp"
102+
100103
// Helper to get function
101104
template <typename Op>
102105
inline BinaryOpFunc get_op_func(pythonic::vars::TypeTag left, pythonic::vars::TypeTag right)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Generated declarations for OpTable specializations
2+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<Add>::table;
3+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<Sub>::table;
4+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<Mul>::table;
5+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<Div>::table;
6+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<Mod>::table;
7+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<Eq>::table;
8+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<Ne>::table;
9+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<Gt>::table;
10+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<Ge>::table;
11+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<Lt>::table;
12+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<Le>::table;
13+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<BitAnd>::table;
14+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<BitOr>::table;
15+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<BitXor>::table;
16+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<ShiftLeft>::table;
17+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<ShiftRight>::table;
18+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<LogicalAnd>::table;
19+
template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<LogicalOr>::table;

scripts/gen_dispatch_stubs.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# gen_dispatch_stubs.py
22
import os
3+
import sys
34

45
type_tags = [
56
"none", "int", "float", "string", "bool", "double", "long", "long_long", "long_double",
@@ -37,6 +38,21 @@
3738
"land": "and", "lor": "or"
3839
}
3940

41+
# OpTable map to Struct names
42+
op_struct_map = {
43+
"add": "Add", "sub": "Sub", "mul": "Mul", "div": "Div", "mod": "Mod",
44+
"eq": "Eq", "ne": "Ne", "gt": "Gt", "ge": "Ge", "lt": "Lt", "le": "Le",
45+
"band": "BitAnd", "bor": "BitOr", "bxor": "BitXor",
46+
"shl": "ShiftLeft", "shr": "ShiftRight",
47+
"land": "LogicalAnd", "lor": "LogicalOr"
48+
}
49+
50+
if len(sys.argv) > 1 and sys.argv[1] == 'declarations':
51+
print("// Generated declarations for OpTable specializations")
52+
for opname, opstruct_name in op_struct_map.items():
53+
print(f"template<> const std::array<std::array<BinaryOpFunc, TypeTagCount>, TypeTagCount> OpTable<{opstruct_name}>::table;")
54+
sys.exit(0)
55+
4056
print("#include \"pythonic/pythonicDispatchForwardDecls.hpp\"")
4157
print("#include \"pythonic/pythonicVars.hpp\"")
4258
print("#include \"pythonic/pythonicError.hpp\"")
@@ -810,16 +826,8 @@ def print_cast(operand, varname, t, ctype):
810826

811827
print("}")
812828

813-
# OpTable map to Struct names
814-
op_struct_map = {
815-
"add": "Add", "sub": "Sub", "mul": "Mul", "div": "Div", "mod": "Mod",
816-
"eq": "Eq", "ne": "Ne", "gt": "Gt", "ge": "Ge", "lt": "Lt", "le": "Le",
817-
"band": "BitAnd", "bor": "BitOr", "bxor": "BitXor",
818-
"shl": "ShiftLeft", "shr": "ShiftRight",
819-
"land": "LogicalAnd", "lor": "LogicalOr"
820-
}
821-
822829
# Generate OpTable initializations
830+
823831
for opname, opstruct_name in op_struct_map.items():
824832
actual_op_func = ops[opname] # e.g. "add"
825833
print(f"\n// OpTable initialization for {opstruct_name}")

0 commit comments

Comments
 (0)