add function diary 87/2387/3
Antoine ELIAS [Fri, 29 Oct 2010 13:04:02 +0000 (15:04 +0200)]
Change-Id: Ib438dc74aec70d6f918ff1f2767a329914f20e51

scilab/modules/output_stream/Makefile.am
scilab/modules/output_stream/Makefile.in
scilab/modules/output_stream/includes/gw_output_stream.h
scilab/modules/output_stream/sci_gateway/cpp/output_stream_gw.cpp
scilab/modules/output_stream/sci_gateway/cpp/sci_diary.cpp
scilab/modules/output_stream/src/c/Shell_Import.def
scilab/modules/output_stream/src/c/api_scilab_Import.def
scilab/modules/output_stream/src/c/diary.h
scilab/modules/output_stream/src/cpp/diary_manager.cpp
scilab/modules/output_stream/src/cpp/yaspio.cpp

index e8ffd7b..01f7484 100644 (file)
@@ -8,7 +8,8 @@
 # are also available at
 # http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 
-OUTPUT_STREAM_CPP_SOURCES = src/cpp/Diary.cpp \
+OUTPUT_STREAM_CPP_SOURCES = \
+       src/cpp/Diary.cpp \
        src/cpp/yaspio.cpp \
        src/cpp/DiaryList.cpp \
        src/cpp/diary_manager.cpp \
@@ -16,6 +17,7 @@ OUTPUT_STREAM_CPP_SOURCES = src/cpp/Diary.cpp \
        src/cpp/getFullFilename.cpp \
        src/cpp/scilab_sprintf.cpp
 
+#
 GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_diary.cpp \
        sci_gateway/cpp/sci_disp.cpp \
@@ -23,70 +25,77 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_msprintf.cpp \
        sci_gateway/cpp/sci_mprintf.cpp
 
