pause / resume / abort Implementation. 79/3479/7
Bruno JOFRET [Wed, 9 Mar 2011 10:47:12 +0000 (11:47 +0100)]
Change-Id: I9e35ccc63686fed6c2000c6ae372ffc60f16c20b

30 files changed:
scilab/Scilab.sln
scilab/modules/abstractSyntaxTree/includes/runvisitor.hxx
scilab/modules/core/Makefile.am
scilab/modules/core/Makefile.in
scilab/modules/core/core_yasp.vcproj
scilab/modules/core/includes/core_gw.hxx
scilab/modules/core/includes/runner.hxx
scilab/modules/core/sci_gateway/c/gw_core.c
scilab/modules/core/sci_gateway/cpp/sci_abort.cpp [new file with mode: 0644]
scilab/modules/core/sci_gateway/cpp/sci_pause.cpp [new file with mode: 0644]
scilab/modules/core/sci_gateway/cpp/sci_resume.cpp [new file with mode: 0644]
scilab/modules/core/src/cpp/core_gw.cpp
scilab/modules/core/src/cpp/core_gw.vcproj
scilab/modules/core/src/cpp/runner.cpp [new file with mode: 0644]
scilab/modules/core/src/cpp/scilab.cpp
scilab/modules/core/src/cpp/storeCommand.cpp
scilab/modules/core/src/cpp/tasks.cpp
scilab/modules/functions/sci_gateway/cpp/sci_exec.cpp
scilab/modules/functions/sci_gateway/cpp/sci_execstr.cpp
scilab/modules/functions/sci_gateway/cpp/sci_getCurrentThreadId.cpp
scilab/modules/functions_manager/src/cpp/funcmanager.cpp
scilab/modules/io/sci_gateway/cpp/sci_genlib.cpp
scilab/modules/parse/includes/parser.hxx
scilab/modules/parse/src/cpp/parser.cpp
scilab/modules/shell/src/c/prompt.c
scilab/modules/system_env/includes/configvariable.hxx
scilab/modules/system_env/src/cpp/configvariable.cpp
scilab/modules/types/includes/threadId.hxx
scilab/modules/types/src/cpp/macro.cpp
scilab/modules/types/src/cpp/threadId.cpp

index acfa85a..9252e49 100644 (file)
@@ -1340,9 +1340,9 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core_gw", "modules\core\src\cpp\core_gw.vcproj", "{3E933EB6-D427-4828-9B30-B6B9987491F6}"
        ProjectSection(ProjectDependencies) = postProject
                {ECFFEB0C-1EDA-45EE-9A10-B18143852E17} = {ECFFEB0C-1EDA-45EE-9A10-B18143852E17}
-               {C6E2BC17-34D8-46E4-85F3-6293CB21ADCD} = {C6E2BC17-34D8-46E4-85F3-6293CB21ADCD}
                {2C60033B-0DBD-4CA4-80D3-176C9BE9CE2F} = {2C60033B-0DBD-4CA4-80D3-176C9BE9CE2F}
                {4FC72D4A-80EE-4B1A-8724-0201C1A35621} = {4FC72D4A-80EE-4B1A-8724-0201C1A35621}
+               {0D3FA25B-8116-44EC-A45E-260789DAA3D9} = {0D3FA25B-8116-44EC-A45E-260789DAA3D9}
                {64BC155E-292F-484F-9404-76EE6AE67A43} = {64BC155E-292F-484F-9404-76EE6AE67A43}
                {6A84AD8C-BA18-4A3F-9C72-EC3DF0939E9E} = {6A84AD8C-BA18-4A3F-9C72-EC3DF0939E9E}
                {43C5BAB1-1DCA-4743-A183-77E0D42FE7D0} = {43C5BAB1-1DCA-4743-A183-77E0D42FE7D0}
index e30b160..b11bafd 100644 (file)
@@ -519,7 +519,14 @@ namespace ast
                         throw ScilabError(os.str(), 999, (*e.args_get().begin())->location_get());
                     }
 
-                    result_set(pList);
+                    if (pList->getSize() == 1)
+                    {
+                        result_set(pList->get(0));
+                    }
+                    else
+                    {
+                        result_set(pList);
+                    }
                 }
             }
             else
index df43875..c37500e 100644 (file)
@@ -189,14 +189,14 @@ CORE_CPP_SOURCES = \
     src/cpp/storeCommand.cpp \
     src/cpp/banner.cpp \
     src/cpp/overload.cpp \
-       src/cpp/with_module.cpp
+       src/cpp/with_module.cpp \
+       src/cpp/runner.cpp
 
 if USE_DYNAMIC_STACK
 CORE_FORTRAN_SOURCES += src/fortran/relocstack.f
 endif
 
 GATEWAY_C_SOURCES = sci_gateway/c/sci_stacksize.c \
-sci_gateway/c/sci_resume.c \
 sci_gateway/c/sci_mtlb_mode.c \
 sci_gateway/c/sci_where.c \
 sci_gateway/c/sci_errcatch.c \
@@ -268,7 +268,10 @@ GATEWAY_CPP_SOURCES =      \
        sci_gateway/cpp/sci_getversion.cpp \
        sci_gateway/cpp/sci_warning.cpp \
        sci_gateway/cpp/sci_getmd5.cpp \
-       sci_gateway/cpp/sci_error.cpp
+       sci_gateway/cpp/sci_error.cpp \
+       sci_gateway/cpp/sci_pause.cpp \
+       sci_gateway/cpp/sci_resume.cpp \
+       sci_gateway/cpp/sci_abort.cpp
 
 
 libscicore_la_CFLAGS = -I$(srcdir)/includes/ \
index b7074eb..6d1ff09 100644 (file)
@@ -194,8 +194,8 @@ am__libscicore_la_SOURCES_DIST = src/c/inffic.c src/c/cs2st.c \
        src/cpp/hashtable_core.cpp src/cpp/namstr.cpp \
        src/cpp/search_functions.cpp src/cpp/storeCommand.cpp \
        src/cpp/banner.cpp src/cpp/overload.cpp \
-       src/cpp/with_module.cpp sci_gateway/c/sci_stacksize.c \
-       sci_gateway/c/sci_resume.c sci_gateway/c/sci_mtlb_mode.c \
+       src/cpp/with_module.cpp src/cpp/runner.cpp \
+       sci_gateway/c/sci_stacksize.c sci_gateway/c/sci_mtlb_mode.c \
        sci_gateway/c/sci_where.c sci_gateway/c/sci_errcatch.c \
        sci_gateway/c/sci_format.c sci_gateway/c/sci_getmemory.c \
        sci_gateway/c/sci_havewindow.c sci_gateway/c/sci_delbpt.c \
