YaSp now manage cd and pwd functions 95/495/2
Bruno JOFRET [Fri, 7 May 2010 07:18:46 +0000 (09:18 +0200)]
Change-Id: I4828af1907437063a0917ae9c44f9f13d0630b96

scilab/etc/yasp_modules.xml
scilab/modules/fileio/Makefile.am
scilab/modules/fileio/Makefile.in
scilab/modules/fileio/includes/fileio_gw.hxx [new file with mode: 0644]
scilab/modules/fileio/includes/gw_fileio.h
scilab/modules/fileio/sci_gateway/c/gw_fileio.c
scilab/modules/fileio/sci_gateway/c/sci_chdir.c
scilab/modules/fileio/sci_gateway/c/sci_pwd.c
scilab/modules/fileio/sci_gateway/cpp/fileio_gw.cpp [new file with mode: 0644]
scilab/modules/functions_manager/includes/module_declaration.hxx
scilab/modules/functions_manager/src/cpp/funcmanager.cpp

index e4b1647..71e6dcc 100644 (file)
@@ -22,4 +22,6 @@
     <module name="functions" activate="yes"/>
     <module name="output_stream" activate="yes"/>
     <module name="matio" activate="yes"/>
+    <module name="fileio" activate="yes"/>
+    <module name="development_tools" activate="yes"/>
 </modules>
index e07fac1..dcc7d17 100644 (file)
@@ -53,7 +53,7 @@ src/c/pathconvert.c \
 src/c/copyfile_others.c \
 src/c/getFullFilename.c
 
-GATEWAY_SOURCES = \
+GATEWAY_C_SOURCES = \
 sci_gateway/c/gw_fileio.c \
 sci_gateway/c/sci_mfprintf.c \
 sci_gateway/c/sci_mscanf.c \
@@ -99,6 +99,8 @@ sci_gateway/c/sci_basename.c \
 sci_gateway/c/sci_pathconvert.c \
 sci_gateway/c/sci_isfile.c
 
+GATEWAY_CPP_SOURCES = \
+sci_gateway/cpp/fileio_gw.cpp
 
 libscifileio_la_CPPFLAGS=      -I$(srcdir)/includes/ \
                                -I$(srcdir)/src/c/ \
@@ -106,6 +108,10 @@ libscifileio_la_CPPFLAGS=  -I$(srcdir)/includes/ \
                                -I$(top_srcdir)/modules/api_scilab/includes \
                                -I$(top_srcdir)/modules/output_stream/includes \
                                -I$(top_srcdir)/modules/operations/includes \
+                               -I$(top_srcdir)/modules/types/includes \
+                               -I$(top_srcdir)/modules/functions_manager/includes \
+                               -I$(top_srcdir)/modules/abstractSyntaxTree/includes \
+                               -I$(top_srcdir)/modules/symbol/includes \
                                $(HDF5_CFLAGS)
 
 libscifileio_la_CFLAGS=                -I$(srcdir)/includes/ \
@@ -123,7 +129,7 @@ pkglib_LTLIBRARIES = libscifileio.la
 
 libscifileio_la_LDFLAGS = -version-info $(SCILAB_LIBRARY_VERSION)
 
-libscifileio_la_SOURCES = $(FILEIO_SOURCES) $(GATEWAY_SOURCES) $(GATEWAY_CPP_SOURCES)
+libscifileio_la_SOURCES = $(FILEIO_SOURCES) $(GATEWAY_C_SOURCES) $(GATEWAY_CPP_SOURCES)
 
 # For the code check (splint)
 CHECK_SRC= $(FILEIO_SOURCES) $(GATEWAY_SOURCES)
index 77e34de..8e0b570 100644 (file)
@@ -175,11 +175,13 @@ am__objects_2 = libscifileio_la-gw_fileio.lo \
        libscifileio_la-sci_basename.lo \
        libscifileio_la-sci_pathconvert.lo \
        libscifileio_la-sci_isfile.lo