-OUTPUT_STREAM_C_SOURCES =      src/c/erro.c \
-                               src/c/cerro.c \
-                               src/c/Scierror.c \
-                               src/c/msgstore.c \
-                               src/c/msgout.c \
-                               src/c/msgs.c \
-                               src/c/msgstxt.c \
-                               src/c/basout.c \
-                               src/c/sciprint.c \
-                               src/c/sciprint_full.c \
-                               src/c/errmds.c \
-                               src/c/errmsg.c \
-                               src/c/error.c \
-                               src/c/error_internal.c \
-                               src/c/do_xxprintf.c \
-                               src/c/set_xxprintf.c
-
-OUTPUT_STREAM_FORTRAN_SOURCES = src/fortran/wspdsp.f \
-               src/fortran/wmdsp.f \
-               src/fortran/strdsp.f \
-               src/fortran/prntid.f \
-               src/fortran/print.f \
-               src/fortran/lspdsp.f \
-               src/fortran/fmttyp.f \
-               src/fortran/fmt.f \
-               src/fortran/dspdsp.f \
-               src/fortran/dmrdsp.f \
-               src/fortran/dmpdsp.f \
-               src/fortran/dmdspf.f \
-               src/fortran/dmdsp.f \
-               src/fortran/dldsp.f \
-               src/fortran/basouttofile.f \
-               src/fortran/formatnumber.f
-
-
-GATEWAY_C_SOURCES = sci_gateway/c/gw_output_stream.c \
-               sci_gateway/c/sci_print.c
-
-
-GATEWAY_FORTRAN_SOURCES = sci_gateway/fortran/intprint.f \
-                       sci_gateway/fortran/intdisp.f
-
-libscioutput_stream_la_CFLAGS=  -I$(top_srcdir)/libs/MALLOC/includes/ \
--I$(srcdir)/includes/ \
--I$(top_srcdir)/modules/core/includes \
--I$(srcdir)/src/c/ \
--I$(top_srcdir)/modules/string/includes \
--I$(top_srcdir)/modules/shell/includes \
--I$(top_srcdir)/modules/api_scilab/includes \
--I$(top_srcdir)/modules/operations/includes
-
-libscioutput_stream_la_CPPFLAGS=  -I$(top_srcdir)/libs/MALLOC/includes/ \
--I$(srcdir)/includes/ \
--I$(top_srcdir)/modules/core/includes \
--I$(srcdir)/src/cpp/ \
--I$(srcdir)/src/c/ \
--I$(top_srcdir)/modules/api_scilab/includes \
--I$(top_srcdir)/modules/operations/includes \
--I$(top_srcdir)/modules/string/includes \
--I$(top_srcdir)/modules/types/includes \
--I$(top_srcdir)/modules/functions_manager/includes \
--I$(top_srcdir)/modules/symbol/includes \
--I$(top_srcdir)/modules/abstractSyntaxTree/includes \
--I$(top_srcdir)/modules/system_env/includes
+OUTPUT_STREAM_C_SOURCES = \
+       src/c/erro.c \
+       src/c/cerro.c \
+       src/c/Scierror.c \
+       src/c/msgstore.c \
+       src/c/msgout.c \
+       src/c/msgs.c \
+       src/c/msgstxt.c \
+       src/c/basout.c \
+       src/c/sciprint.c \
+       src/c/sciprint_full.c \
+       src/c/errmds.c \
+       src/c/errmsg.c \
+       src/c/error.c \
+       src/c/error_internal.c \
+       src/c/do_xxprintf.c \
+       src/c/set_xxprintf.c
+
+OUTPUT_STREAM_FORTRAN_SOURCES = \
+       src/fortran/wspdsp.f \
+       src/fortran/wmdsp.f \
+       src/fortran/strdsp.f \
+       src/fortran/prntid.f \
+       src/fortran/print.f \
+       src/fortran/lspdsp.f \
+       src/fortran/fmttyp.f \
+       src/fortran/fmt.f \
+       src/fortran/dspdsp.f \
+       src/fortran/dmrdsp.f \
+       src/fortran/dmpdsp.f \
+       src/fortran/dmdspf.f \
+       src/fortran/dmdsp.f \
+       src/fortran/dldsp.f \
+       src/fortran/basouttofile.f \
+       src/fortran/formatnumber.f
+
+
+GATEWAY_C_SOURCES = \
+       sci_gateway/c/gw_output_stream.c \
+       sci_gateway/c/sci_print.c
+
+
+GATEWAY_FORTRAN_SOURCES = \
+       sci_gateway/fortran/intprint.f \
+       sci_gateway/fortran/intdisp.f
+
+libscioutput_stream_la_CFLAGS=  \
+       -I$(top_srcdir)/libs/MALLOC/includes/ \
+       -I$(srcdir)/includes/ \
+       -I$(top_srcdir)/modules/core/includes \
+       -I$(srcdir)/src/c/ \
+       -I$(top_srcdir)/modules/string/includes \
+       -I$(top_srcdir)/modules/shell/includes \
+       -I$(top_srcdir)/modules/api_scilab/includes \
+       -I$(top_srcdir)/modules/operations/includes
+
+libscioutput_stream_la_CPPFLAGS=  \
+       -I$(top_srcdir)/libs/MALLOC/includes/ \
+       -I$(srcdir)/includes/ \
+       -I$(top_srcdir)/modules/core/includes \
+       -I$(srcdir)/src/cpp/ \
+       -I$(srcdir)/src/c/ \
+       -I$(top_srcdir)/modules/api_scilab/includes \
+       -I$(top_srcdir)/modules/operations/includes \
+       -I$(top_srcdir)/modules/string/includes \
+       -I$(top_srcdir)/modules/types/includes \
+       -I$(top_srcdir)/modules/functions_manager/includes \
+       -I$(top_srcdir)/modules/symbol/includes \
+       -I$(top_srcdir)/modules/abstractSyntaxTree/includes \
+       -I$(top_srcdir)/modules/system_env/includes \
+       -I$(top_srcdir)/modules/shell/includes
 
 
 pkglib_LTLIBRARIES = libscioutput_stream.la
index a789be3..fd646c4 100644 (file)
@@ -448,7 +448,8 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 yacc_present = @yacc_present@
-OUTPUT_STREAM_CPP_SOURCES = src/cpp/Diary.cpp \
+OUTPUT_STREAM_CPP_SOURCES = \
+       src/cpp/Diary.cpp \
        src/cpp/yaspio.cpp \
        src/cpp/DiaryList.cpp \
        src/cpp/diary_manager.cpp \