@@ -240,7 +240,8 @@ am__libscicore_la_SOURCES_DIST = src/c/inffic.c src/c/cs2st.c \
        sci_gateway/cpp/sci_lasterror.cpp \
        sci_gateway/cpp/sci_getversion.cpp \
        sci_gateway/cpp/sci_warning.cpp sci_gateway/cpp/sci_getmd5.cpp \
-       sci_gateway/cpp/sci_error.cpp
+       sci_gateway/cpp/sci_error.cpp sci_gateway/cpp/sci_pause.cpp \
+       sci_gateway/cpp/sci_resume.cpp sci_gateway/cpp/sci_abort.cpp
 @USE_DYNAMIC_STACK_TRUE@am__objects_1 = libscicore_la-scimem64.lo
 am__objects_2 = libscicore_la-inffic.lo libscicore_la-cs2st.lo \
        libscicore_la-intmacr2tree.lo libscicore_la-run.lo \
@@ -307,25 +308,26 @@ am__objects_5 = libscicore_la-core_gw.lo \
        libscicore_la-hashtable_core.lo libscicore_la-namstr.lo \
        libscicore_la-search_functions.lo \
        libscicore_la-storeCommand.lo libscicore_la-banner.lo \
-       libscicore_la-overload.lo libscicore_la-with_module.lo
+       libscicore_la-overload.lo libscicore_la-with_module.lo \
+       libscicore_la-runner.lo
 am__objects_6 = libscicore_la-sci_stacksize.lo \
-       libscicore_la-sci_resume.lo libscicore_la-sci_mtlb_mode.lo \
-       libscicore_la-sci_where.lo libscicore_la-sci_errcatch.lo \
-       libscicore_la-sci_format.lo libscicore_la-sci_getmemory.lo \
-       libscicore_la-sci_havewindow.lo libscicore_la-sci_delbpt.lo \
-       libscicore_la-sci_macr2lst.lo libscicore_la-sci_who.lo \
-       libscicore_la-sci_errclear.lo libscicore_la-sci_funcprot.lo \
-       libscicore_la-sci_newfun.lo libscicore_la-sci_dispbpt.lo \
-       libscicore_la-sci_intppty.lo libscicore_la-sci_ieee.lo \
-       libscicore_la-sci_gstacksize.lo libscicore_la-sci_funptr.lo \
-       libscicore_la-sci_return.lo libscicore_la-sci_clearfun.lo \
-       libscicore_la-sci_setbpt.lo libscicore_la-sci_what.lo \
-       libscicore_la-sci_predef.lo libscicore_la-sci_type.lo \
-       libscicore_la-sci_typename.lo libscicore_la-sci_mode.lo \
-       libscicore_la-sci_macr2tree.lo libscicore_la-sci_iserror.lo \
-       libscicore_la-sci_getdebuginfo.lo libscicore_la-sci_debug.lo \
-       libscicore_la-gw_core.lo libscicore_la-gw_user.lo \
-       libscicore_la-gw_user2.lo libscicore_la-sci_islittleendian.lo \
+       libscicore_la-sci_mtlb_mode.lo libscicore_la-sci_where.lo \
+       libscicore_la-sci_errcatch.lo libscicore_la-sci_format.lo \
+       libscicore_la-sci_getmemory.lo libscicore_la-sci_havewindow.lo \
+       libscicore_la-sci_delbpt.lo libscicore_la-sci_macr2lst.lo \
+       libscicore_la-sci_who.lo libscicore_la-sci_errclear.lo \
+       libscicore_la-sci_funcprot.lo libscicore_la-sci_newfun.lo \
+       libscicore_la-sci_dispbpt.lo libscicore_la-sci_intppty.lo \
+       libscicore_la-sci_ieee.lo libscicore_la-sci_gstacksize.lo \
+       libscicore_la-sci_funptr.lo libscicore_la-sci_return.lo \
+       libscicore_la-sci_clearfun.lo libscicore_la-sci_setbpt.lo \
+       libscicore_la-sci_what.lo libscicore_la-sci_predef.lo \
+       libscicore_la-sci_type.lo libscicore_la-sci_typename.lo \
+       libscicore_la-sci_mode.lo libscicore_la-sci_macr2tree.lo \
+       libscicore_la-sci_iserror.lo libscicore_la-sci_getdebuginfo.lo \
+       libscicore_la-sci_debug.lo libscicore_la-gw_core.lo \
+       libscicore_la-gw_user.lo libscicore_la-gw_user2.lo \
+       libscicore_la-sci_islittleendian.lo \
        libscicore_la-sci_getvariablesonstack.lo \
        libscicore_la-sci_readgateway.lo libscicore_la-sci_comp.lo
 am__objects_7 = sci_global.lo sci_mtlb_mode.lo sci_resume.lo \
@@ -341,7 +343,8 @@ am__objects_8 = libscicore_la-sci_getmodules.lo \
        libscicore_la-sci_exists.lo libscicore_la-sci_with_module.lo \
        libscicore_la-sci_lasterror.lo libscicore_la-sci_getversion.lo \
        libscicore_la-sci_warning.lo libscicore_la-sci_getmd5.lo \
-       libscicore_la-sci_error.lo
+       libscicore_la-sci_error.lo libscicore_la-sci_pause.lo \
+       libscicore_la-sci_resume.lo libscicore_la-sci_abort.lo
 am_libscicore_la_OBJECTS = $(am__objects_2) $(am__objects_4) \
        $(am__objects_5) $(am__objects_6) $(am__objects_7) \
        $(am__objects_8)
@@ -711,10 +714,10 @@ CORE_CPP_SOURCES = \
     src/cpp/storeCommand.cpp \
     src/cpp/banner.cpp \
     src/cpp/overload.cpp \
-       src/cpp/with_module.cpp
+       src/cpp/with_module.cpp \
+       src/cpp/runner.cpp
 
 GATEWAY_C_SOURCES = sci_gateway/c/sci_stacksize.c \
-sci_gateway/c/sci_resume.c \
 sci_gateway/c/sci_mtlb_mode.c \
 sci_gateway/c/sci_where.c \
 sci_gateway/c/sci_errcatch.c \
@@ -786,7 +789,10 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_getversion.cpp \
        sci_gateway/cpp/sci_warning.cpp \
        sci_gateway/cpp/sci_getmd5.cpp \
-       sci_gateway/cpp/sci_error.cpp
+       sci_gateway/cpp/sci_error.cpp \
+       sci_gateway/cpp/sci_pause.cpp \
+       sci_gateway/cpp/sci_resume.cpp \
+       sci_gateway/cpp/sci_abort.cpp
 
 libscicore_la_CFLAGS = -I$(srcdir)/includes/ -I$(srcdir)/src/c/ \
        -I$(top_srcdir)/libs/MALLOC/includes/ \
