CTRL + C break display or 'pause' execution 67/17267/3
Antoine ELIAS [Tue, 29 Sep 2015 10:17:25 +0000 (12:17 +0200)]
Change-Id: Ib4296d931c04ff1455810c519001a098dfa47c65

12 files changed:
scilab/modules/action_binding/src/c/InterpreterManagement.c
scilab/modules/action_binding/src/c/action_binding.vcxproj
scilab/modules/ast/core_Import.def
scilab/modules/ast/includes/system_env/configvariable.hxx
scilab/modules/ast/includes/system_env/configvariable_interface.h
scilab/modules/ast/src/cpp/ast/runvisitor.cpp
scilab/modules/ast/src/cpp/system_env/configvariable.cpp
scilab/modules/ast/src/cpp/system_env/configvariable_interface.cpp
scilab/modules/ast/src/cpp/types/types_tools.cpp
scilab/modules/console/src/c/windows/TermCommand.c
scilab/modules/core/src/c/csignal.c
scilab/modules/core/src/cpp/runner.cpp

index 90c5347..756dd19 100644 (file)
  *
  */
 
-#include <signal.h> /* for SIGINT */
 #include "InterpreterManagement.h"
 #include "storeCommand.h"
-#include "sigbas.h"
-#include "sci_malloc.h"
-#include "charEncoding.h"
+#include "configvariable_interface.h"
 /*--------------------------------------------------------------------------*/
 int putCommandInScilabQueue(char *command)
 {
@@ -35,8 +32,7 @@ int requestScilabExec(char *command)
 /*--------------------------------------------------------------------------*/
 int interruptScilab(void)
 {
-    int scilabSignal = SIGINT;
-    //C2F(sigbas)(&scilabSignal);
+    setExecutionBreak();
     return 0;
 }
 /*--------------------------------------------------------------------------*/
index fe9976c..8599bd4 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="ProjectConfigurations">
     <ProjectConfiguration Include="Debug|Win32">
@@ -85,7 +85,7 @@
     <ClCompile>
       <AdditionalOptions>%(AdditionalOptions)</AdditionalOptions>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>.;../../includes;../jni;$(SCILAB_JDK32)/include/win32;$(SCILAB_JDK32)/include;../../../../libs/intl;../../../output_stream/includes;../../../core/includes;../../../jvm/includes;../../../api_scilab/includes;../../../localization/includes;../../../commons/src/jni;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../jni;$(SCILAB_JDK32)/include/win32;$(SCILAB_JDK32)/include;../../../../libs/intl;../../../output_stream/includes;../../../core/includes;../../../jvm/includes;../../../api_scilab/includes;../../../localization/includes;../../../commons/src/jni;../../../ast/includes/system_env;../../../ast/includes/ast;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;ACTION_BINDING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>Default</BasicRuntimeChecks>
     </Midl>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>.;../../includes;../jni;$(SCILAB_JDK64)/include/win32;$(SCILAB_JDK64)/include;../../../../libs/intl;../../../output_stream/includes;../../../core/includes;../../../jvm/includes;../../../api_scilab/includes;../../../localization/includes;../../../commons/src/jni;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../jni;$(SCILAB_JDK64)/include/win32;$(SCILAB_JDK64)/include;../../../../libs/intl;../../../output_stream/includes;../../../core/includes;../../../jvm/includes;../../../api_scilab/includes;../../../localization/includes;../../../commons/src/jni;../../../ast/includes/system_env;../../../ast/includes/ast;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;ACTION_BINDING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>Default</BasicRuntimeChecks>
       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>.;../../includes;../jni;$(SCILAB_JDK32)/include/win32;$(SCILAB_JDK32)/include;../../../../libs/intl;../../../output_stream/includes;../../../core/includes;../../../jvm/includes;../../../api_scilab/includes;../../../localization/includes;../../../commons/src/jni;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../jni;$(SCILAB_JDK32)/include/win32;$(SCILAB_JDK32)/include;../../../../libs/intl;../../../output_stream/includes;../../../core/includes;../../../jvm/includes;../../../api_scilab/includes;../../../localization/includes;../../../commons/src/jni;../../../ast/includes/system_env;../../../ast/includes/ast;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;ACTION_BINDING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <WholeProgramOptimization>false</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>.;../../includes;../jni;$(SCILAB_JDK64)/include/win32;$(SCILAB_JDK64)/include;../../../../libs/intl;../../../output_stream/includes;../../../core/includes;../../../jvm/includes;../../../api_scilab/includes;../../../localization/includes;../../../commons/src/jni;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>.;../../includes;../jni;$(SCILAB_JDK64)/include/win32;$(SCILAB_JDK64)/include;../../../../libs/intl;../../../output_stream/includes;../../../core/includes;../../../jvm/includes;../../../api_scilab/includes;../../../localization/includes;../../../commons/src/jni;../../../ast/includes/system_env;../../../ast/includes/ast;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;ACTION_BINDING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <Project>{43c5bab1-1dca-4743-a183-77e0d42fe7d0}</Project>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
     </ProjectReference>
+    <ProjectReference Include="..\..\..\ast\ast.vcxproj">
+      <Project>{0d3fa25b-8116-44ec-a45e-260789daa3d9}</Project>
+    </ProjectReference>
     <ProjectReference Include="..\..\..\commons\src\c\commons.vcxproj">
       <Project>{eca09a1e-6d12-4a47-92e1-a671c181df77}</Project>
     </ProjectReference>
index b5b284b..0501c00 100644 (file)
@@ -9,4 +9,5 @@ StaticRunner_isRunnerAvailable
 StaticRunner_isInterruptibleCommand
 StaticRunner_setInterruptibleCommand
 StoreConsoleCommand
+StorePrioritaryCommand
 parseCommand
\ No newline at end of file
index 8205985..1279fd1 100644 (file)
@@ -396,7 +396,7 @@ public :
             m_line(line), m_absolute_line(absolute_line), m_name(name), m_macro_first_line(first_line), m_file_name(file_name) {}
     };
     typedef std::vector<WhereEntry> WhereVector;