@@ -456,6 +457,8 @@ OUTPUT_STREAM_CPP_SOURCES = src/cpp/Diary.cpp \
        src/cpp/getFullFilename.cpp \
        src/cpp/scilab_sprintf.cpp
 
+
+#
 GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_diary.cpp \
        sci_gateway/cpp/sci_disp.cpp \
@@ -463,68 +466,75 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_msprintf.cpp \
        sci_gateway/cpp/sci_mprintf.cpp
 
-OUTPUT_STREAM_C_SOURCES = src/c/erro.c \
-                               src/c/cerro.c \
-                               src/c/Scierror.c \
-                               src/c/msgstore.c \
-                               src/c/msgout.c \
-                               src/c/msgs.c \
-                               src/c/msgstxt.c \
-                               src/c/basout.c \
-                               src/c/sciprint.c \
-                               src/c/sciprint_full.c \
-                               src/c/errmds.c \
-                               src/c/errmsg.c \
-                               src/c/error.c \
-                               src/c/error_internal.c \
-                               src/c/do_xxprintf.c \
-                               src/c/set_xxprintf.c
-
-OUTPUT_STREAM_FORTRAN_SOURCES = src/fortran/wspdsp.f \
-               src/fortran/wmdsp.f \
-               src/fortran/strdsp.f \
-               src/fortran/prntid.f \
-               src/fortran/print.f \
-               src/fortran/lspdsp.f \
-               src/fortran/fmttyp.f \
-               src/fortran/fmt.f \
-               src/fortran/dspdsp.f \
-               src/fortran/dmrdsp.f \
-               src/fortran/dmpdsp.f \
-               src/fortran/dmdspf.f \
-               src/fortran/dmdsp.f \
-               src/fortran/dldsp.f \
-               src/fortran/basouttofile.f \
-               src/fortran/formatnumber.f
-
-GATEWAY_C_SOURCES = sci_gateway/c/gw_output_stream.c \
-               sci_gateway/c/sci_print.c
-
-GATEWAY_FORTRAN_SOURCES = sci_gateway/fortran/intprint.f \
-                       sci_gateway/fortran/intdisp.f
-
-libscioutput_stream_la_CFLAGS = -I$(top_srcdir)/libs/MALLOC/includes/ \
--I$(srcdir)/includes/ \
--I$(top_srcdir)/modules/core/includes \
--I$(srcdir)/src/c/ \
--I$(top_srcdir)/modules/string/includes \
--I$(top_srcdir)/modules/shell/includes \
--I$(top_srcdir)/modules/api_scilab/includes \
--I$(top_srcdir)/modules/operations/includes
-
-libscioutput_stream_la_CPPFLAGS = -I$(top_srcdir)/libs/MALLOC/includes/ \
--I$(srcdir)/includes/ \
--I$(top_srcdir)/modules/core/includes \
--I$(srcdir)/src/cpp/ \
--I$(srcdir)/src/c/ \
--I$(top_srcdir)/modules/api_scilab/includes \
--I$(top_srcdir)/modules/operations/includes \
--I$(top_srcdir)/modules/string/includes \
--I$(top_srcdir)/modules/types/includes \
--I$(top_srcdir)/modules/functions_manager/includes \
--I$(top_srcdir)/modules/symbol/includes \
--I$(top_srcdir)/modules/abstractSyntaxTree/includes \
--I$(top_srcdir)/modules/system_env/includes
+OUTPUT_STREAM_C_SOURCES = \
+       src/c/erro.c \
+       src/c/cerro.c \
+       src/c/Scierror.c \
+       src/c/msgstore.c \
+       src/c/msgout.c \
+       src/c/msgs.c \
+       src/c/msgstxt.c \
+       src/c/basout.c \
+       src/c/sciprint.c \
+       src/c/sciprint_full.c \
+       src/c/errmds.c \
+       src/c/errmsg.c \
+       src/c/error.c \
+       src/c/error_internal.c \
+       src/c/do_xxprintf.c \
+       src/c/set_xxprintf.c
+
+OUTPUT_STREAM_FORTRAN_SOURCES = \
+       src/fortran/wspdsp.f \
+       src/fortran/wmdsp.f \
+       src/fortran/strdsp.f \
+       src/fortran/prntid.f \
+       src/fortran/print.f \
+       src/fortran/lspdsp.f \
+       src/fortran/fmttyp.f \
+       src/fortran/fmt.f \
+       src/fortran/dspdsp.f \
+       src/fortran/dmrdsp.f \
+       src/fortran/dmpdsp.f \
+       src/fortran/dmdspf.f \
+       src/fortran/dmdsp.f \
+       src/fortran/dldsp.f \
+       src/fortran/basouttofile.f \
+       src/fortran/formatnumber.f
+
+GATEWAY_C_SOURCES = \
+       sci_gateway/c/gw_output_stream.c \
+       sci_gateway/c/sci_print.c
+
+GATEWAY_FORTRAN_SOURCES = \
+       sci_gateway/fortran/intprint.f \
+       sci_gateway/fortran/intdisp.f
+
+libscioutput_stream_la_CFLAGS = \
+       -I$(top_srcdir)/libs/MALLOC/includes/ \
+       -I$(srcdir)/includes/ \
+       -I$(top_srcdir)/modules/core/includes \
+       -I$(srcdir)/src/c/ \
+       -I$(top_srcdir)/modules/string/includes \
+       -I$(top_srcdir)/modules/shell/includes \
+       -I$(top_srcdir)/modules/api_scilab/includes \
+       -I$(top_srcdir)/modules/operations/includes
+
+libscioutput_stream_la_CPPFLAGS = \
+       -I$(top_srcdir)/libs/MALLOC/includes/ \
+       -I$(srcdir)/includes/ \
+       -I$(top_srcdir)/modules/core/includes \
+       -I$(srcdir)/src/cpp/ \
+       -I$(srcdir)/src/c/ \
+       -I$(top_srcdir)/modules/api_scilab/includes \
+       -I$(top_srcdir)/modules/operations/includes \
+       -I$(top_srcdir)/modules/string/includes \
+       -I$(top_srcdir)/modules/types/includes \
+       -I$(top_srcdir)/modules/functions_manager/includes \
+       -I$(top_srcdir)/modules/symbol/includes \
+       -I$(top_srcdir)/modules/abstractSyntaxTree/includes \
+       -I$(top_srcdir)/modules/system_env/includes \
+       -I$(top_srcdir)/modules/shell/includes
 
 pkglib_LTLIBRARIES = libscioutput_stream.la
 @GUI_TRUE@USEANT = 1