@@ -1087,6 +1093,8 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-returnPropertyList.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-returnanan.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-run.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-runner.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_abort.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_argn.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_banner.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_clear.Plo@am__quote@
@@ -1126,6 +1134,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_mode.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_mtlb_mode.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_newfun.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_pause.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_predef.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_quit.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_readgateway.Plo@am__quote@
@@ -1694,13 +1703,6 @@ libscicore_la-sci_stacksize.lo: sci_gateway/c/sci_stacksize.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(libscicore_la_CFLAGS) $(CFLAGS) -c -o libscicore_la-sci_stacksize.lo `test -f 'sci_gateway/c/sci_stacksize.c' || echo '$(srcdir)/'`sci_gateway/c/sci_stacksize.c
 
-libscicore_la-sci_resume.lo: sci_gateway/c/sci_resume.c
-@am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(libscicore_la_CFLAGS) $(CFLAGS) -MT libscicore_la-sci_resume.lo -MD -MP -MF $(DEPDIR)/libscicore_la-sci_resume.Tpo -c -o libscicore_la-sci_resume.lo `test -f 'sci_gateway/c/sci_resume.c' || echo '$(srcdir)/'`sci_gateway/c/sci_resume.c
-@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscicore_la-sci_resume.Tpo $(DEPDIR)/libscicore_la-sci_resume.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='sci_gateway/c/sci_resume.c' object='libscicore_la-sci_resume.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(libscicore_la_CFLAGS) $(CFLAGS) -c -o libscicore_la-sci_resume.lo `test -f 'sci_gateway/c/sci_resume.c' || echo '$(srcdir)/'`sci_gateway/c/sci_resume.c
-
 libscicore_la-sci_mtlb_mode.lo: sci_gateway/c/sci_mtlb_mode.c
 @am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(libscicore_la_CFLAGS) $(CFLAGS) -MT libscicore_la-sci_mtlb_mode.lo -MD -MP -MF $(DEPDIR)/libscicore_la-sci_mtlb_mode.Tpo -c -o libscicore_la-sci_mtlb_mode.lo `test -f 'sci_gateway/c/sci_mtlb_mode.c' || echo '$(srcdir)/'`sci_gateway/c/sci_mtlb_mode.c
 @am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscicore_la-sci_mtlb_mode.Tpo $(DEPDIR)/libscicore_la-sci_mtlb_mode.Plo
@@ -2030,6 +2032,13 @@ libscicore_la-with_module.lo: src/cpp/with_module.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscicore_la-with_module.lo `test -f 'src/cpp/with_module.cpp' || echo '$(srcdir)/'`src/cpp/with_module.cpp
 
+libscicore_la-runner.lo: src/cpp/runner.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscicore_la-runner.lo -MD -MP -MF $(DEPDIR)/libscicore_la-runner.Tpo -c -o libscicore_la-runner.lo `test -f 'src/cpp/runner.cpp' || echo '$(srcdir)/'`src/cpp/runner.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscicore_la-runner.Tpo $(DEPDIR)/libscicore_la-runner.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/runner.cpp' object='libscicore_la-runner.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscicore_la-runner.lo `test -f 'src/cpp/runner.cpp' || echo '$(srcdir)/'`src/cpp/runner.cpp
+
 libscicore_la-sci_getmodules.lo: sci_gateway/cpp/sci_getmodules.cpp
 @am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscicore_la-sci_getmodules.lo -MD -MP -MF $(DEPDIR)/libscicore_la-sci_getmodules.Tpo -c -o libscicore_la-sci_getmodules.lo `test -f 'sci_gateway/cpp/sci_getmodules.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_getmodules.cpp
 @am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscicore_la-sci_getmodules.Tpo $(DEPDIR)/libscicore_la-sci_getmodules.Plo
@@ -2156,6 +2165,27 @@ libscicore_la-sci_error.lo: sci_gateway/cpp/sci_error.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscicore_la-sci_error.lo `test -f 'sci_gateway/cpp/sci_error.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_error.cpp
 
+libscicore_la-sci_pause.lo: sci_gateway/cpp/sci_pause.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscicore_la-sci_pause.lo -MD -MP -MF $(DEPDIR)/libscicore_la-sci_pause.Tpo -c -o libscicore_la-sci_pause.lo `test -f 'sci_gateway/cpp/sci_pause.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_pause.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscicore_la-sci_pause.Tpo $(DEPDIR)/libscicore_la-sci_pause.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_pause.cpp' object='libscicore_la-sci_pause.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscicore_la-sci_pause.lo `test -f 'sci_gateway/cpp/sci_pause.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_pause.cpp
+
+libscicore_la-sci_resume.lo: sci_gateway/cpp/sci_resume.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscicore_la-sci_resume.lo -MD -MP -MF $(DEPDIR)/libscicore_la-sci_resume.Tpo -c -o libscicore_la-sci_resume.lo `test -f 'sci_gateway/cpp/sci_resume.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_resume.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscicore_la-sci_resume.Tpo $(DEPDIR)/libscicore_la-sci_resume.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_resume.cpp' object='libscicore_la-sci_resume.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscicore_la-sci_resume.lo `test -f 'sci_gateway/cpp/sci_resume.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_resume.cpp
+
+libscicore_la-sci_abort.lo: sci_gateway/cpp/sci_abort.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscicore_la-sci_abort.lo -MD -MP -MF $(DEPDIR)/libscicore_la-sci_abort.Tpo -c -o libscicore_la-sci_abort.lo `test -f 'sci_gateway/cpp/sci_abort.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_abort.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscicore_la-sci_abort.Tpo $(DEPDIR)/libscicore_la-sci_abort.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_abort.cpp' object='libscicore_la-sci_abort.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscicore_la-sci_abort.lo `test -f 'sci_gateway/cpp/sci_abort.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_abort.cpp
+
 .f.o:
        $(F77COMPILE) -c -o $@ $<
 
index 462ec03..c028b9f 100644 (file)
                        Filter="h;hpp;hxx;hm;inl;inc;xsd"
                        UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
                        >
-                       <File
-                               RelativePath=".\includes\runner.hxx"
-                               >
-                       </File>
                </Filter>
                <Filter
                        Name="Resource Files"
index bd8765e..94c85cc 100644 (file)
@@ -47,5 +47,8 @@ CPP_GATEWAY_PROTOTYPE(sci_getversion);
 CPP_GATEWAY_PROTOTYPE(sci_warning);
 CPP_GATEWAY_PROTOTYPE(sci_getmd5);
 CPP_GATEWAY_PROTOTYPE(sci_error);
