1515#include  " xeus-cpp/xinterpreter.hpp" 
1616#include  " xeus-cpp/xmagics.hpp" 
1717
18- #include  < cstring>    //  for std::strlen
19- #include  < sstream>    //  for std::istringstream
20- #include  < string>    //  for std::getline
18+ #include  < cstring> //  for std::strlen
19+ #include  < sstream> //  for std::istringstream
20+ #include  < string> //  for std::getline
2121
2222#include  " xinput.hpp" 
2323#include  " xinspect.hpp" 
3030
3131using  Args = std::vector<const  char *>;
3232
33- void * createInterpreter (const  Args &ExtraArgs = {}) {
34-   Args ClangArgs = {/* "-xc++"*/ " -v" //  ? {"-Xclang", "-emit-llvm-only", "-Xclang", "-diagnostic-log-file", "-Xclang", "-", "-xc++"};
35-   if  (std::find_if (ExtraArgs.begin (), ExtraArgs.end (), [](const  std::string& s) {
36-     return  s == " -resource-dir" end ()) {
37-     std::string resource_dir = Cpp::DetectResourceDir ();
38-     if  (resource_dir.empty ())
39-       std::cerr << " Failed to detect the resource-dir\n " 
40-     ClangArgs.push_back (" -resource-dir" 
41-     ClangArgs.push_back (resource_dir.c_str ());
42-   }
43-   std::vector<std::string> CxxSystemIncludes;
44-   Cpp::DetectSystemCompilerIncludePaths (CxxSystemIncludes);
45-   for  (const  std::string& CxxInclude : CxxSystemIncludes) {
46-     ClangArgs.push_back (" -isystem" 
47-     ClangArgs.push_back (CxxInclude.c_str ());
48-   }
49-   ClangArgs.insert (ClangArgs.end (), ExtraArgs.begin (), ExtraArgs.end ());
50-   //  FIXME: We should process the kernel input options and conditionally pass
51-   //  the gpu args here.
52-   return  Cpp::CreateInterpreter (ClangArgs/* , {"-cuda"}*/ 
33+ void * createInterpreter (const  Args& ExtraArgs = {})
34+ {
35+     Args ClangArgs = {/* "-xc++"*/ " -v" //  ? {"-Xclang", "-emit-llvm-only", "-Xclang",
36+                                           //  "-diagnostic-log-file", "-Xclang", "-", "-xc++"};
37+     if  (std::find_if (
38+             ExtraArgs.begin (),
39+             ExtraArgs.end (),
40+             [](const  std::string& s)
41+             {
42+                 return  s == " -resource-dir" 
43+             }
44+         )
45+         == ExtraArgs.end ())
46+     {
47+         std::string resource_dir = Cpp::DetectResourceDir ();
48+         if  (resource_dir.empty ())
49+         {
50+             std::cerr << " Failed to detect the resource-dir\n " 
51+         }
52+         ClangArgs.push_back (" -resource-dir" 
53+         ClangArgs.push_back (resource_dir.c_str ());
54+     }
55+     std::vector<std::string> CxxSystemIncludes;
56+     Cpp::DetectSystemCompilerIncludePaths (CxxSystemIncludes);
57+     for  (const  std::string& CxxInclude : CxxSystemIncludes)
58+     {
59+         ClangArgs.push_back (" -isystem" 
60+         ClangArgs.push_back (CxxInclude.c_str ());
61+     }
62+     ClangArgs.insert (ClangArgs.end (), ExtraArgs.begin (), ExtraArgs.end ());
63+     //  FIXME: We should process the kernel input options and conditionally pass
64+     //  the gpu args here.
65+     return  Cpp::CreateInterpreter (ClangArgs /* , {"-cuda"}*/ 
5366}
5467
5568using  namespace  std ::placeholders; 
5669
5770namespace  xcpp 
5871{
59-     struct  StreamRedirectRAII  {
60-       std::string &err;
61-       StreamRedirectRAII (std::string &e) : err(e) {
62-         Cpp::BeginStdStreamCapture (Cpp::kStdErr );
63-         Cpp::BeginStdStreamCapture (Cpp::kStdOut );
64-       }
65-       ~StreamRedirectRAII () {
66-         std::string out = Cpp::EndStdStreamCapture ();
67-         err = Cpp::EndStdStreamCapture ();
68-         std::cout << out;
69-       }
72+     struct  StreamRedirectRAII 
73+     {
74+         std::string& err;
75+ 
76+         StreamRedirectRAII (std::string& e)
77+             : err(e)
78+         {
79+             Cpp::BeginStdStreamCapture (Cpp::kStdErr );
80+             Cpp::BeginStdStreamCapture (Cpp::kStdOut );
81+         }
82+ 
83+         ~StreamRedirectRAII ()
84+         {
85+             std::string out = Cpp::EndStdStreamCapture ();
86+             err = Cpp::EndStdStreamCapture ();
87+             std::cout << out;
88+         }
7089    };
7190
7291    void  interpreter::configure_impl ()
@@ -102,15 +121,14 @@ __get_cxx_version ()
102121        return  std::to_string (cxx_version);
103122    }
104123
105- 
106-     interpreter::interpreter (int  argc, const  char * const * argv) :
107-         xmagics ()
124+     interpreter::interpreter (int  argc, const  char * const * argv)
125+         : xmagics()
108126        , p_cout_strbuf(nullptr )
109127        , p_cerr_strbuf(nullptr )
110128        , m_cout_buffer(std::bind(&interpreter::publish_stdout, this , _1))
111129        , m_cerr_buffer(std::bind(&interpreter::publish_stderr, this , _1))
112130    {
113-         // NOLINTNEXTLINE (cppcoreguidelines-pro-bounds-pointer-arithmetic)
131+         //   NOLINTNEXTLINE (cppcoreguidelines-pro-bounds-pointer-arithmetic)
114132        createInterpreter (Args (argv ? argv + 1  : argv, argv + argc));
115133        m_version = get_stdopt ();
116134        redirect_output ();
@@ -214,10 +232,11 @@ __get_cxx_version ()
214232            // 
215233            //  JupyterLab displays the "{ename}: {evalue}" if the traceback is
216234            //  empty.
217-             if  (evalue.size () < 4 ) {
235+             if  (evalue.size () < 4 )
236+             {
218237                ename = "  " 
219238            }
220-             std::vector<std::string> traceback ({ename   + evalue});
239+             std::vector<std::string> traceback ({ename + evalue});
221240            if  (!config.silent )
222241            {
223242                publish_execution_error (ename, evalue, traceback);
@@ -260,7 +279,8 @@ __get_cxx_version ()
260279
261280        Cpp::CodeComplete (results, code.c_str (), 1 , _cursor_pos + 1 );
262281
263-         return  xeus::create_complete_reply (results /* matches*/ 
282+         return  xeus::create_complete_reply (
283+             results /* matches*/ 
264284            cursor_pos - to_complete.length () /* cursor_start*/ 
265285            cursor_pos /* cursor_end*/ 
266286        );
@@ -281,13 +301,17 @@ __get_cxx_version ()
281301
282302    nl::json interpreter::is_complete_request_impl (const  std::string& code)
283303    {
284-         if  (!code.empty () && code[code.size () - 1 ] == ' \\ ' 
304+         if  (!code.empty () && code[code.size () - 1 ] == ' \\ ' 
305+         {
285306            auto  found = code.rfind (' \n ' 
286307            if  (found == std::string::npos)
308+             {
287309                found = -1 ;
310+             }
288311            auto  found1 = found++;
289-             while  (isspace (code[++found1])) ;
290-             return  xeus::create_is_complete_reply (" incomplete" substr (found, found1-found));
312+             while  (isspace (code[++found1]))
313+                 ;
314+             return  xeus::create_is_complete_reply (" incomplete" substr (found, found1 - found));
291315        }
292316
293317        return  xeus::create_is_complete_reply (" complete" 
@@ -366,7 +390,8 @@ __get_cxx_version ()
366390
367391        //  Get include paths from environment variable
368392        const  char * non_standard_paths = std::getenv (" XEUS_SEARCH_PATH" 
369-         if  (!non_standard_paths) {
393+         if  (!non_standard_paths)
394+         {
370395            non_standard_paths = " " 
371396        }
372397
@@ -387,11 +412,11 @@ __get_cxx_version ()
387412
388413    void  interpreter::init_preamble ()
389414    {
390-         // NOLINTBEGIN(cppcoreguidelines-owning-memory)
415+         //   NOLINTBEGIN(cppcoreguidelines-owning-memory)
391416        preamble_manager.register_preamble (" introspection" 
392417        preamble_manager.register_preamble (" magics" 
393418        preamble_manager.register_preamble (" shell" 
394-         // NOLINTEND(cppcoreguidelines-owning-memory)
419+         //   NOLINTEND(cppcoreguidelines-owning-memory)
395420    }
396421
397422    void  interpreter::init_magic ()
0 commit comments