index acd9d41..a57aa4d 100644 (file)
@@ -13,7 +13,6 @@
 #ifndef __GW_OUTPUT_STREAM_H__
 #define __GW_OUTPUT_STREAM_H__
 
-#include "api_scilab.h"
 #include "dynlib_output_stream.h"
 /*--------------------------------------------------------------------------*/
 OUTPUT_STREAM_IMPEXP int gw_output_stream(void);
index e730983..7c667be 100644 (file)
 
 #include "output_stream_gw.hxx"
 
+extern "C"
+{
+    #include "gw_output_stream.h"
+}
+
 #define MODULE_NAME L"output_stream"
 
 bool OutputStreamModule::Load()
 {
-       symbol::Context::getInstance()->AddFunction(Function::createFunction(L"disp", &sci_disp, MODULE_NAME));
-       symbol::Context::getInstance()->AddFunction(Function::createFunction(L"msprintf", &sci_msprintf, MODULE_NAME));
-       symbol::Context::getInstance()->AddFunction(Function::createFunction(L"mprintf", &sci_mprintf, MODULE_NAME));
-  return true;
+    symbol::Context::getInstance()->AddFunction(Function::createFunction(L"disp", &sci_disp, MODULE_NAME));
+    symbol::Context::getInstance()->AddFunction(Function::createFunction(L"msprintf", &sci_msprintf, MODULE_NAME));
+    symbol::Context::getInstance()->AddFunction(Function::createFunction(L"mprintf", &sci_mprintf, MODULE_NAME));
+    symbol::Context::getInstance()->AddFunction(Function::createFunction(L"diary", &sci_diary, MODULE_NAME));
+    return true;
 }