+CPP_GATEWAY_PROTOTYPE(sci_pause);
+CPP_GATEWAY_PROTOTYPE(sci_resume);
+CPP_GATEWAY_PROTOTYPE(sci_abort);
 
 #endif /* __CORE_GW_HXX__ */
index c2c6f85..3622616 100644 (file)
 extern "C"
 {
 #include "Thread_Wrapper.h"
+#include "dynlib_core_gw.h"
 }
 
 #include "exp.hxx"
 #include "execvisitor.hxx"
 #include "threadId.hxx"
 
-class Runner
+class CORE_GW_IMPEXP Runner
 {
-public :
-    Runner() { }
-    ~Runner() { }
-
-public :
-    void execAndWait(ast::Exp* _theProgram, ast::ExecVisitor *_visitor)
-    {
-        try
-        {
-            m_theProgram = _theProgram;
-            m_visitor = _visitor;
-            __threadKey key;
-
-            //init locker
-            __InitLock(&m_lock);
-            //lock locker
-            __Lock(&m_lock);
-            //launch thread but is can't really start since locker is locked
-            __CreateThreadWithParams(&m_threadId, &key, &Runner::launch, this);
-            //register thread
-            ConfigVariable::setThread(key, new ThreadId(m_threadId));
-            //free locker to release thread
-            __UnLock(&m_lock);
-            //wait and of thread execution
-            __WaitThreadDie(m_threadId);
-            //change thread status
-            ConfigVariable::getThread(key)->setStatus(ThreadId::Done);
-            //unregister thread
-            ConfigVariable::deleteThread(key);
-        }
-        catch(ScilabException se)
-        {
-            throw se;
-        }
-    }
-
-    void exec(ast::Exp* _theProgram, ast::ExecVisitor *_visitor)
+private :
+    Runner(ast::Exp* _theProgram, ast::ExecVisitor *_visitor)
     {
         m_theProgram = _theProgram;
         m_visitor = _visitor;
-        __threadKey key;
-        __CreateThreadWithParams(&m_threadId, &key, &Runner::launch, this);
     }
+    ~Runner()
+    {
+        delete m_theProgram;
+        delete m_visitor;
+    }
+
+public :
+
+    static void init();
+
+    static void execAndWait(ast::Exp* _theProgram, ast::ExecVisitor *_visitor);
+
+    void exec(ast::Exp* _theProgram, ast::ExecVisitor *_visitor);
 
     ast::ExecVisitor *getVisitor()
     {
@@ -85,35 +62,37 @@ public :
         return m_threadId;
     }
 
-private :
-    static void *launch(void *args)
+    void setThreadId(__threadId _threadId)
     {
-        //try to lock locker ( waiting parent thread register me )
-        __Lock(&m_lock);
-        //just release locker
-        __UnLock(&m_lock);
-
-        //exec !
-        Runner *me = (Runner *)args;
-        try
-        {
-            me->getProgram()->accept(*(me->getVisitor()));
-            ConfigVariable::clearLastError();
-        }
-        catch(ScilabException se)
-        {
-            YaspWriteW(se.GetErrorMessage().c_str());
-        }
-        return NULL;
+        m_threadId = _threadId;
     }
 
+    __threadKey getThreadKey(void)
+    {
+        return m_threadKey;
+    }
+
+    void setThreadKey(__threadKey _threadId)
+    {
+        m_threadKey = _threadId;
+    }
+
+    static void UnlockPrompt();
+
+    static void LockPrompt();
+
 private :
-    __threadId m_threadId;
+    static void *launch(void *args);
 
-public :
+private :
+    __threadKey m_threadKey;
+    __threadId m_threadId;
     ast::Exp*           m_theProgram;
     ast::ExecVisitor*   m_visitor;
-    static __threadLock m_lock;
 
+private :
+    static __threadSignal m_awakeScilab;
+    static __threadSignalLock m_awakeScilabLock;
+    static __threadLock m_lock;
 };
 #endif /* !__RUNNER_HXX__ */
index 39650ea..cca06f3 100644 (file)
@@ -28,7 +28,7 @@ static gw_generic_table Tab[]=
 {C2F(sci_mode),"mode"},
 {NULL ,""}, //type
 {NULL, ""}, //error
-{C2F(sci_resume),"resume"},
+{NULL, ""}, //resune
 {C2F(sci_return),"return"},
 {C2F(sci_format),"format"},
 {NULL, ""}, // isdef