-am_libscifileio_la_OBJECTS = $(am__objects_1) $(am__objects_2)
+am__objects_3 = libscifileio_la-fileio_gw.lo
+am_libscifileio_la_OBJECTS = $(am__objects_1) $(am__objects_2) \
+       $(am__objects_3)
 libscifileio_la_OBJECTS = $(am_libscifileio_la_OBJECTS)
-libscifileio_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libscifileio_la_CFLAGS) \
-       $(CFLAGS) $(libscifileio_la_LDFLAGS) $(LDFLAGS) -o $@
+libscifileio_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+       $(CXXFLAGS) $(libscifileio_la_LDFLAGS) $(LDFLAGS) -o $@
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/modules/core/includes
 depcomp = $(SHELL) $(top_srcdir)/config/depcomp
 am__depfiles_maybe = depfiles
@@ -193,6 +195,15 @@ CCLD = $(CC)
 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
        --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
        $(LDFLAGS) -o $@
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+       $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+       $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
 SOURCES = $(libscifileio_la_SOURCES)
 DIST_SOURCES = $(libscifileio_la_SOURCES)
 DATA = $(libscifileio_la_etc_DATA) $(libscifileio_la_root_DATA) \
@@ -495,7 +506,7 @@ src/c/pathconvert.c \
 src/c/copyfile_others.c \
 src/c/getFullFilename.c
 
-GATEWAY_SOURCES = \
+GATEWAY_C_SOURCES = \
 sci_gateway/c/gw_fileio.c \
 sci_gateway/c/sci_mfprintf.c \
 sci_gateway/c/sci_mscanf.c \
@@ -541,12 +552,19 @@ sci_gateway/c/sci_basename.c \
 sci_gateway/c/sci_pathconvert.c \
 sci_gateway/c/sci_isfile.c
 
+GATEWAY_CPP_SOURCES = \
+sci_gateway/cpp/fileio_gw.cpp
+
 libscifileio_la_CPPFLAGS = -I$(srcdir)/includes/ \
                                -I$(srcdir)/src/c/ \
                                -I$(top_srcdir)/libs/MALLOC/includes/ \
                                -I$(top_srcdir)/modules/api_scilab/includes \
                                -I$(top_srcdir)/modules/output_stream/includes \
                                -I$(top_srcdir)/modules/operations/includes \
+                               -I$(top_srcdir)/modules/types/includes \
+                               -I$(top_srcdir)/modules/functions_manager/includes \
+                               -I$(top_srcdir)/modules/abstractSyntaxTree/includes \
+                               -I$(top_srcdir)/modules/symbol/includes \
                                $(HDF5_CFLAGS)
 
 libscifileio_la_CFLAGS = -I$(srcdir)/includes/ \
@@ -562,7 +580,7 @@ libscifileio_la_CFLAGS = -I$(srcdir)/includes/ \
 
 pkglib_LTLIBRARIES = libscifileio.la
 libscifileio_la_LDFLAGS = -version-info $(SCILAB_LIBRARY_VERSION)
-libscifileio_la_SOURCES = $(FILEIO_SOURCES) $(GATEWAY_SOURCES) $(GATEWAY_CPP_SOURCES)
+libscifileio_la_SOURCES = $(FILEIO_SOURCES) $(GATEWAY_C_SOURCES) $(GATEWAY_CPP_SOURCES)
 
 # For the code check (splint)
 CHECK_SRC = $(FILEIO_SOURCES) $(GATEWAY_SOURCES)
@@ -656,7 +674,7 @@ HELP_CHAPTERLANG = en_US fr_FR pt_BR
 all: all-am
 
 .SUFFIXES:
-.SUFFIXES: .sci .bin .c .lo .o .obj
+.SUFFIXES: .sci .bin .c .cpp .lo .o .obj
 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/Makefile.incl.am $(am__configure_deps)
        @for dep in $?; do \
          case '$(am__configure_deps)' in \