index 38c13fc..8c0aa68 100644 (file)
@@ -17,6 +17,7 @@ extern "C"
 #include "gw_output_stream.h"
 #include "stack-c.h"
 #include "api_scilab.h"
+#include "api_oldstack.h"
 #include "localization.h"
 #include "charEncoding.h"
 #include "Scierror.h"
@@ -182,7 +183,7 @@ static int sci_diary_no_rhs(char *fname, int* _piKey)
                }
        }
 
-       C2F(putlhsvar)();
+       PutLhsVar();
 
        return 0;
 }
@@ -221,7 +222,7 @@ static int sci_diary_one_rhs(char *fname, int* _piKey)
                         ((IDs_size == 1) && ((int)IDs[0] == 0)))
                {
                        diaryCloseAll();
-                       C2F(putlhsvar)();
+                       PutLhsVar();
                }
                else
                {
@@ -295,7 +296,7 @@ static int sci_diary_one_rhs(char *fname, int* _piKey)
                        }
 
                        freeArrayOfWideString(wcFilenames,sizewcFilenames);
-                       C2F(putlhsvar)();
+                       PutLhsVar();
                }
                else
                {
@@ -1019,7 +1020,7 @@ static int CloseByFilenames(char *fname, int* _piKey)
        }
 
        freeArrayOfWideString(wcFilenames, dIDs_size);
-       C2F(putlhsvar)();
+       PutLhsVar();
        return 0;
 }
 /*--------------------------------------------------------------------------*/
@@ -1035,7 +1036,7 @@ static int CloseByIds(char *fname, int* _piKey)
        {
                // diary([], 'close')
                diaryCloseAll();
-               C2F(putlhsvar)();
+               PutLhsVar();
                return 0;
        }
        else if (ierr) return 0;
@@ -1051,7 +1052,7 @@ static int CloseByIds(char *fname, int* _piKey)
                        return 0;
                }
        }
-       C2F(putlhsvar)();
+       PutLhsVar();
        return 0;
 }
 /*--------------------------------------------------------------------------*/
@@ -1083,7 +1084,7 @@ static int PauseByFilenames(char *fname, int* _piKey)
 
        freeArrayOfWideString(wcFilenames, dIDs_size);
 
-       C2F(putlhsvar)();
+       PutLhsVar();
        return 0;
 }
 /*--------------------------------------------------------------------------*/
@@ -1108,7 +1109,7 @@ static int PauseByIds(char *fname, int* _piKey)
                }
        }
 
-       C2F(putlhsvar)();
+       PutLhsVar();
 
        return 0;
 }
@@ -1140,7 +1141,7 @@ static int ResumeByFilenames(char *fname, int* _piKey)
 
        freeArrayOfWideString(wcFilenames, dIDs_size);
 
-       C2F(putlhsvar)();
+       PutLhsVar();
 
        return 0;
 }
@@ -1166,7 +1167,7 @@ static int ResumeByIds(char *fname, int* _piKey)
                }
        }
 
-       C2F(putlhsvar)();
+       PutLhsVar();
 
        return 0;
 }
@@ -1210,7 +1211,7 @@ static int ExistByFilenames(char *fname, int* _piKey)
 
        FREE(resultExist); resultExist = NULL;
        LhsVar(1) = Rhs + 1;
-       C2F(putlhsvar)();
+       PutLhsVar();
        return 0;
 }
 /*--------------------------------------------------------------------------*/
@@ -1252,7 +1253,7 @@ static int ExistByIds(char *fname, int* _piKey)
 
        FREE(resultExist); resultExist = NULL;
        LhsVar(1) = Rhs + 1;
-       C2F(putlhsvar)();
+       PutLhsVar();
        return 0;
 }
 /*--------------------------------------------------------------------------*/
@@ -1319,7 +1320,7 @@ static int AppendByFilenames(char *fname, int* _piKey,
                        LhsVar(2) = Rhs + 2;
                        freeArrayOfWideString(wfilenameUsed, 1);
                }