diff --git a/scilab/modules/core/sci_gateway/cpp/sci_abort.cpp b/scilab/modules/core/sci_gateway/cpp/sci_abort.cpp
new file mode 100644 (file)
index 0000000..fd3967b
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2011-2011 - DIGITEO - Bruno JOFRET
+ *
+ *  This file must be used under the terms of the CeCILL.
+ *  This source file is licensed as described in the file COPYING, which
+ *  you should have received as part of this distribution.  The terms
+ *  are also available at
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+
+#include "function.hxx"
+#include "runner.hxx"
+#include "threadId.hxx"
+#include "double.hxx"
+
+extern "C"
+{
+#include "charEncoding.h"
+#include "localization.h"
+#include "Scierror.h"
+
+#include "Thread_Wrapper.h"
+}
+
+types::Function::ReturnValue sci_abort(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    if(in.size() != 0)
+    {
+        ScierrorW(77,_W("%ls: Wrong number of input argument(s): %d expected.\n"), L"abort", 0);
+        return types::Function::Error;
+    }
+
+    if(_iRetCount > 1)
+    {
+        ScierrorW(78,_W("%ls: Wrong number of output argument(s): %d to %d expected.\n"), L"abort", 0, 1);
+        return types::Function::Error;
+    }
+
+    ThreadId* pThreadId = NULL;
+    while((pThreadId = ConfigVariable::getLastPausedThread()) != NULL)
+    {
+        __threadId id = pThreadId->getId();
+        pThreadId->abort();
+        __WaitThreadDie(id);
+    }
+   
+    return types::Function::OK;
+}
diff --git a/scilab/modules/core/sci_gateway/cpp/sci_pause.cpp b/scilab/modules/core/sci_gateway/cpp/sci_pause.cpp
new file mode 100644 (file)
index 0000000..3fd0012
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2011-2011 - DIGITEO - Bruno JOFRET
+ *
+ *  This file must be used under the terms of the CeCILL.
+ *  This source file is licensed as described in the file COPYING, which
+ *  you should have received as part of this distribution.  The terms
+ *  are also available at
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "function.hxx"
+#include "runner.hxx"
+#include "threadId.hxx"
+#include "scilabexception.hxx"
+
+extern "C"
+{
+#include "charEncoding.h"
+#include "localization.h"
+#include "Scierror.h"
+
+#include "Thread_Wrapper.h"
+}
+
+types::Function::ReturnValue sci_pause(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    if(in.size() != 0)
+    {
+        ScierrorW(77,_W("%ls: Wrong number of input argument(s): %d expected.\n"), L"pause", 0);
+        return types::Function::Error;
+    }
+
+    if(_iRetCount != -1)
+    {
+        ScierrorW(78,_W("%ls: Wrong number of output argument(s): %d expected.\n"), L"pause", 0);
+        return types::Function::Error;
+    }
+
+    ConfigVariable::IncreasePauseLevel();
+    Runner::UnlockPrompt();
+    ThreadId* pThread = ConfigVariable::getLastRunningThread();
+    pThread->suspend();
+
+    // Running from here means we have been awaken by some resume / abort
+    ConfigVariable::DecreasePauseLevel();
+    if (pThread->getStatus() == types::ThreadId::Aborted)
+    {
+        throw ScilabMessage(L"");
+    }
+
+    return types::Function::OK;
+
+}
diff --git a/scilab/modules/core/sci_gateway/cpp/sci_resume.cpp b/scilab/modules/core/sci_gateway/cpp/sci_resume.cpp
new file mode 100644 (file)
index 0000000..a79146d
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2011-2011 - DIGITEO - Bruno JOFRET
+ *
+ *  This file must be used under the terms of the CeCILL.
+ *  This source file is licensed as described in the file COPYING, which
+ *  you should have received as part of this distribution.  The terms
+ *  are also available at
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "function.hxx"
+#include "runner.hxx"
+#include "threadId.hxx"
+#include "configvariable.hxx"
+
+extern "C"
+{
+#include "charEncoding.h"
+#include "localization.h"
+#include "Scierror.h"
+
+#include "Thread_Wrapper.h"
+}
+
+types::Function::ReturnValue sci_resume(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    if(in.size() != 0)
+    {
+        ScierrorW(77,_W("%ls: Wrong number of input argument(s): %d expected.\n"), L"resume", 0);
+        return types::Function::Error;
+    }
+
+    if(_iRetCount > 1)
+    {
+        ScierrorW(78,_W("%ls: Wrong number of output argument(s): %d to %d expected.\n"), L"resume", 0, 1);
+        return types::Function::Error;
+    }
+
+    ThreadId* pThreadId = ConfigVariable::getLastPausedThread();
+    if (pThreadId == NULL)
+    {//no paused thread, so just go leave
+        return types::Function::OK;
+    }
+
+    __threadId id = pThreadId->getId();
+    pThreadId->resume();
+    __WaitThreadDie(id);
+
+    return types::Function::OK;
+}
index 37427c9..0e0576b 100644 (file)
@@ -44,6 +44,9 @@ bool CoreModule::Load()
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"warning", &sci_warning, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"getmd5", &sci_getmd5, MODULE_NAME));
     symbol::Context::getInstance()->AddFunction(Function::createFunction(L"error", &sci_error, MODULE_NAME));
+    symbol::Context::getInstance()->AddFunction(Function::createFunction(L"pause", &sci_pause, MODULE_NAME));
+    symbol::Context::getInstance()->AddFunction(Function::createFunction(L"resume", &sci_resume, MODULE_NAME));
+    symbol::Context::getInstance()->AddFunction(Function::createFunction(L"abort", &sci_abort, MODULE_NAME));
     return true;
 }
 
index e998361..7cab5b5 100644 (file)
                                >
                        </File>
                        <File
+                               RelativePath=".\runner.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\sci_gateway\cpp\sci_abort.cpp"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\sci_gateway\cpp\sci_argn.cpp"
                                >
                        </File>
                                >
                        </File>
                        <File
+                               RelativePath="..\..\sci_gateway\cpp\sci_pause.cpp"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\sci_gateway\cpp\sci_quit.cpp"
                                >
                        </File>
                        <File
+                               RelativePath="..\..\sci_gateway\cpp\sci_resume.cpp"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\sci_gateway\cpp\sci_warning.cpp"
                                >
                        </File>
                                RelativePath="..\..\includes\dynlib_core_gw.h"
                                >
                        </File>
+                       <File
+                               RelativePath="..\..\includes\runner.hxx"
+                               >
+                       </File>
                </Filter>
                <Filter
                        Name="Resource Files"
diff --git a/scilab/modules/core/src/cpp/runner.cpp b/scilab/modules/core/src/cpp/runner.cpp
new file mode 100644 (file)
index 0000000..f38a0dc
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2011-2011 - DIGITEO - Bruno JOFRET
+ *
+ *  This file must be used under the terms of the CeCILL.
+ *  This source file is licensed as described in the file COPYING, which
+ *  you should have received as part of this distribution.  The terms
+ *  are also available at
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "runner.hxx"
+
+__threadLock Runner::m_lock;
+__threadSignal Runner::m_awakeScilab;
+__threadSignalLock Runner::m_awakeScilabLock;
+
+void Runner::init()
+{
+    __InitSignal(&m_awakeScilab);
+    __InitSignalLock(&m_awakeScilabLock); 
+}
+
+void *Runner::launch(void *args)
+{
+    //try to lock locker ( waiting parent thread register me )
+    __Lock(&m_lock);
+    //just release locker
+    __UnLock(&m_lock);
+
+    //exec !
+    Runner *me = (Runner *)args;
+    try
+    {
+        me->getProgram()->accept(*(me->getVisitor()));
+        ConfigVariable::clearLastError();
+    }
+    catch(ScilabException se)
+    {
+        YaspWriteW(se.GetErrorMessage().c_str());
+    }
+
+
+
+    //change thread status
+    ThreadId* pThread = ConfigVariable::getThread(__GetCurrentThreadKey());
+    if(pThread->getStatus() != ThreadId::Aborted)
+    {
+        pThread->setStatus(ThreadId::Done);
+        UnlockPrompt();
+    }
+
+    //unregister thread
+    ConfigVariable::deleteThread(__GetCurrentThreadKey());
+
+
+    delete me;
+    return NULL;
+}
+
+void Runner::LockPrompt()
+{
+    __LockSignal(&m_awakeScilabLock);
+    __Wait(&m_awakeScilab, &m_awakeScilabLock);
+    __UnLockSignal(&m_awakeScilabLock);
+}
+
+void Runner::UnlockPrompt()
+{
+    __LockSignal(&m_awakeScilabLock);
+    __Signal(&m_awakeScilab);
+    __UnLockSignal(&m_awakeScilabLock);
+}
+
+
+void Runner::execAndWait(ast::Exp* _theProgram, ast::ExecVisitor *_visitor)
+{
+    try
+    {
+        Runner *runMe = new Runner(_theProgram, _visitor);
+        __threadKey threadKey;
+        __threadId threadId;
+
+        //init locker
+        __InitLock(&m_lock);
+        //lock locker
+        __Lock(&m_lock);
+        //launch thread but is can't really start since locker is locked
+        __CreateThreadWithParams(&threadId, &threadKey, &Runner::launch, runMe);
+        runMe->setThreadId(threadId);
+        runMe->setThreadKey(threadKey);
+
+        //register thread
+        ConfigVariable::addThread(new ThreadId(threadId, threadKey));
+        //free locker to release thread
+        __UnLock(&m_lock);
+        //wait and of thread execution
+        LockPrompt();
+    }
+    catch(ScilabException se)
+    {
+        throw se;
+    }
+}
+
+void Runner::exec(ast::Exp* _theProgram, ast::ExecVisitor *_visitor)
+{
+    m_theProgram = _theProgram;
+    m_visitor = _visitor;
+    __CreateThreadWithParams(&m_threadId, &m_threadKey, &Runner::launch, this);
+}
index 2765cae..e3d65a6 100644 (file)
@@ -83,6 +83,8 @@ extern "C"
 #include "filemanager.hxx"
 #include "scilabexception.hxx"
 
