getmemory function plugged. 44/12344/4
Cedric Delamarre [Mon, 26 Aug 2013 15:57:00 +0000 (17:57 +0200)]
Change-Id: Ic9532665f64922c798ae544b0a45fd36125526e9

scilab/modules/core/Makefile.am
scilab/modules/core/Makefile.in
scilab/modules/core/includes/core_gw.hxx
scilab/modules/core/sci_gateway/c/sci_getmemory.c [deleted file]
scilab/modules/core/sci_gateway/cpp/core_gw.cpp
scilab/modules/core/sci_gateway/cpp/core_gw.vcxproj
scilab/modules/core/sci_gateway/cpp/core_gw.vcxproj.filters
scilab/modules/core/sci_gateway/cpp/sci_getmemory.cpp [new file with mode: 0644]

index face994..a809b9c 100644 (file)
@@ -172,7 +172,8 @@ GATEWAY_CPP_SOURCES =       \
        sci_gateway/cpp/sci_funcprot.cpp \
        sci_gateway/cpp/sci_mode.cpp \
        sci_gateway/cpp/sci_typename.cpp \
-       sci_gateway/cpp/sci_where.cpp
+       sci_gateway/cpp/sci_where.cpp \
+       sci_gateway/cpp/sci_getmemory.cpp
 
 
 libscicore_la_CPPFLAGS = \
index eb7dd7b..7057522 100644 (file)
@@ -317,7 +317,8 @@ am__objects_8 = libscicore_la-core_gw.lo \
        libscicore_la-sci_stacksize.lo libscicore_la-sci_format.lo \
        libscicore_la-sci_sciargs.lo libscicore_la-sci_ieee.lo \
        libscicore_la-sci_funcprot.lo libscicore_la-sci_mode.lo \
-       libscicore_la-sci_typename.lo libscicore_la-sci_where.lo
+       libscicore_la-sci_typename.lo libscicore_la-sci_where.lo \
+       libscicore_la-sci_getmemory.lo
 am_libscicore_la_OBJECTS = $(am__objects_6) $(am__objects_7) \
        $(am__objects_8)
 libscicore_la_OBJECTS = $(am_libscicore_la_OBJECTS)
@@ -788,7 +789,8 @@ GATEWAY_CPP_SOURCES = \
        sci_gateway/cpp/sci_funcprot.cpp \
        sci_gateway/cpp/sci_mode.cpp \
        sci_gateway/cpp/sci_typename.cpp \
-       sci_gateway/cpp/sci_where.cpp
+       sci_gateway/cpp/sci_where.cpp \
+       sci_gateway/cpp/sci_getmemory.cpp
 
 libscicore_la_CPPFLAGS = -I$(srcdir)/includes/ -I$(srcdir)/src/c/ \
        -I$(srcdir)/src/cpp/ \