-               C2F(putlhsvar)();
+               PutLhsVar();
        }
        else
        {
@@ -1387,7 +1388,7 @@ static int NewByFilenames(char *fname, int* _piKey,
                        FREE(wfilenameUsed[0]);
                        delete [] wfilenameUsed;
                }
-               C2F(putlhsvar)();
+               PutLhsVar();
        }
        else
        {
index 763e33a..2fd865c 100644 (file)
@@ -6,5 +6,5 @@ EXPORTS
        getColumnsSize
        linesmore
        TermPrintf_Windows
-       
+       GetCurrentPrompt
        
\ No newline at end of file
index e27f1ca..ef07e19 100644 (file)
@@ -12,3 +12,8 @@ getVarDimension
 getMatrixOfDouble
 getMatrixOfWideString
 createMatrixOfBoolean
+api_Rhs
+api_Lhs
+api_CheckRhs
+api_CheckLhs
+api_LhsVar
index 3a94ea5..50a770f 100644 (file)
@@ -25,14 +25,14 @@ extern "C" {
 * @param[in] string to write
 * @param[in] string is a input
 */
-int diaryWrite(wchar_t *wstr, BOOL bInput);
+int diaryWrite(const wchar_t *wstr, BOOL bInput);
 
 /*
 * same as diaryWrite but add carriage return
 * @param[in] string to write
 * @param[in] string is a input
 */
-int diaryWriteln(wchar_t *wstr, BOOL bInput);
+int diaryWriteln(const wchar_t *wstr, BOOL bInput);
 
 #ifdef  __cplusplus
 }
index a030440..4eeec22 100644 (file)
@@ -245,7 +245,7 @@ int diaryAppend(wchar_t *filename)
        return -1;
 }
 /*--------------------------------------------------------------------------*/
-int diaryWrite(wchar_t *wstr, BOOL bInput)
+int diaryWrite(const wchar_t *wstr, BOOL bInput)
 {
        if (SCIDIARY)
        {
@@ -256,7 +256,7 @@ int diaryWrite(wchar_t *wstr, BOOL bInput)
        return 1;
 }
 /*--------------------------------------------------------------------------*/
-int diaryWriteln(wchar_t *wstr, BOOL bInput)
+int diaryWriteln(const wchar_t *wstr, BOOL bInput)
 {
        if (SCIDIARY)
        {
index b3b8443..9c4483a 100644 (file)
@@ -18,6 +18,8 @@ extern "C"
 {
 #include "charEncoding.h"
 #include "MALLOC.h"
+#include "diary.h"
+#include "prompt.h"
 }
 
 static YASP_OUTPUT _writer;
@@ -35,22 +37,38 @@ void setYaspInputMethod(YASP_INPUT reader)
 
 char *YaspRead()
 {
-    return (*_reader)();
-}
+    char* pstTemp = (*_reader)();
 
-void YaspWrite(const char* text)
-{
-    (*_writer)(const_cast<char*>(text));
+    //add prompt to diary
+    static char pstPrompt[PROMPT_SIZE_MAX];
+    GetCurrentPrompt(pstPrompt);
+    wchar_t* pwstPrompt = to_wide_string(pstPrompt);
+    diaryWrite(pwstPrompt, TRUE);
+    FREE(pwstPrompt);
+
+    //add input to diary
+    wchar_t* pwstIn = to_wide_string(pstTemp);
+    diaryWriteln(pwstIn, TRUE);
+    FREE(pwstIn);
+
+    return pstTemp;
 }
 
-void YaspWriteW(const wchar_t* text)
+void YaspWrite(const char* text)
 {
     int iMode =  getPromptMode();
-
     if(iMode != PROMPTMODE_SILENT)
     {
-        char* pstTemp = wide_string_to_UTF8(text);
-        (*_writer)(pstTemp);
-        FREE(pstTemp);
+        wchar_t* pwstTemp = to_wide_string(text);
+        diaryWrite(pwstTemp, TRUE);
+        FREE(pwstTemp);
+        (*_writer)(const_cast<char*>(text));
     }
 }
+
+void YaspWriteW(const wchar_t* text)
+{
+    char* pstTemp = wide_string_to_UTF8(text);
+    YaspWrite(pstTemp);
+    FREE(pstTemp);
+}