+#include "runner.hxx"
+
 #include "banner.hxx"
 
 #include "string.hxx"
@@ -313,6 +315,8 @@ static int interactiveMain (void)
         // Show Parser Sate before prompt
         stateShow(controlStatus);
 
+        pause = ConfigVariable::getPauseLevel();
+
         //set prompt value
         C2F(setprlev)(&pause);
 
@@ -400,7 +404,6 @@ static Parser::ControlStatus processCommand(char* _pstCommand)
             YaspWriteW(parser->getErrorMessage());
         }
 
-        parser->freeTree();
         FREE(pwstCommand);
     }
     return parser->getControlStatus();
@@ -465,6 +468,8 @@ int main(int argc, char *argv[])
 int StartScilabEngine(int argc, char*argv[], int iFileIndex)
 {
     int iMainRet = 0;
+    Runner::init();
+    
     /* Scilab Startup */
     InitializeEnvironnement();
 
index 6752dda..19b7200 100644 (file)
@@ -76,7 +76,7 @@ int StoreCommandWithFlag (wchar_t *command,int flag)
         YaspWriteW(_W("while executing a callback"));
     }
 
-    parser.freeTree();
+    delete parser.getTree();
        return 0;
 }
 /*--------------------------------------------------------------------------*/
@@ -106,7 +106,7 @@ int StorePrioritaryCommandWithFlag (wchar_t *command,int flag)
         YaspWriteW(_W("while executing a callback"));
     }
 
-    parser.freeTree();
+    delete parser.getTree();
        return (0);
 }
 /*--------------------------------------------------------------------------*/
index 9118843..3efb29e 100644 (file)
@@ -29,8 +29,6 @@ Timer _timer;
 
 //#define DEBUG
 
-__threadLock Runner::m_lock;
-
 /*
 ** Parse
 **
@@ -155,9 +153,8 @@ void execAstTask(ast::Exp* tree, bool timed, bool ASTtimed)
         exec = new ast::ExecVisitor();
     }
 
-    Runner engine;
-    engine.execAndWait(tree, exec);
-    delete exec;
+    Runner::execAndWait(tree, exec);
+    //delete exec;
 
     if(timed)
     {
index 7c5e44f..512c780 100644 (file)
@@ -120,7 +120,7 @@ Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, types::typ
                if(parser.getExitStatus() !=  Parser::Succeded)
                {
                        YaspWriteW(parser.getErrorMessage());
-                       parser.freeTree();
+                       delete parser.getTree();
             mclose(iID);
                        return Function::Error;
                }
@@ -191,7 +191,7 @@ Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, types::typ
             (*j)->accept(execMe);
 
             bool bImplicitCall = false;
-            
+
             //to manage call without ()
             if(execMe.result_get() != NULL && execMe.result_get()->getAsCallable())
             {
@@ -259,7 +259,7 @@ Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, types::typ
                                }
                        }
 
-                       //if( !checkPrompt(iMode, EXEC_MODE_MUTE) && 
+                       //if( !checkPrompt(iMode, EXEC_MODE_MUTE) &&
    //             bErrCatch == false)
                        //{
                        //      YaspWriteW(L"\n");
@@ -348,7 +348,7 @@ Function::ReturnValue sci_exec(types::typed_list &in, int _iRetCount, types::typ
         ConfigVariable::setLastErrorCall();
     }
 
-       parser.freeTree();
+       delete parser.getTree();
     mclose(iID);
        file.close();
        return Function::OK;
index 9ef9f6f..9baabcf 100644 (file)
@@ -175,7 +175,7 @@ Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, types::
             iErr = ConfigVariable::getLastErrorNumber();
             if(bErrCatch == false)
             {
-               parser.freeTree();
+               delete parser.getTree();
                            return Function::Error;
             }
             break;
@@ -191,8 +191,8 @@ Function::ReturnValue sci_execstr(types::typed_list &in, int _iRetCount, types::
         //to lock last error information
         ConfigVariable::setLastErrorCall();
     }
-    
-    parser.freeTree();
+
+    delete parser.getTree();
        return Function::OK;
 }
 /*--------------------------------------------------------------------------*/
index a9a6e5d..6eddcd9 100644 (file)
@@ -37,7 +37,7 @@ Function::ReturnValue sci_getCurrentThreadId(types::typed_list &in, int _iRetCou
         return Function::Error;
     }
 
-    out.push_back(ConfigVariable::getThread(__GetCurrentThreadKey()));
+    out.push_back(ConfigVariable::getLastRunningThread());
 
     return Function::OK;
 }
index f2f0bde..3907e08 100644 (file)
@@ -359,7 +359,7 @@ bool FuncManager::ExecuteStartFile(wstring _stModule)
         std::wostringstream ostr;
         ostr << _W("Unable to execute : ") << stPath << endl;
         YaspWriteW(ostr.str().c_str());
-        parser.freeTree();
+        delete parser.getTree();
         return false;
     }
 
@@ -385,6 +385,6 @@ bool FuncManager::ExecuteStartFile(wstring _stModule)
 
     //restore previous prompt mode
     ConfigVariable::setPromptMode(oldVal);
-    parser.freeTree();
+    delete parser.getTree();
     return true;
 }
