瀏覽代碼

Fixed macros for msvc

gbeurier 7 年之前
父節點
當前提交
cbda96dc93
共有 2 個文件被更改,包括 39 次插入21 次删除
  1. 26 19
      src/artis/kernel/AbstractCoupledModel.hpp
  2. 13 2
      src/artis/kernel/Macro.hpp

+ 26 - 19
src/artis/kernel/AbstractCoupledModel.hpp

@@ -350,23 +350,23 @@ public:
     }
 
 protected:
-    // void change_internal(unsigned int index, double T::* var)
-    // {
-    //     submodel_internals.erase(index);
-    //     Internals < T, U, V >::internal(index, var);
-    // }
-
-    // void change_internal(unsigned int index, int T::* var)
-    // {
-    //     submodel_internals.erase(index);
-    //     Internals < T, U, V >::internalI(index, var);
-    // }
-
-    // void change_internal(unsigned int index, bool T::* var)
-    // {
-    //     submodel_internals.erase(index);
-    //     Internals < T, U, V >::internalB(index, var);
-    // }
+     void change_internal(unsigned int index, double T::* var)
+     {
+         submodel_internals.erase(index);
+         Internals < T, U, V >::internal(index, var);
+     }
+
+     void change_internal(unsigned int index, int T::* var)
+     {
+         submodel_internals.erase(index);
+         Internals < T, U, V >::internalI(index, var);
+     }
+
+     void change_internal(unsigned int index, bool T::* var)
+     {
+         submodel_internals.erase(index);
+         Internals < T, U, V >::internalB(index, var);
+     }
 
     void internal_(unsigned int index, type* model, int sub_index)
     {
@@ -429,7 +429,10 @@ private:
 #define LIST_S_3(L1, L2, L3) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3) }
 #define LIST_S_2(L1, L2) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2) }
 #define LIST_S_1(L1) { UNWRAP_ITEM_S(L1) }
-#define UNWRAP_S_2(...) GET_MACRO(__VA_ARGS__, LIST_S_16, LIST_S_15, LIST_S_14, LIST_S_13, LIST_S_12, LIST_S_11, LIST_S_10, LIST_S_9, LIST_S_8, LIST_S_7, LIST_S_6, LIST_S_5, LIST_S_4, LIST_S_3, LIST_S_2, LIST_S_1)(__VA_ARGS__)
+#define LIST_S_(N) LIST_S_##N
+#define LIST_S_EVAL(N) LIST_S_(N)
+#define UNWRAP_S_2(...) EXPAND( LIST_S_EVAL(EXPAND( PP_NARG(__VA_ARGS__) ))(__VA_ARGS__) )
+//#define UNWRAP_S_2(...) GET_MACRO(__VA_ARGS__, LIST_S_16, LIST_S_15, LIST_S_14, LIST_S_13, LIST_S_12, LIST_S_11, LIST_S_10, LIST_S_9, LIST_S_8, LIST_S_7, LIST_S_6, LIST_S_5, LIST_S_4, LIST_S_3, LIST_S_2, LIST_S_1)(__VA_ARGS__)
 #define InternalsS(L) I_(UNWRAP_S_2 L)
 
 #define ITEM_Sub(index, model) { index, model }
@@ -450,9 +453,13 @@ private:
 #define LIST_Sub_3(L1, L2, L3) { UNWRAP_ITEM_Sub(L1), UNWRAP_ITEM_Sub(L2), UNWRAP_ITEM_Sub(L3) }
 #define LIST_Sub_2(L1, L2) { UNWRAP_ITEM_Sub(L1), UNWRAP_ITEM_Sub(L2) }
 #define LIST_Sub_1(L1) { UNWRAP_ITEM_Sub(L1) }
-#define UNWRAP_Sub_2(...) GET_MACRO(__VA_ARGS__, LIST_Sub_16, LIST_Sub_15, LIST_Sub_14, LIST_Sub_13, LIST_Sub_12, LIST_Sub_11, LIST_Sub_10, LIST_Sub_9, LIST_Sub_8, LIST_Sub_7, LIST_Sub_6, LIST_Sub_5, LIST_Sub_4, LIST_Sub_3, LIST_Sub_2, LIST_Sub_1)(__VA_ARGS__)
+#define LIST_Sub_(N) LIST_Sub_##N
+#define LIST_Sub_EVAL(N) LIST_Sub_(N)
+#define UNWRAP_Sub_2(...) EXPAND( LIST_Sub_EVAL(EXPAND( PP_NARG(__VA_ARGS__) ))(__VA_ARGS__) )
+//#define UNWRAP_Sub_2(...) GET_MACRO(__VA_ARGS__, LIST_Sub_16, LIST_Sub_15, LIST_Sub_14, LIST_Sub_13, LIST_Sub_12, LIST_Sub_11, LIST_Sub_10, LIST_Sub_9, LIST_Sub_8, LIST_Sub_7, LIST_Sub_6, LIST_Sub_5, LIST_Sub_4, LIST_Sub_3, LIST_Sub_2, LIST_Sub_1)(__VA_ARGS__)
 #define Submodels(L) SM_(UNWRAP_Sub_2 L)
 
+
 } }
 
 #endif

+ 13 - 2
src/artis/kernel/Macro.hpp

@@ -46,7 +46,18 @@
 #define LIST_3(L1, L2, L3) { UNWRAP_ITEM(L1), UNWRAP_ITEM(L2), UNWRAP_ITEM(L3) }
 #define LIST_2(L1, L2) { UNWRAP_ITEM(L1), UNWRAP_ITEM(L2) }
 #define LIST_1(L1) { UNWRAP_ITEM(L1) }
-#define GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, NAME, ...) NAME
-#define UNWRAP2(...) GET_MACRO(__VA_ARGS__, LIST_16, LIST_15, LIST_14, LIST_13, LIST_12, LIST_11, LIST_10, LIST_9, LIST_8, LIST_7, LIST_6, LIST_5, LIST_4, LIST_3, LIST_2, LIST_1)(__VA_ARGS__)
+//#define GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, NAME, ...) NAME
+//#define UNWRAP2(...) GET_MACRO(__VA_ARGS__, LIST_16, LIST_15, LIST_14, LIST_13, LIST_12, LIST_11, LIST_10, LIST_9, LIST_8, LIST_7, LIST_6, LIST_5, LIST_4, LIST_3, LIST_2, LIST_1)(__VA_ARGS__)
+
+//MVSC compatibility
+#define EXPAND(X) X
+#define PP_NARG(...) EXPAND( PP_NARG_(__VA_ARGS__, PP_RSEQ_N()) )
+#define PP_NARG_(...) EXPAND( PP_ARG_N(__VA_ARGS__) )
+#define PP_ARG_N(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10_,_11,_12,_13,_14,_15,_16,N, ...) N
+#define PP_RSEQ_N() 16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
+#define LIST_(N) LIST_##N
+#define LIST_EVAL(N) LIST_(N)
+#define UNWRAP2(...) EXPAND( LIST_EVAL(EXPAND( PP_NARG(__VA_ARGS__) ))(__VA_ARGS__) )
+
 
 #endif