From 9e474e4cc24a07110d129e41d1a1de24c2033b89 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 13 Mar 2021 00:15:05 +0100 Subject: [PATCH] Provide more information for GSI error messages. --- src/gsi/gsi/gsiMethods.h | 272 ++++++++++++++++----------------- src/gsi/gsi/gsiSerialisation.h | 121 ++++++++++----- 2 files changed, 222 insertions(+), 171 deletions(-) diff --git a/src/gsi/gsi/gsiMethods.h b/src/gsi/gsi/gsiMethods.h index 169e540c9..4a12754a1 100644 --- a/src/gsi/gsi/gsiMethods.h +++ b/src/gsi/gsi/gsiMethods.h @@ -939,7 +939,7 @@ constant (const std::string &name, const R &v, const std::string &doc = std::str #define _FUNCARGLIST A1 #define _ADDARGS this->template add_arg (m_s1); #define _GETARGVARS tl::Heap heap;\ - A1 a1 = args ? args.template read (heap) : m_s1.init (); + A1 a1 = args ? args.template read (heap, &m_s1) : m_s1.init (); #define _ARGVARLIST a1 #define _ARGSPECARGS s1 #define _ARGSPEC const ArgSpec &s1 @@ -973,8 +973,8 @@ constant (const std::string &name, const R &v, const std::string &doc = std::str #define _ADDARGS this->template add_arg (m_s1); \ this->template add_arg (m_s2); #define _GETARGVARS tl::Heap heap;\ - A1 a1 = args ? args.template read (heap) : m_s1.init (); \ - A2 a2 = args ? args.template read (heap) : m_s2.init (); + A1 a1 = args ? args.template read (heap, &m_s1) : m_s1.init (); \ + A2 a2 = args ? args.template read (heap, &m_s2) : m_s2.init (); #define _ARGVARLIST a1, a2 #define _ARGSPECARGS s1, s2 #define _ARGSPEC const ArgSpec &s1, const ArgSpec &s2 @@ -1010,9 +1010,9 @@ constant (const std::string &name, const R &v, const std::string &doc = std::str this->template add_arg (m_s2); \ this->template add_arg (m_s3); #define _GETARGVARS tl::Heap heap;\ - A1 a1 = args ? args.template read (heap) : m_s1.init (); \ - A2 a2 = args ? args.template read (heap) : m_s2.init (); \ - A3 a3 = args ? args.template read (heap) : m_s3.init (); + A1 a1 = args ? args.template read (heap, &m_s1) : m_s1.init (); \ + A2 a2 = args ? args.template read (heap, &m_s2) : m_s2.init (); \ + A3 a3 = args ? args.template read (heap, &m_s3) : m_s3.init (); #define _ARGVARLIST a1, a2, a3 #define _ARGSPECARGS s1, s2, s3 #define _ARGSPEC const ArgSpec &s1, const ArgSpec &s2, const ArgSpec &s3 @@ -1050,10 +1050,10 @@ constant (const std::string &name, const R &v, const std::string &doc = std::str this->template add_arg (m_s3); \ this->template add_arg (m_s4); #define _GETARGVARS tl::Heap heap;\ - A1 a1 = args ? args.template read (heap) : m_s1.init (); \ - A2 a2 = args ? args.template read (heap) : m_s2.init (); \ - A3 a3 = args ? args.template read (heap) : m_s3.init (); \ - A4 a4 = args ? args.template read (heap) : m_s4.init (); + A1 a1 = args ? args.template read (heap, &m_s1) : m_s1.init (); \ + A2 a2 = args ? args.template read (heap, &m_s2) : m_s2.init (); \ + A3 a3 = args ? args.template read (heap, &m_s3) : m_s3.init (); \ + A4 a4 = args ? args.template read (heap, &m_s4) : m_s4.init (); #define _ARGVARLIST a1, a2, a3, a4 #define _ARGSPECARGS s1, s2, s3, s4 #define _ARGSPEC const ArgSpec &s1, const ArgSpec &s2, const ArgSpec &s3, const ArgSpec &s4 @@ -1093,11 +1093,11 @@ constant (const std::string &name, const R &v, const std::string &doc = std::str this->template add_arg (m_s4); \ this->template add_arg (m_s5); #define _GETARGVARS tl::Heap heap;\ - A1 a1 = args ? args.template read (heap) : m_s1.init (); \ - A2 a2 = args ? args.template read (heap) : m_s2.init (); \ - A3 a3 = args ? args.template read (heap) : m_s3.init (); \ - A4 a4 = args ? args.template read (heap) : m_s4.init (); \ - A5 a5 = args ? args.template read (heap) : m_s5.init (); + A1 a1 = args ? args.template read (heap, &m_s1) : m_s1.init (); \ + A2 a2 = args ? args.template read (heap, &m_s2) : m_s2.init (); \ + A3 a3 = args ? args.template read (heap, &m_s3) : m_s3.init (); \ + A4 a4 = args ? args.template read (heap, &m_s4) : m_s4.init (); \ + A5 a5 = args ? args.template read (heap, &m_s5) : m_s5.init (); #define _ARGVARLIST a1, a2, a3, a4, a5 #define _ARGSPECARGS s1, s2, s3, s4, s5 #define _ARGSPEC const ArgSpec &s1, const ArgSpec &s2, const ArgSpec &s3, const ArgSpec &s4, const ArgSpec &s5 @@ -1139,12 +1139,12 @@ constant (const std::string &name, const R &v, const std::string &doc = std::str this->template add_arg (m_s5); \ this->template add_arg (m_s6); #define _GETARGVARS tl::Heap heap;\ - A1 a1 = args ? args.template read (heap) : m_s1.init (); \ - A2 a2 = args ? args.template read (heap) : m_s2.init (); \ - A3 a3 = args ? args.template read (heap) : m_s3.init (); \ - A4 a4 = args ? args.template read (heap) : m_s4.init (); \ - A5 a5 = args ? args.template read (heap) : m_s5.init (); \ - A6 a6 = args ? args.template read (heap) : m_s6.init (); + A1 a1 = args ? args.template read (heap, &m_s1) : m_s1.init (); \ + A2 a2 = args ? args.template read (heap, &m_s2) : m_s2.init (); \ + A3 a3 = args ? args.template read (heap, &m_s3) : m_s3.init (); \ + A4 a4 = args ? args.template read (heap, &m_s4) : m_s4.init (); \ + A5 a5 = args ? args.template read (heap, &m_s5) : m_s5.init (); \ + A6 a6 = args ? args.template read (heap, &m_s6) : m_s6.init (); #define _ARGVARLIST a1, a2, a3, a4, a5, a6 #define _ARGSPECARGS s1, s2, s3, s4, s5, s6 #define _ARGSPEC const ArgSpec &s1, const ArgSpec &s2, const ArgSpec &s3, const ArgSpec &s4, const ArgSpec &s5, const ArgSpec &s6 @@ -1188,13 +1188,13 @@ constant (const std::string &name, const R &v, const std::string &doc = std::str this->template add_arg (m_s6); \ this->template add_arg (m_s7); #define _GETARGVARS tl::Heap heap;\ - A1 a1 = args ? args.template read (heap) : m_s1.init (); \ - A2 a2 = args ? args.template read (heap) : m_s2.init (); \ - A3 a3 = args ? args.template read (heap) : m_s3.init (); \ - A4 a4 = args ? args.template read (heap) : m_s4.init (); \ - A5 a5 = args ? args.template read (heap) : m_s5.init (); \ - A6 a6 = args ? args.template read (heap) : m_s6.init (); \ - A7 a7 = args ? args.template read (heap) : m_s7.init (); + A1 a1 = args ? args.template read (heap, &m_s1) : m_s1.init (); \ + A2 a2 = args ? args.template read (heap, &m_s2) : m_s2.init (); \ + A3 a3 = args ? args.template read (heap, &m_s3) : m_s3.init (); \ + A4 a4 = args ? args.template read (heap, &m_s4) : m_s4.init (); \ + A5 a5 = args ? args.template read (heap, &m_s5) : m_s5.init (); \ + A6 a6 = args ? args.template read (heap, &m_s6) : m_s6.init (); \ + A7 a7 = args ? args.template read (heap, &m_s7) : m_s7.init (); #define _ARGVARLIST a1, a2, a3, a4, a5, a6, a7 #define _ARGSPECARGS s1, s2, s3, s4, s5, s6, s7 #define _ARGSPEC const ArgSpec &s1, const ArgSpec &s2, const ArgSpec &s3, const ArgSpec &s4, const ArgSpec &s5, const ArgSpec &s6, const ArgSpec &s7 @@ -1240,14 +1240,14 @@ constant (const std::string &name, const R &v, const std::string &doc = std::str this->template add_arg (m_s7); \ this->template add_arg (m_s8); #define _GETARGVARS tl::Heap heap;\ - A1 a1 = args ? args.template read (heap) : m_s1.init (); \ - A2 a2 = args ? args.template read (heap) : m_s2.init (); \ - A3 a3 = args ? args.template read (heap) : m_s3.init (); \ - A4 a4 = args ? args.template read (heap) : m_s4.init (); \ - A5 a5 = args ? args.template read (heap) : m_s5.init (); \ - A6 a6 = args ? args.template read (heap) : m_s6.init (); \ - A7 a7 = args ? args.template read (heap) : m_s7.init (); \ - A8 a8 = args ? args.template read (heap) : m_s8.init (); + A1 a1 = args ? args.template read (heap, &m_s1) : m_s1.init (); \ + A2 a2 = args ? args.template read (heap, &m_s2) : m_s2.init (); \ + A3 a3 = args ? args.template read (heap, &m_s3) : m_s3.init (); \ + A4 a4 = args ? args.template read (heap, &m_s4) : m_s4.init (); \ + A5 a5 = args ? args.template read (heap, &m_s5) : m_s5.init (); \ + A6 a6 = args ? args.template read (heap, &m_s6) : m_s6.init (); \ + A7 a7 = args ? args.template read (heap, &m_s7) : m_s7.init (); \ + A8 a8 = args ? args.template read (heap, &m_s8) : m_s8.init (); #define _ARGVARLIST a1, a2, a3, a4, a5, a6, a7, a8 #define _ARGSPECARGS s1, s2, s3, s4, s5, s6, s7, s8 #define _ARGSPEC const ArgSpec &s1, const ArgSpec &s2, const ArgSpec &s3, const ArgSpec &s4, const ArgSpec &s5, const ArgSpec &s6, const ArgSpec &s7, const ArgSpec &s8 @@ -1295,15 +1295,15 @@ constant (const std::string &name, const R &v, const std::string &doc = std::str this->template add_arg (m_s8); \ this->template add_arg (m_s9); #define _GETARGVARS tl::Heap heap;\ - A1 a1 = args ? args.template read (heap) : m_s1.init (); \ - A2 a2 = args ? args.template read (heap) : m_s2.init (); \ - A3 a3 = args ? args.template read (heap) : m_s3.init (); \ - A4 a4 = args ? args.template read (heap) : m_s4.init (); \ - A5 a5 = args ? args.template read (heap) : m_s5.init (); \ - A6 a6 = args ? args.template read (heap) : m_s6.init (); \ - A7 a7 = args ? args.template read (heap) : m_s7.init (); \ - A8 a8 = args ? args.template read (heap) : m_s8.init (); \ - A9 a9 = args ? args.template read (heap) : m_s9.init (); + A1 a1 = args ? args.template read (heap, &m_s1) : m_s1.init (); \ + A2 a2 = args ? args.template read (heap, &m_s2) : m_s2.init (); \ + A3 a3 = args ? args.template read (heap, &m_s3) : m_s3.init (); \ + A4 a4 = args ? args.template read (heap, &m_s4) : m_s4.init (); \ + A5 a5 = args ? args.template read (heap, &m_s5) : m_s5.init (); \ + A6 a6 = args ? args.template read (heap, &m_s6) : m_s6.init (); \ + A7 a7 = args ? args.template read (heap, &m_s7) : m_s7.init (); \ + A8 a8 = args ? args.template read (heap, &m_s8) : m_s8.init (); \ + A9 a9 = args ? args.template read (heap, &m_s9) : m_s9.init (); #define _ARGVARLIST a1, a2, a3, a4, a5, a6, a7, a8, a9 #define _ARGSPECARGS s1, s2, s3, s4, s5, s6, s7, s8, s9 #define _ARGSPEC const ArgSpec &s1, const ArgSpec &s2, const ArgSpec &s3, const ArgSpec &s4, const ArgSpec &s5, const ArgSpec &s6, const ArgSpec &s7, const ArgSpec &s8, const ArgSpec &s9 @@ -1353,16 +1353,16 @@ constant (const std::string &name, const R &v, const std::string &doc = std::str this->template add_arg (m_s9); \ this->template add_arg (m_s10); #define _GETARGVARS tl::Heap heap;\ - A1 a1 = args ? args.template read (heap) : m_s1.init (); \ - A2 a2 = args ? args.template read (heap) : m_s2.init (); \ - A3 a3 = args ? args.template read (heap) : m_s3.init (); \ - A4 a4 = args ? args.template read (heap) : m_s4.init (); \ - A5 a5 = args ? args.template read (heap) : m_s5.init (); \ - A6 a6 = args ? args.template read (heap) : m_s6.init (); \ - A7 a7 = args ? args.template read (heap) : m_s7.init (); \ - A8 a8 = args ? args.template read (heap) : m_s8.init (); \ - A9 a9 = args ? args.template read (heap) : m_s9.init (); \ - A10 a10 = args ? args.template read (heap) : m_s10.init (); + A1 a1 = args ? args.template read (heap, &m_s1) : m_s1.init (); \ + A2 a2 = args ? args.template read (heap, &m_s2) : m_s2.init (); \ + A3 a3 = args ? args.template read (heap, &m_s3) : m_s3.init (); \ + A4 a4 = args ? args.template read (heap, &m_s4) : m_s4.init (); \ + A5 a5 = args ? args.template read (heap, &m_s5) : m_s5.init (); \ + A6 a6 = args ? args.template read (heap, &m_s6) : m_s6.init (); \ + A7 a7 = args ? args.template read (heap, &m_s7) : m_s7.init (); \ + A8 a8 = args ? args.template read (heap, &m_s8) : m_s8.init (); \ + A9 a9 = args ? args.template read (heap, &m_s9) : m_s9.init (); \ + A10 a10 = args ? args.template read (heap, &m_s10) : m_s10.init (); #define _ARGVARLIST a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 #define _ARGSPECARGS s1, s2, s3, s4, s5, s6, s7, s8, s9, s10 #define _ARGSPEC const ArgSpec &s1, const ArgSpec &s2, const ArgSpec &s3, const ArgSpec &s4, const ArgSpec &s5, const ArgSpec &s6, const ArgSpec &s7, const ArgSpec &s8, const ArgSpec &s9, const ArgSpec &s10 @@ -1414,17 +1414,17 @@ constant (const std::string &name, const R &v, const std::string &doc = std::str this->template add_arg (m_s10); \ this->template add_arg (m_s11); #define _GETARGVARS tl::Heap heap;\ - A1 a1 = args ? args.template read (heap) : m_s1.init (); \ - A2 a2 = args ? args.template read (heap) : m_s2.init (); \ - A3 a3 = args ? args.template read (heap) : m_s3.init (); \ - A4 a4 = args ? args.template read (heap) : m_s4.init (); \ - A5 a5 = args ? args.template read (heap) : m_s5.init (); \ - A6 a6 = args ? args.template read (heap) : m_s6.init (); \ - A7 a7 = args ? args.template read (heap) : m_s7.init (); \ - A8 a8 = args ? args.template read (heap) : m_s8.init (); \ - A9 a9 = args ? args.template read (heap) : m_s9.init (); \ - A10 a10 = args ? args.template read (heap) : m_s10.init (); \ - A11 a11 = args ? args.template read (heap) : m_s11.init (); + A1 a1 = args ? args.template read (heap, &m_s1) : m_s1.init (); \ + A2 a2 = args ? args.template read (heap, &m_s2) : m_s2.init (); \ + A3 a3 = args ? args.template read (heap, &m_s3) : m_s3.init (); \ + A4 a4 = args ? args.template read (heap, &m_s4) : m_s4.init (); \ + A5 a5 = args ? args.template read (heap, &m_s5) : m_s5.init (); \ + A6 a6 = args ? args.template read (heap, &m_s6) : m_s6.init (); \ + A7 a7 = args ? args.template read (heap, &m_s7) : m_s7.init (); \ + A8 a8 = args ? args.template read (heap, &m_s8) : m_s8.init (); \ + A9 a9 = args ? args.template read (heap, &m_s9) : m_s9.init (); \ + A10 a10 = args ? args.template read (heap, &m_s10) : m_s10.init (); \ + A11 a11 = args ? args.template read (heap, &m_s11) : m_s11.init (); #define _ARGVARLIST a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11 #define _ARGSPECARGS s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11 #define _ARGSPEC const ArgSpec &s1, const ArgSpec &s2, const ArgSpec &s3, const ArgSpec &s4, const ArgSpec &s5, const ArgSpec &s6, const ArgSpec &s7, const ArgSpec &s8, const ArgSpec &s9, const ArgSpec &s10, const ArgSpec &s11 @@ -1478,18 +1478,18 @@ constant (const std::string &name, const R &v, const std::string &doc = std::str this->template add_arg (m_s11); \ this->template add_arg (m_s12); #define _GETARGVARS tl::Heap heap;\ - A1 a1 = args ? args.template read (heap) : m_s1.init (); \ - A2 a2 = args ? args.template read (heap) : m_s2.init (); \ - A3 a3 = args ? args.template read (heap) : m_s3.init (); \ - A4 a4 = args ? args.template read (heap) : m_s4.init (); \ - A5 a5 = args ? args.template read (heap) : m_s5.init (); \ - A6 a6 = args ? args.template read (heap) : m_s6.init (); \ - A7 a7 = args ? args.template read (heap) : m_s7.init (); \ - A8 a8 = args ? args.template read (heap) : m_s8.init (); \ - A9 a9 = args ? args.template read (heap) : m_s9.init (); \ - A10 a10 = args ? args.template read (heap) : m_s10.init (); \ - A11 a11 = args ? args.template read (heap) : m_s11.init (); \ - A12 a12 = args ? args.template read (heap) : m_s12.init (); + A1 a1 = args ? args.template read (heap, &m_s1) : m_s1.init (); \ + A2 a2 = args ? args.template read (heap, &m_s2) : m_s2.init (); \ + A3 a3 = args ? args.template read (heap, &m_s3) : m_s3.init (); \ + A4 a4 = args ? args.template read (heap, &m_s4) : m_s4.init (); \ + A5 a5 = args ? args.template read (heap, &m_s5) : m_s5.init (); \ + A6 a6 = args ? args.template read (heap, &m_s6) : m_s6.init (); \ + A7 a7 = args ? args.template read (heap, &m_s7) : m_s7.init (); \ + A8 a8 = args ? args.template read (heap, &m_s8) : m_s8.init (); \ + A9 a9 = args ? args.template read (heap, &m_s9) : m_s9.init (); \ + A10 a10 = args ? args.template read (heap, &m_s10) : m_s10.init (); \ + A11 a11 = args ? args.template read (heap, &m_s11) : m_s11.init (); \ + A12 a12 = args ? args.template read (heap, &m_s12) : m_s12.init (); #define _ARGVARLIST a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12 #define _ARGSPECARGS s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12 #define _ARGSPEC const ArgSpec &s1, const ArgSpec &s2, const ArgSpec &s3, const ArgSpec &s4, const ArgSpec &s5, const ArgSpec &s6, const ArgSpec &s7, const ArgSpec &s8, const ArgSpec &s9, const ArgSpec &s10, const ArgSpec &s11, const ArgSpec &s12 @@ -1545,19 +1545,19 @@ constant (const std::string &name, const R &v, const std::string &doc = std::str this->template add_arg (m_s12); \ this->template add_arg (m_s13); #define _GETARGVARS tl::Heap heap;\ - A1 a1 = args ? args.template read (heap) : m_s1.init (); \ - A2 a2 = args ? args.template read (heap) : m_s2.init (); \ - A3 a3 = args ? args.template read (heap) : m_s3.init (); \ - A4 a4 = args ? args.template read (heap) : m_s4.init (); \ - A5 a5 = args ? args.template read (heap) : m_s5.init (); \ - A6 a6 = args ? args.template read (heap) : m_s6.init (); \ - A7 a7 = args ? args.template read (heap) : m_s7.init (); \ - A8 a8 = args ? args.template read (heap) : m_s8.init (); \ - A9 a9 = args ? args.template read (heap) : m_s9.init (); \ - A10 a10 = args ? args.template read (heap) : m_s10.init (); \ - A11 a11 = args ? args.template read (heap) : m_s11.init (); \ - A12 a12 = args ? args.template read (heap) : m_s12.init (); \ - A13 a13 = args ? args.template read (heap) : m_s13.init (); + A1 a1 = args ? args.template read (heap, &m_s1) : m_s1.init (); \ + A2 a2 = args ? args.template read (heap, &m_s2) : m_s2.init (); \ + A3 a3 = args ? args.template read (heap, &m_s3) : m_s3.init (); \ + A4 a4 = args ? args.template read (heap, &m_s4) : m_s4.init (); \ + A5 a5 = args ? args.template read (heap, &m_s5) : m_s5.init (); \ + A6 a6 = args ? args.template read (heap, &m_s6) : m_s6.init (); \ + A7 a7 = args ? args.template read (heap, &m_s7) : m_s7.init (); \ + A8 a8 = args ? args.template read (heap, &m_s8) : m_s8.init (); \ + A9 a9 = args ? args.template read (heap, &m_s9) : m_s9.init (); \ + A10 a10 = args ? args.template read (heap, &m_s10) : m_s10.init (); \ + A11 a11 = args ? args.template read (heap, &m_s11) : m_s11.init (); \ + A12 a12 = args ? args.template read (heap, &m_s12) : m_s12.init (); \ + A13 a13 = args ? args.template read (heap, &m_s13) : m_s13.init (); #define _ARGVARLIST a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13 #define _ARGSPECARGS s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13 #define _ARGSPEC const ArgSpec &s1, const ArgSpec &s2, const ArgSpec &s3, const ArgSpec &s4, const ArgSpec &s5, const ArgSpec &s6, const ArgSpec &s7, const ArgSpec &s8, const ArgSpec &s9, const ArgSpec &s10, const ArgSpec &s11, const ArgSpec &s12, const ArgSpec &s13 @@ -1615,20 +1615,20 @@ constant (const std::string &name, const R &v, const std::string &doc = std::str this->template add_arg (m_s13); \ this->template add_arg (m_s14); #define _GETARGVARS tl::Heap heap;\ - A1 a1 = args ? args.template read (heap) : m_s1.init (); \ - A2 a2 = args ? args.template read (heap) : m_s2.init (); \ - A3 a3 = args ? args.template read (heap) : m_s3.init (); \ - A4 a4 = args ? args.template read (heap) : m_s4.init (); \ - A5 a5 = args ? args.template read (heap) : m_s5.init (); \ - A6 a6 = args ? args.template read (heap) : m_s6.init (); \ - A7 a7 = args ? args.template read (heap) : m_s7.init (); \ - A8 a8 = args ? args.template read (heap) : m_s8.init (); \ - A9 a9 = args ? args.template read (heap) : m_s9.init (); \ - A10 a10 = args ? args.template read (heap) : m_s10.init (); \ - A11 a11 = args ? args.template read (heap) : m_s11.init (); \ - A12 a12 = args ? args.template read (heap) : m_s12.init (); \ - A13 a13 = args ? args.template read (heap) : m_s13.init (); \ - A14 a14 = args ? args.template read (heap) : m_s14.init (); + A1 a1 = args ? args.template read (heap, &m_s1) : m_s1.init (); \ + A2 a2 = args ? args.template read (heap, &m_s2) : m_s2.init (); \ + A3 a3 = args ? args.template read (heap, &m_s3) : m_s3.init (); \ + A4 a4 = args ? args.template read (heap, &m_s4) : m_s4.init (); \ + A5 a5 = args ? args.template read (heap, &m_s5) : m_s5.init (); \ + A6 a6 = args ? args.template read (heap, &m_s6) : m_s6.init (); \ + A7 a7 = args ? args.template read (heap, &m_s7) : m_s7.init (); \ + A8 a8 = args ? args.template read (heap, &m_s8) : m_s8.init (); \ + A9 a9 = args ? args.template read (heap, &m_s9) : m_s9.init (); \ + A10 a10 = args ? args.template read (heap, &m_s10) : m_s10.init (); \ + A11 a11 = args ? args.template read (heap, &m_s11) : m_s11.init (); \ + A12 a12 = args ? args.template read (heap, &m_s12) : m_s12.init (); \ + A13 a13 = args ? args.template read (heap, &m_s13) : m_s13.init (); \ + A14 a14 = args ? args.template read (heap, &m_s14) : m_s14.init (); #define _ARGVARLIST a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14 #define _ARGSPECARGS s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14 #define _ARGSPEC const ArgSpec &s1, const ArgSpec &s2, const ArgSpec &s3, const ArgSpec &s4, const ArgSpec &s5, const ArgSpec &s6, const ArgSpec &s7, const ArgSpec &s8, const ArgSpec &s9, const ArgSpec &s10, const ArgSpec &s11, const ArgSpec &s12, const ArgSpec &s13, const ArgSpec &s14 @@ -1688,21 +1688,21 @@ constant (const std::string &name, const R &v, const std::string &doc = std::str this->template add_arg (m_s14); \ this->template add_arg (m_s15); #define _GETARGVARS tl::Heap heap;\ - A1 a1 = args ? args.template read (heap) : m_s1.init (); \ - A2 a2 = args ? args.template read (heap) : m_s2.init (); \ - A3 a3 = args ? args.template read (heap) : m_s3.init (); \ - A4 a4 = args ? args.template read (heap) : m_s4.init (); \ - A5 a5 = args ? args.template read (heap) : m_s5.init (); \ - A6 a6 = args ? args.template read (heap) : m_s6.init (); \ - A7 a7 = args ? args.template read (heap) : m_s7.init (); \ - A8 a8 = args ? args.template read (heap) : m_s8.init (); \ - A9 a9 = args ? args.template read (heap) : m_s9.init (); \ - A10 a10 = args ? args.template read (heap) : m_s10.init (); \ - A11 a11 = args ? args.template read (heap) : m_s11.init (); \ - A12 a12 = args ? args.template read (heap) : m_s12.init (); \ - A13 a13 = args ? args.template read (heap) : m_s13.init (); \ - A14 a14 = args ? args.template read (heap) : m_s14.init (); \ - A15 a15 = args ? args.template read (heap) : m_s15.init (); + A1 a1 = args ? args.template read (heap, &m_s1) : m_s1.init (); \ + A2 a2 = args ? args.template read (heap, &m_s2) : m_s2.init (); \ + A3 a3 = args ? args.template read (heap, &m_s3) : m_s3.init (); \ + A4 a4 = args ? args.template read (heap, &m_s4) : m_s4.init (); \ + A5 a5 = args ? args.template read (heap, &m_s5) : m_s5.init (); \ + A6 a6 = args ? args.template read (heap, &m_s6) : m_s6.init (); \ + A7 a7 = args ? args.template read (heap, &m_s7) : m_s7.init (); \ + A8 a8 = args ? args.template read (heap, &m_s8) : m_s8.init (); \ + A9 a9 = args ? args.template read (heap, &m_s9) : m_s9.init (); \ + A10 a10 = args ? args.template read (heap, &m_s10) : m_s10.init (); \ + A11 a11 = args ? args.template read (heap, &m_s11) : m_s11.init (); \ + A12 a12 = args ? args.template read (heap, &m_s12) : m_s12.init (); \ + A13 a13 = args ? args.template read (heap, &m_s13) : m_s13.init (); \ + A14 a14 = args ? args.template read (heap, &m_s14) : m_s14.init (); \ + A15 a15 = args ? args.template read (heap, &m_s15) : m_s15.init (); #define _ARGVARLIST a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 #define _ARGSPECARGS s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15 #define _ARGSPEC const ArgSpec &s1, const ArgSpec &s2, const ArgSpec &s3, const ArgSpec &s4, const ArgSpec &s5, const ArgSpec &s6, const ArgSpec &s7, const ArgSpec &s8, const ArgSpec &s9, const ArgSpec &s10, const ArgSpec &s11, const ArgSpec &s12, const ArgSpec &s13, const ArgSpec &s14, const ArgSpec &s15 @@ -1764,22 +1764,22 @@ constant (const std::string &name, const R &v, const std::string &doc = std::str this->template add_arg (m_s15); \ this->template add_arg (m_s16); #define _GETARGVARS tl::Heap heap;\ - A1 a1 = args ? args.template read (heap) : m_s1.init (); \ - A2 a2 = args ? args.template read (heap) : m_s2.init (); \ - A3 a3 = args ? args.template read (heap) : m_s3.init (); \ - A4 a4 = args ? args.template read (heap) : m_s4.init (); \ - A5 a5 = args ? args.template read (heap) : m_s5.init (); \ - A6 a6 = args ? args.template read (heap) : m_s6.init (); \ - A7 a7 = args ? args.template read (heap) : m_s7.init (); \ - A8 a8 = args ? args.template read (heap) : m_s8.init (); \ - A9 a9 = args ? args.template read (heap) : m_s9.init (); \ - A10 a10 = args ? args.template read (heap) : m_s10.init (); \ - A11 a11 = args ? args.template read (heap) : m_s11.init (); \ - A12 a12 = args ? args.template read (heap) : m_s12.init (); \ - A13 a13 = args ? args.template read (heap) : m_s13.init (); \ - A14 a14 = args ? args.template read (heap) : m_s14.init (); \ - A15 a15 = args ? args.template read (heap) : m_s15.init (); \ - A16 a16 = args ? args.template read (heap) : m_s16.init (); + A1 a1 = args ? args.template read (heap, &m_s1) : m_s1.init (); \ + A2 a2 = args ? args.template read (heap, &m_s2) : m_s2.init (); \ + A3 a3 = args ? args.template read (heap, &m_s3) : m_s3.init (); \ + A4 a4 = args ? args.template read (heap, &m_s4) : m_s4.init (); \ + A5 a5 = args ? args.template read (heap, &m_s5) : m_s5.init (); \ + A6 a6 = args ? args.template read (heap, &m_s6) : m_s6.init (); \ + A7 a7 = args ? args.template read (heap, &m_s7) : m_s7.init (); \ + A8 a8 = args ? args.template read (heap, &m_s8) : m_s8.init (); \ + A9 a9 = args ? args.template read (heap, &m_s9) : m_s9.init (); \ + A10 a10 = args ? args.template read (heap, &m_s10) : m_s10.init (); \ + A11 a11 = args ? args.template read (heap, &m_s11) : m_s11.init (); \ + A12 a12 = args ? args.template read (heap, &m_s12) : m_s12.init (); \ + A13 a13 = args ? args.template read (heap, &m_s13) : m_s13.init (); \ + A14 a14 = args ? args.template read (heap, &m_s14) : m_s14.init (); \ + A15 a15 = args ? args.template read (heap, &m_s15) : m_s15.init (); \ + A16 a16 = args ? args.template read (heap, &m_s16) : m_s16.init (); #define _ARGVARLIST a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16 #define _ARGSPECARGS s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16 #define _ARGSPEC const ArgSpec &s1, const ArgSpec &s2, const ArgSpec &s3, const ArgSpec &s4, const ArgSpec &s5, const ArgSpec &s6, const ArgSpec &s7, const ArgSpec &s8, const ArgSpec &s9, const ArgSpec &s10, const ArgSpec &s11, const ArgSpec &s12, const ArgSpec &s13, const ArgSpec &s14, const ArgSpec &s15, const ArgSpec &s16 diff --git a/src/gsi/gsi/gsiSerialisation.h b/src/gsi/gsi/gsiSerialisation.h index 3801d1553..ef4a9f8a3 100644 --- a/src/gsi/gsi/gsiSerialisation.h +++ b/src/gsi/gsi/gsiSerialisation.h @@ -83,6 +83,17 @@ struct GSI_PUBLIC ArglistUnderflowException { } }; +/** + * @brief An exception thrown if there are not enough arguments on the serialization buffer + */ +struct GSI_PUBLIC ArglistUnderflowExceptionWithType + : public tl::Exception +{ + ArglistUnderflowExceptionWithType (const ArgSpecBase &as) + : tl::Exception (tl::to_string (tr ("Too few arguments - missing '%s'")), as.name ()) + { } +}; + /** * @brief An exception thrown if a reference is null (nil) */ @@ -94,6 +105,17 @@ struct GSI_PUBLIC NilPointerToReference { } }; +/** + * @brief An exception thrown if a reference is null (nil) + */ +struct GSI_PUBLIC NilPointerToReferenceWithType + : public tl::Exception +{ + NilPointerToReferenceWithType (const ArgSpecBase &as) + : tl::Exception (tl::to_string (tr ("nil object passed to a reference for '%s'")), as.name ()) + { } +}; + /** * @brief This class provides the basic argument serialization mechanism for the C++/scripting interface */ @@ -208,7 +230,16 @@ public: template inline X read (tl::Heap &heap) { - return this->read_impl (typename type_traits::tag (), heap); + return this->read_impl (typename type_traits::tag (), heap, 0); + } + + /** + * @brief Reads a value from the buffer + */ + template + inline X read (tl::Heap &heap, const ArgSpecBase *as) + { + return this->read_impl (typename type_traits::tag (), heap, as); } /** @@ -231,6 +262,26 @@ private: } } + inline void check_data (const ArgSpecBase *as) const + { + if (! *this) { + if (as) { + throw ArglistUnderflowExceptionWithType (*as); + } else { + throw ArglistUnderflowException (); + } + } + } + + inline void throw_nil_for_reference (const ArgSpecBase *as) const + { + if (as) { + throw NilPointerToReferenceWithType (*as); + } else { + throw NilPointerToReference (); + } + } + // ----------------------------------------------------------- // reader implementations @@ -369,18 +420,18 @@ private: // reader implementations template - X read_impl (const pod_direct_tag &, tl::Heap &) + X read_impl (const pod_direct_tag &, tl::Heap &, const ArgSpecBase *as) { - check_data (); + check_data (as); X r = *((X *)mp_read); mp_read += item_size (); return r; } template - X read_impl (const x_tag &, tl::Heap &) + X read_impl (const x_tag &, tl::Heap &, const ArgSpecBase *as) { - check_data (); + check_data (as); X *xp = *(X **)mp_read; X x = *xp; delete xp; @@ -389,7 +440,7 @@ private: } template - X read_impl (const vptr_tag &, tl::Heap &) + X read_impl (const vptr_tag &, tl::Heap &, const ArgSpecBase *) { void *r = *((void **)mp_read); mp_read += item_size (); @@ -398,73 +449,73 @@ private: } template - X read_impl (const ref_tag &, tl::Heap &) + X read_impl (const ref_tag &, tl::Heap &, const ArgSpecBase *as) { typedef typename type_traits::value_type value_type; - check_data (); + check_data (as); value_type *r = *((value_type **)mp_read); mp_read += item_size (); if (! r) { - throw NilPointerToReference (); + throw_nil_for_reference (as); } return *r; } template - X read_impl (const pod_cref_tag &, tl::Heap &) + X read_impl (const pod_cref_tag &, tl::Heap &, const ArgSpecBase *as) { // X is actually an (const X &) typedef typename type_traits::value_type value_type; - check_data (); + check_data (as); const value_type *r = ((const value_type *)mp_read); mp_read += item_size (); return *r; } template - X read_impl (const npod_cref_tag &, tl::Heap &) + X read_impl (const npod_cref_tag &, tl::Heap &, const ArgSpecBase *as) { // X is actually an (const X &) typedef typename type_traits::value_type value_type; - check_data (); + check_data (as); const value_type *r = *((const value_type **)mp_read); mp_read += item_size (); if (! r) { - throw NilPointerToReference (); + throw_nil_for_reference (as); } return *r; } template - X read_impl (const x_cref_tag &, tl::Heap &) + X read_impl (const x_cref_tag &, tl::Heap &, const ArgSpecBase *as) { // X is actually an (const X &) typedef typename type_traits::value_type value_type; - check_data (); + check_data (as); const value_type *r = *((const value_type **)mp_read); mp_read += item_size (); if (! r) { - throw NilPointerToReference (); + throw_nil_for_reference (as); } return *r; } template - X read_impl (const ptr_tag &, tl::Heap &) + X read_impl (const ptr_tag &, tl::Heap &, const ArgSpecBase *as) { // X is actually an (X *) typedef typename type_traits::value_type value_type; - check_data (); + check_data (as); value_type * const &r = *((value_type **)mp_read); mp_read += item_size (); return r; } template - X read_impl (const pod_cptr_tag &, tl::Heap &) + X read_impl (const pod_cptr_tag &, tl::Heap &, const ArgSpecBase *as) { // X is actually an (const X *) - check_data (); + check_data (as); bool h = *(bool *)mp_read; mp_read += item_size (); X r = h ? (X)mp_read : (X)0; @@ -474,29 +525,29 @@ private: // see notes on the serialization for this type: template - X read_impl (const npod_cptr_tag &, tl::Heap &) + X read_impl (const npod_cptr_tag &, tl::Heap &, const ArgSpecBase *as) { // X is actually an (const X *) - check_data (); + check_data (as); X r = *((X *)mp_read); mp_read += item_size (); return r; } template - X read_impl (const x_cptr_tag &, tl::Heap &) + X read_impl (const x_cptr_tag &, tl::Heap &, const ArgSpecBase *as) { // X is actually an (const X *) - check_data (); + check_data (as); X r = *((X *)mp_read); mp_read += item_size (); return r; } template - X read_impl (const adaptor_direct_tag &, tl::Heap &heap) + X read_impl (const adaptor_direct_tag &, tl::Heap &heap, const ArgSpecBase *as) { - check_data (); + check_data (as); std::unique_ptr p (*(AdaptorBase **)mp_read); mp_read += item_size (); @@ -508,11 +559,11 @@ private: } template - X read_impl (const adaptor_cref_tag &, tl::Heap &heap) + X read_impl (const adaptor_cref_tag &, tl::Heap &heap, const ArgSpecBase *as) { typedef typename tl::get_inner_type::result x_type; - check_data (); + check_data (as); std::unique_ptr p (*(AdaptorBase **)mp_read); mp_read += item_size (); @@ -526,11 +577,11 @@ private: } template - X read_impl (const adaptor_ref_tag &, tl::Heap &heap) + X read_impl (const adaptor_ref_tag &, tl::Heap &heap, const ArgSpecBase *as) { typedef typename tl::get_inner_type::result x_type; - check_data (); + check_data (as); AdaptorBase *p = *(AdaptorBase **)mp_read; mp_read += item_size (); @@ -544,11 +595,11 @@ private: } template - X read_impl (const adaptor_cptr_tag &, tl::Heap &heap) + X read_impl (const adaptor_cptr_tag &, tl::Heap &heap, const ArgSpecBase *as) { typedef typename tl::get_inner_type::result x_type; - check_data (); + check_data (as); std::unique_ptr p (*(AdaptorBase **)mp_read); mp_read += item_size (); @@ -564,11 +615,11 @@ private: } template - X read_impl (const adaptor_ptr_tag &, tl::Heap &heap) + X read_impl (const adaptor_ptr_tag &, tl::Heap &heap, const ArgSpecBase *as) { typedef typename tl::get_inner_type::result x_type; - check_data (); + check_data (as); AdaptorBase *p = *(AdaptorBase **)mp_read; mp_read += item_size ();