index 94c518a..87f4a7c 100644 (file)
@@ -162,7 +162,7 @@ Function::ReturnValue sci_genlib(types::typed_list &in, int _iRetCount, types::t
             {
                 os_swprintf(pstVerbose, 65535, _W("%ls: Warning: Error in file %ls : %ls. File ignored\n"), L"genlib", pstPath[k], parser.getErrorMessage());
                 YaspWriteW(pstVerbose);
-                parser.freeTree();
+                delete parser.getTree();
                 continue;
             }
 
@@ -182,7 +182,7 @@ Function::ReturnValue sci_genlib(types::typed_list &in, int _iRetCount, types::t
                                }
                        }
 
-                       parser.freeTree();
+                       delete parser.getTree();
                }
        }
 
index 5883742..3052397 100644 (file)
@@ -91,9 +91,6 @@ public:
     void setParseTrace(bool parseTrace) { _parse_trace = parseTrace; }
     bool getParseTrace(void) { return _parse_trace; }
 
-    /** \brief free current tree */
-    void freeTree();
-
     /** Setters / Getters
         \{ */
 
index 8d84944..a5bbe43 100644 (file)
@@ -218,15 +218,6 @@ void ParserSingleInstance::disableParseTrace(void)
     yydebug = 0;
 }
 
-void Parser::freeTree()
-{
-       if(_the_program != NULL)
-       {
-               delete _the_program;
-               _the_program = NULL;
-       }
-}
-
 const wstring* ParserSingleInstance::_file_name = NULL;
 const wstring* ParserSingleInstance::_prog_name = NULL;
 wstring* ParserSingleInstance::_error_message = new wstring();
index fa047f0..b88ec7b 100644 (file)
@@ -53,7 +53,7 @@ void C2F(setprlev)( int *pause)
                sprintf(Sci_Prompt,SCIPROMPT_INTERRUPT,*pause);
                // bug 5513
                // when we change prompt to a pause level, we change also temp. prompt
-               SetTemporaryPrompt(Sci_Prompt);
+               //SetTemporaryPrompt(Sci_Prompt);
        }
        else 
        {
index ae49455..e29b0c7 100644 (file)
@@ -181,14 +181,27 @@ public :
     //Thread List
 
 private :
-    static std::map<__threadKey, types::ThreadId*>    m_threadList;
+    static std::list<types::ThreadId*> m_threadList;
 public :
 
     static types::ThreadId* getThread(__threadKey _key);
+    static types::ThreadId* getLastRunningThread();
+    static types::ThreadId* getLastPausedThread();
+    static types::ThreadId* getLastThread();
+
     static types::Cell* getAllThreads(void);
-    static void setThread(__threadKey _key, types::ThreadId* _thread);
+    static void addThread(types::ThreadId* _thread);
     static void deleteThread(__threadKey _key);
 
+    // Pause level
+private :
+    static int m_iPauseLevel;
+
+public :
+    static void IncreasePauseLevel();
+    static void DecreasePauseLevel();
+    static int getPauseLevel();
+
 
 };
 
index 055a2d0..ecca19e 100644 (file)
@@ -368,17 +368,37 @@ int ConfigVariable::getPromptMode(void)
 ** \{
 */
 
-std::map<__threadKey, types::ThreadId *> ConfigVariable::m_threadList;
+std::list<types::ThreadId *> ConfigVariable::m_threadList;
 
-types::ThreadId* ConfigVariable::getThread(__threadKey _key)
+types::ThreadId* ConfigVariable::getLastPausedThread()
 {
-    std::map<__threadKey, types::ThreadId *>::const_iterator it;
-    it = m_threadList.find(_key);
-    if(it == m_threadList.end())
+    std::list<types::ThreadId *>::reverse_iterator it;
+    for(it = m_threadList.rbegin() ; it != m_threadList.rend() ; it++)
     {
-        return NULL;
+        if((*it)->getStatus() == types::ThreadId::Paused)
+        {
+            return *it;
+        }
     }
-    return it->second;
+    return NULL;
+}
+
+types::ThreadId* ConfigVariable::getLastRunningThread()
+{
+    std::list<types::ThreadId *>::reverse_iterator it;
+    for(it = m_threadList.rbegin() ; it != m_threadList.rend() ; it++)
+    {
+        if((*it)->getStatus() == types::ThreadId::Running)
+        {
+            return *it;
+        }
+    }
+    return NULL;
+}
+
+types::ThreadId* ConfigVariable::getLastThread()
+{
+    return m_threadList.back();
 }
 
 types::Cell* ConfigVariable::getAllThreads(void)
@@ -392,40 +412,96 @@ types::Cell* ConfigVariable::getAllThreads(void)
 
     int i = 0;
     types::Cell *pcResult = new types::Cell(iSize, 1);
-    std::map<__threadKey, types::ThreadId *>::iterator it;
+    std::list<types::ThreadId *>::iterator it;
 
     for (it = ConfigVariable::m_threadList.begin() ; it != ConfigVariable::m_threadList.end() ; ++it, ++i)
     {
-        pcResult->set(i, 0, it->second);
+        pcResult->set(i, *it);
     }
 
     return pcResult;
 }
 
 
-void ConfigVariable::setThread(__threadKey _key, types::ThreadId* _thread)
+void ConfigVariable::addThread(types::ThreadId* _thread)
 {
-    ConfigVariable::deleteThread(_key);
     _thread->IncreaseRef();
-    m_threadList[_key] = _thread;
+    m_threadList.push_back(_thread);
 }
 
+
+types::ThreadId* ConfigVariable::getThread(__threadKey _key)
+{
+    std::list<types::ThreadId *>::iterator it;
+
+    for (it = ConfigVariable::m_threadList.begin() ; it != ConfigVariable::m_threadList.end() ; ++it)
+    {
+        if((*it)->getKey() == _key)
+        {
+            return *it;
+        }
+    }
+    return NULL;
+}
+
+
 void ConfigVariable::deleteThread(__threadKey _key)
 {
-    std::map<__threadKey, types::ThreadId *>::const_iterator it;
-    it = m_threadList.find(_key);
-    if(it != m_threadList.end())
+    //for(int i = 0 ; i < m_threadList.size() ; i++)
+    //{
+    //    types::ThreadId* pThread = m_threadList[i];
+    //    if(pThread->getKey() == _key)
+    //    {
+    //        pThread->DecreaseRef();
+    //        if(pThread->isDeletable())
+    //        {
+    //            delete pThread;
+    //            m_threadList.erase(.begin() + i - 1);
+    //        }
+    //    }
+    //}
+    std::list<types::ThreadId *>::iterator it;
+    for (it = ConfigVariable::m_threadList.begin() ; it != ConfigVariable::m_threadList.end() ; ++it)
     {
-        it->second->DecreaseRef();
-        if(it->second->isDeletable())
+        if((*it)->getKey() == _key)
         {
-            delete it->second;
+            (*it)->DecreaseRef();
+            if((*it)->isDeletable())
+            {
+                delete (*it);
+                m_threadList.erase(it);
+                return;
+            }
         }
-        m_threadList[_key] = NULL;
-        m_threadList.erase(_key);
     }
 }
 
 /*
 ** \}
 */