-        
+
     static void where_begin(int _iLineNum, int _iLineLocation, types::Callable* _pCall);
     static void where_end();
     static const WhereVector& getWhere();
@@ -474,6 +474,14 @@ public:
 
     static void setDefaultVisitor(ast::ConstVisitor* _default);
     static ast::ConstVisitor* getDefaultVisitor();
+
+    //manage CTRL C in console
+private :
+    static bool executionbreak;
+public :
+    static bool isExecutionBreak();
+    static void setExecutionBreak();
+    static void resetExecutionBreak();
 };
 
 #endif /* !__CONFIGVARIABLE_HXX__ */
index d7e659d..33dbb27 100644 (file)
@@ -78,4 +78,9 @@ EXTERN_AST dynlib_ptr getEntryPointFromPosition(int position);
 
 EXTERN_AST int isEnableDebug();
 EXTERN_AST int isDebugInterrupted();
+
+EXTERN_AST int isExecutionBreak();
+EXTERN_AST void setExecutionBreak();
+EXTERN_AST void resetExecutionBreak();
+
 #endif /* !__CONFIGVARIABLE_INTERFACE_H__ */
index 51d46af..9705c62 100644 (file)
@@ -48,6 +48,7 @@ extern "C"
 #include "sciprint.h"
 #include "os_string.h"
 #include "elem_common.h"
+#include "storeCommand.h"
 }
 
 namespace ast
@@ -920,6 +921,12 @@ void RunVisitorT<T>::visitprivate(const SeqExp  &e)
             continue;
         }
 
+        if (ConfigVariable::isExecutionBreak())
+        {
+            ConfigVariable::resetExecutionBreak();
+            StorePrioritaryCommand("pause");
+        }
+
         // interrupt me to execute a prioritary command
         while (StaticRunner_isInterruptibleCommand() == 1 && StaticRunner_isRunnerAvailable() == 1)
         {
@@ -927,6 +934,8 @@ void RunVisitorT<T>::visitprivate(const SeqExp  &e)
             StaticRunner_setInterruptibleCommand(1);
         }
 