@@ -741,6 +759,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscifileio_la-do_xxscanf.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscifileio_la-expandPathVariable.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscifileio_la-fileinfo.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscifileio_la-fileio_gw.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscifileio_la-filesmanagement.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscifileio_la-findfiles.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscifileio_la-fullpath.Plo@am__quote@
@@ -1485,6 +1504,34 @@ libscifileio_la-sci_isfile.lo: sci_gateway/c/sci_isfile.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) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(libscifileio_la_CFLAGS) $(CFLAGS) -c -o libscifileio_la-sci_isfile.lo `test -f 'sci_gateway/c/sci_isfile.c' || echo '$(srcdir)/'`sci_gateway/c/sci_isfile.c
 
+.cpp.o:
+@am__fastdepCXX_TRUE@  $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@  $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@  $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+libscifileio_la-fileio_gw.lo: sci_gateway/cpp/fileio_gw.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscifileio_la-fileio_gw.lo -MD -MP -MF $(DEPDIR)/libscifileio_la-fileio_gw.Tpo -c -o libscifileio_la-fileio_gw.lo `test -f 'sci_gateway/cpp/fileio_gw.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/fileio_gw.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscifileio_la-fileio_gw.Tpo $(DEPDIR)/libscifileio_la-fileio_gw.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/fileio_gw.cpp' object='libscifileio_la-fileio_gw.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) $(libscifileio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscifileio_la-fileio_gw.lo `test -f 'sci_gateway/cpp/fileio_gw.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/fileio_gw.cpp
+
 mostlyclean-libtool:
        -rm -f *.lo
 