+
+/*
+** Prompt Mode
+** \{
+*/
+
+int ConfigVariable::m_iPauseLevel = 0;
+
+void ConfigVariable::IncreasePauseLevel()
+{
+    m_iPauseLevel++;
+}
+
+void ConfigVariable::DecreasePauseLevel()
+{
+    m_iPauseLevel--;
+}
+
+int ConfigVariable::getPauseLevel()
+{
+    return m_iPauseLevel;
+}
+
+/*
+** \}
+*/
index e734b1f..7cf0ad3 100644 (file)
@@ -25,7 +25,7 @@ namespace types
     class ThreadId : public InternalType
     {
     public :
-                                ThreadId(__threadId _id);
+                                ThreadId(__threadId _id, __threadKey _key);
         virtual                 ~ThreadId();
 
         ThreadId*               getAsThreadId(void);
@@ -36,10 +36,12 @@ namespace types
         virtual std::wstring    getTypeStr() {return L"ThreadId";}
         /* return type as short string ( s, i, ce, l, ... )*/
         virtual std::wstring    getShortTypeStr() {return L"tid";}
-        InternalType*               clone();
+        InternalType*           clone();
 
         __threadId              getId();
         void                    setId(__threadId _id);
+        __threadKey             getKey();
+        void                    setKey(__threadKey _key);
 
         /*
         ** Status
@@ -53,6 +55,10 @@ namespace types
 
         Status                  getStatus();
         void                    setStatus(Status _status);
+
+        void                    suspend();
+        void                    resume();
+        void                    abort();
     private :
         std::wstring            StatusToString(Status _status);
 
@@ -60,8 +66,10 @@ namespace types
         RealType                getType();
 
     private :
-        __threadId                                 m_threadId;
-        Status                                     m_threadStatus;
+        __threadId              m_threadId;
+        __threadKey             m_threadKey;
+        __threadLock            m_threadLock;
+        Status                  m_threadStatus;
 
     };
 }
index 677f6e8..f051783 100644 (file)
@@ -195,7 +195,7 @@ namespace types
                 }
             }
         }
-        catch(ast::ScilabError se)
+        catch(ast::ScilabException se)
         {
             //close the current scope
             pContext->scope_end();
index 2f1b3cd..1511d1b 100644 (file)
@@ -1,14 +1,14 @@
 /*
- *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- *  Copyright (C) 2010-2010 - DIGITEO - Bruno JOFRET
- *
- *  This file must be used under the terms of the CeCILL.
- *  This source file is licensed as described in the file COPYING, which
- *  you should have received as part of this distribution.  The terms
- *  are also available at
- *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
+*  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+*  Copyright (C) 2010-2010 - DIGITEO - Bruno JOFRET
+*
+*  This file must be used under the terms of the CeCILL.
+*  This source file is licensed as described in the file COPYING, which
+*  you should have received as part of this distribution.  The terms
+*  are also available at
+*  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
 
 #include <map>
 #include <sstream>
@@ -27,13 +27,15 @@ extern "C"
 namespace types
 {
 
-       ThreadId::~ThreadId() { }
+    ThreadId::~ThreadId() { }
 
-       ThreadId::ThreadId(__threadId _id)
-       {
+    ThreadId::ThreadId(__threadId _id, __threadKey _key)
+    {
         m_threadId = _id;
+        m_threadKey = _key;
+        __InitLock(&m_threadLock);
         m_threadStatus = Running;
-       }
+    }
 
     __threadId ThreadId::getId()
     {
@@ -45,20 +47,30 @@ namespace types
         this->m_threadId = _id;
     }
 
-       InternalType* ThreadId::clone()
-       {
+    __threadKey ThreadId::getKey()
+    {
+        return m_threadKey;
+    }
+
+    void ThreadId::setKey(__threadKey _key)
+    {
+        this->m_threadKey = _key;
+    }
+
+    InternalType* ThreadId::clone()
+    {
         return this;
-       }
+    }
 
-       ThreadId* ThreadId::getAsThreadId(void)
-       {
-               return this;
-       }
+    ThreadId* ThreadId::getAsThreadId(void)
+    {
+        return this;
+    }
 
-       GenericType::RealType ThreadId::getType()
-       {
-               return GenericType::RealThreadId;
-       }
+    GenericType::RealType ThreadId::getType()
+    {
+        return GenericType::RealThreadId;
+    }
 
     std::wstring ThreadId::StatusToString(Status _status)
     {
@@ -86,8 +98,56 @@ namespace types
         return m_threadStatus;
     }
 
+    void ThreadId::suspend()
+    {
+        setStatus(Paused);
+        /*
+        ** BJ: Under Linux / Mac having a lock twice will force thread to wait.
+        ** this will not work under windows. So use native Thread suspend and resume functions.
+        */
+
+#ifndef _MSC_VER
+        __Lock(&m_threadLock);
+        // UnLock will come if resume is called for that thread.
+        __Lock(&m_threadLock);
+        __UnLock(&m_threadLock);
+#else
+        __SuspendThread(m_threadId);
+#endif
+    }
+
+    void ThreadId::resume()
+    {
+        setStatus(Running);
+        /*
+        ** BJ: Lock trick to force thread wait does not work under windows.
+        ** This will release Thread::suspend function.
+        ** Thread waiting in pause GW will then continue and check new thread status (Running)
+        */
+#ifndef _MSC_VER
+        __UnLock(&m_threadLock);
+#else
+        __ResumeThread(m_threadId);
+#endif
+    }
+
+    void ThreadId::abort()
+    {
+        setStatus(Aborted);
+        /*
+        ** BJ: Lock trick to force thread wait does not work under windows.
+        ** This will release Thread::suspend function.
+        ** Thread waiting in pause GW will then continue and check new thread status (Aborted)
+        */
+#ifndef _MSC_VER
+        __UnLock(&m_threadLock);
+#else
+        __ResumeThread(m_threadId);
+#endif
+    }
+
     std::wstring ThreadId::toString(int _iPrecision, int _iLineLen)
-       {
+    {
         std::wostringstream ostr;
 
         ostr << L"ThreadId : " << this << std::endl;