+
+
         try
         {
             //reset default values
index 6891e8b..201464e 100644 (file)
@@ -1480,3 +1480,22 @@ ast::ConstVisitor* ConfigVariable::getDefaultVisitor()
     }
     return m_defaultvisitor->clone();
 }
+
+bool ConfigVariable::executionbreak = false;
+
+bool ConfigVariable::isExecutionBreak()
+{
+    return executionbreak;
+}
+
+void ConfigVariable::setExecutionBreak()
+{
+    executionbreak = true;
+}
+
+void ConfigVariable::resetExecutionBreak()
+{
+    executionbreak = false;
+}
+
+
index dd99fb0..f1afadb 100644 (file)
@@ -196,3 +196,19 @@ int isDebugInterrupted()
 {
     return debugger::DebuggerMagager::getInstance()->isInterrupted() ? 1 : 0;
 }
+
+int isExecutionBreak()
+{
+    return ConfigVariable::isExecutionBreak() ? 1 : 0;
+}
+
+void setExecutionBreak()
+{
+    ConfigVariable::setExecutionBreak();
+}
+
+void resetExecutionBreak()
+{
+    ConfigVariable::resetExecutionBreak();
+}
+
index fd81226..23a9469 100644 (file)
@@ -831,6 +831,7 @@ types::Function::ReturnValue VariableToString(types::InternalType* pIT, const wc
             {
                 ConfigVariable::resetError();
                 ostr.str(L"");
+                ConfigVariable::resetExecutionBreak();
                 return types::Function::Error;
             }
 
@@ -843,8 +844,12 @@ types::Function::ReturnValue VariableToString(types::InternalType* pIT, const wc
             scilabForcedWriteW(ostr.str().c_str());
             ostr.str(L"");
         }
-        while (bFinish == false);
+        while (bFinish == false && ConfigVariable::isExecutionBreak() == false);
 
+        if (bFinish == false)
+        {
+            ConfigVariable::resetExecutionBreak();
+        }
         pIT->clearPrintState();
         return types::Function::OK;
     }
index df6064f..abeb05b 100644 (file)
 /*--------------------------------------------------------------------------*/
 #include "TermCommand.h"
 #include "machine.h" /* C2F */
-#include "sigbas.h" /* C2F (sigbas) */
 #include "storeCommand.h" /* StoreCommand */
 #include "clrscr_nw.h"
 #include "TermLine.h"
-#include "sci_malloc.h"
+#include "configvariable_interface.h"
 /*--------------------------------------------------------------------------*/
 void ControlC_Command(void)
 {
-    int j = 2;
-    //C2F (sigbas) (&j);
+    setExecutionBreak();
 }
 /*--------------------------------------------------------------------------*/
 void ControlX_Command(void)
index 0ef6c11..98ae401 100644 (file)
 #include <string.h>
 #include <wchar.h>
 #include "csignal.h"
-#include "sigbas.h"
+#include "configvariable_interface.h"
 
 /* If CTRL-C was pressed. */
 void controlC_handler(int sig)
 {
-    int j = SIGINT;
-    //C2F(sigbas)(&j);
+    setExecutionBreak();
 }
 
 int csignal(void)
@@ -43,6 +42,5 @@ int csignal(void)
         return -1;
     }
 #endif
-
     return 0;
 }
index 6e0552a..8e5b89f 100644 (file)
@@ -34,6 +34,7 @@ void StaticRunner::launch()
     setInterruptibleCommand(runMe->isInterruptible());
     debugger::DebuggerMagager* manager = debugger::DebuggerMagager::getInstance();
 
+    ConfigVariable::resetExecutionBreak();
     try
     {
         runMe->getProgram()->accept(*(runMe->getVisitor()));