diff --git a/scilab/modules/fileio/includes/fileio_gw.hxx b/scilab/modules/fileio/includes/fileio_gw.hxx
new file mode 100644 (file)
index 0000000..a8391bd
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ *  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
+ * 
+ */
+
+#ifndef __FILEIO_GW_HXX__
+#define __FILEIO_GW_HXX__
+
+#include "funcmanager.hxx"
+#include "context.hxx"
+
+class FileioModule
+{
+private :
+    FileioModule() {};
+    ~FileioModule() {};
+
+public :
+    static bool Load();
+};
+#endif /* !__FILEIO_GW_HXX__ */
index fbd361f..6a890a6 100644 (file)
@@ -46,7 +46,6 @@ FILEIO_IMPEXP int sci_getshortpathname(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_fileext(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_createdir(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_removedir(char *fname,unsigned long fname_len);
-FILEIO_IMPEXP int sci_pwd(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_fileinfo(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_newest(char *fname,unsigned long fname_len);
 FILEIO_IMPEXP int sci_getrelativefilename(char *fname, unsigned long l);
@@ -54,6 +53,7 @@ FILEIO_IMPEXP int sci_get_absolute_file_path(char *fname,unsigned long fname_len
 FILEIO_IMPEXP int sci_mgetl(char *fname,unsigned long fname_len);
 
 //YaSp
+FILEIO_IMPEXP int sci_pwd(char *fname, int* _piKey);
 FILEIO_IMPEXP int sci_isdir(char *fname, int* _piKey);
 FILEIO_IMPEXP int sci_chdir(char *fname, int* _piKey);
 FILEIO_IMPEXP int sci_copyfile(char *fname,int* _piKey);
index 9068be0..7010b5d 100644 (file)
@@ -49,7 +49,7 @@ static gw_generic_table Tab[]={
        {NULL, ""}, //isdir
        {sci_removedir,"removedir"},
        {sci_createdir,"createdir"},
-       {sci_pwd,"pwd"},
+       {NULL, ""}, // pwd
        {NULL, ""}, //chdir
        {sci_fileinfo,"fileinfo"},
        {sci_newest,"newest"},
index 126596e..f903269 100644 (file)
@@ -21,6 +21,9 @@
 #include "api_scilab.h"
 #include "isdir.h"
 #include "charEncoding.h"
+#include "api_scilab.h"
+#include "api_oldstack.h"
+
 /*--------------------------------------------------------------------------*/
 int sci_chdir(char *fname ,int* _piKey)
 {
@@ -33,9 +36,8 @@ int sci_chdir(char *fname ,int* _piKey)
 
        wchar_t *expandedPath = NULL;
 
-       Rhs = Max(0, Rhs);
        CheckRhs(0,1);
-       CheckLhs(1,1);
+       CheckLhs(0,1);
 
        if (Rhs == 0)
        {
@@ -153,7 +155,7 @@ int sci_chdir(char *fname ,int* _piKey)
                        }
 
                        LhsVar(1) = Rhs + 1;
-                       C2F(putlhsvar)();
+                       PutLhsVar();
                        
                        if (bOutput) {FREE(bOutput); bOutput=NULL;}
                }
@@ -180,7 +182,7 @@ int sci_chdir(char *fname ,int* _piKey)
                                }
 
                                LhsVar(1) = Rhs + 1;
-                               C2F(putlhsvar)();
+                               PutLhsVar();
 
                                if (currentDir) {FREE(currentDir); currentDir = NULL;}
                        }
index 93f6bf6..2aab0b1 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2006 - INRIA - Allan CORNET
+ * Copyright (C) 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
 #include "MALLOC.h"
 #include "Scierror.h"
 #include "localization.h"
+#include "api_scilab.h"
+#include "api_oldstack.h"
+
 /*--------------------------------------------------------------------------*/
-int sci_pwd(char *fname,unsigned long fname_len)
+int sci_pwd(char *fname,int *_piKey)
 {
+    SciErr sciErr;
        int ierr = 0;
        char *path = NULL;
 
-       Rhs = Max(Rhs,0);
-
        CheckRhs(0,0);
        CheckLhs(0,1);
 
@@ -40,9 +43,15 @@ int sci_pwd(char *fname,unsigned long fname_len)
                int m1 = (int)strlen(path);
 
                n1 = 1;
-               CreateVarFromPtr(Rhs+1, STRING_DATATYPE, &m1, &n1, &path);
+        sciErr = createMatrixOfString(_piKey, Rhs + 1, 1, 1, &path);
+        if(sciErr.iErr)
+        {
+            printError(&sciErr, 0);
+            return 0;
+        }
+
                LhsVar(1) = Rhs+1;
-               C2F(putlhsvar)();
+               PutLhsVar();
 
                if (path) {FREE(path); path = NULL;}
        }
diff --git a/scilab/modules/fileio/sci_gateway/cpp/fileio_gw.cpp b/scilab/modules/fileio/sci_gateway/cpp/fileio_gw.cpp
new file mode 100644 (file)
index 0000000..30d9a87
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ *  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 "fileio_gw.hxx"
+
+#define MODULE_NAME "fileio"
+
+extern "C"
+{
+       #include "gw_fileio.h"
+}
+
+using namespace types;
+
+bool FileioModule::Load()
+{
+    symbol::Context::getInstance()->AddFunction(Function::createFunction("cd", &sci_chdir, MODULE_NAME));
+    symbol::Context::getInstance()->AddFunction(Function::createFunction("pwd", &sci_pwd, MODULE_NAME));
+
+    return true;
+}
index 830892e..35cef2e 100644 (file)
@@ -22,5 +22,6 @@
 #include "../../functions/includes/functions_gw.hxx"
 #include "../../output_stream/includes/output_stream_gw.hxx"
 #include "../../matio/includes/matio_gw.hxx"
+#include "../../fileio/includes/fileio_gw.hxx"
 
 #endif /* !__MODULE_DECLARATION_HXX__ */
index 2b99198..7148fdc 100644 (file)
@@ -283,6 +283,7 @@ bool FuncManager::CreateModuleList(void)
        m_ModuleMap.insert(pair<string, GW_MOD>("functions", &FunctionsModule::Load));
        m_ModuleMap.insert(pair<string, GW_MOD>("output_stream", &OutputStreamModule::Load));
        m_ModuleMap.insert(pair<string, GW_MOD>("matio", &MatioModule::Load));
+       m_ModuleMap.insert(pair<string, GW_MOD>("fileio", &FileioModule::Load));
        return bRet;
 }