@@ -1137,6 +1139,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_funcprot.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_getdebuginfo.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_getmd5.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_getmemory.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_getmodules.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_getos.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sci_getscilabmode.Plo@am__quote@
@@ -1893,6 +1896,13 @@ libscicore_la-sci_where.lo: sci_gateway/cpp/sci_where.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscicore_la-sci_where.lo `test -f 'sci_gateway/cpp/sci_where.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_where.cpp
 
+libscicore_la-sci_getmemory.lo: sci_gateway/cpp/sci_getmemory.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscicore_la-sci_getmemory.lo -MD -MP -MF $(DEPDIR)/libscicore_la-sci_getmemory.Tpo -c -o libscicore_la-sci_getmemory.lo `test -f 'sci_gateway/cpp/sci_getmemory.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_getmemory.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/libscicore_la-sci_getmemory.Tpo $(DEPDIR)/libscicore_la-sci_getmemory.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='sci_gateway/cpp/sci_getmemory.cpp' object='libscicore_la-sci_getmemory.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscicore_la-sci_getmemory.lo `test -f 'sci_gateway/cpp/sci_getmemory.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_getmemory.cpp
+
 .f.o:
        $(AM_V_F77)$(F77COMPILE) -c -o $@ $<
 
index 785fbda..c2afe2a 100644 (file)
@@ -56,5 +56,6 @@ CPP_GATEWAY_PROTOTYPE(sci_funcprot);
 CPP_GATEWAY_PROTOTYPE(sci_mode);
 CPP_GATEWAY_PROTOTYPE(sci_typename);
 CPP_GATEWAY_PROTOTYPE(sci_where);
+CPP_GATEWAY_PROTOTYPE(sci_getmemory);
 
 #endif /* __CORE_GW_HXX__ */
diff --git a/scilab/modules/core/sci_gateway/c/sci_getmemory.c b/scilab/modules/core/sci_gateway/c/sci_getmemory.c
deleted file mode 100644 (file)
index 97884c3..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2006 - INRIA - Allan CORNET
- *
- * 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.1-en.txt
- *
- */
-#include "getmemory.h"
-#include "gw_core.h"
-#include "stack-c.h"
-/*--------------------------------------------------------------------------*/
-int C2F(sci_getmemory) (char *fname, unsigned long fname_len)
-{
-    static int l1, one = 1;
-
-    Rhs = Max(Rhs, 0);
-    CheckRhs(0, 0) ;
-    CheckLhs(1, 2);
-
-    CreateVar(Rhs + 1, MATRIX_OF_INTEGER_DATATYPE, &one, &one, &l1);
-    *istk(l1) = getfreememory();
-    LhsVar(1) = Rhs + 1;
-    if (Lhs == 2)
-    {
-        CreateVar(Rhs + 2, MATRIX_OF_INTEGER_DATATYPE, &one, &one, &l1);
-        *istk(l1) = getmemorysize();
-        LhsVar(2) = Rhs + 2;
-    }
-
-    PutLhsVar();
-    return 0;
-}
-/*--------------------------------------------------------------------------*/
index 0d2f4de..14ab867 100644 (file)
@@ -55,5 +55,6 @@ int CoreModule::Load()
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"funcprot", &sci_funcprot, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"mode", &sci_mode, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"where", &sci_where, MODULE_NAME));
+    symbol::Context::getInstance()->addFunction(Function::createFunction(L"getmemory", &sci_getmemory, MODULE_NAME));
     return 1;
 }
index 3f4e1d5..7d33568 100644 (file)
   <ItemGroup>
     <ClCompile Include="sci_format.cpp" />
     <ClCompile Include="sci_funcprot.cpp" />
+    <ClCompile Include="sci_getmemory.cpp" />
     <ClCompile Include="sci_ieee.cpp" />
     <ClCompile Include="sci_mode.cpp" />
     <ClCompile Include="sci_sciargs.cpp" />
index 7594bec..11d6639 100644 (file)
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="sci_where.cpp">
+    <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_getmemory.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
     <Library Include="..\..\..\..\bin\libintl.lib" />
     <Library Include="..\..\..\..\bin\libxml2.lib" />
   </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/scilab/modules/core/sci_gateway/cpp/sci_getmemory.cpp b/scilab/modules/core/sci_gateway/cpp/sci_getmemory.cpp
new file mode 100644 (file)
index 0000000..b259545
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2013 - Scilab Enterprises - Cedric Delamarre
+ *
+ *  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 "core_gw.hxx"
+#include "function.hxx"
+#include "configvariable.hxx"
+#include "double.hxx"
+
+extern "C"
+{
+#include "localization.h"
+#include "Scierror.h"
+#include "getmemory.h"
+}
+
+types::Function::ReturnValue sci_getmemory(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    if (in.size() > 0)
+    {
+        Scierror(77, _("%s: Wrong number of input argument(s): %d expected."), "funcprot", 0);
+        return types::Function::Error;
+    }
+
+    if (_iRetCount > 2)
+    {
+        Scierror(77, _("%s: Wrong number of output argument(s): %d expected."), "funcprot", 2);
+        return types::Function::Error;
+    }
+
+    out.push_back(new types::Double((double)getfreememory()));
+
+    if(_iRetCount == 2)
+    {
+        out.push_back(new types::Double((double)getmemorysize()));
+    }
+
+    return types::Function::OK;
+}