src/c/CreateDoubleVariable.c \
src/c/CreateIntegerVariable.c \
src/c/CreateSparseVariable.c \
- src/c/GetMatlabVariable.c \
- src/c/GetMlistVariable.c
+ src/c/GetMatlabVariable.c
#### List of the C++ files ####
MATIO_CPP_SOURCES = \
src/cpp/GetIntegerVariable.cpp \
src/cpp/GetCharVariable.cpp \
src/cpp/GetDoubleVariable.cpp \
- src/cpp/GetSparseVariable.cpp
+ src/cpp/GetSparseVariable.cpp \
+ src/cpp/GetMlistVariable.cpp
libscimatio_la_LDFLAGS = $(AM_LDFLAGS)
src/c/CreateMatlabVariable.c src/c/CreateBooleanVariable.c \
src/c/CreateCharVariable.c src/c/CreateDoubleVariable.c \
src/c/CreateIntegerVariable.c src/c/CreateSparseVariable.c \
- src/c/GetMatlabVariable.c src/c/GetMlistVariable.c \
- src/cpp/CreateCellVariable.cpp \
+ src/c/GetMatlabVariable.c src/cpp/CreateCellVariable.cpp \
src/cpp/CreateHyperMatrixVariable.cpp \
src/cpp/CreateMatlabTreeVariable.cpp \
src/cpp/GetCellVariable.cpp src/cpp/GetStructVariable.cpp \
src/cpp/CreateStructVariable.cpp \
src/cpp/ConvertSciVarToMatVar.cpp \
src/cpp/GetIntegerVariable.cpp src/cpp/GetCharVariable.cpp \
- src/cpp/GetDoubleVariable.cpp src/cpp/GetSparseVariable.cpp
+ src/cpp/GetDoubleVariable.cpp src/cpp/GetSparseVariable.cpp \
+ src/cpp/GetMlistVariable.cpp
am__dirstamp = $(am__leading_dot)dirstamp
@MATIO_TRUE@am__objects_1 = \
@MATIO_TRUE@ src/c/libscimatio_algo_la-matfile_manager.lo \
@MATIO_TRUE@ src/c/libscimatio_algo_la-CreateDoubleVariable.lo \
@MATIO_TRUE@ src/c/libscimatio_algo_la-CreateIntegerVariable.lo \
@MATIO_TRUE@ src/c/libscimatio_algo_la-CreateSparseVariable.lo \
-@MATIO_TRUE@ src/c/libscimatio_algo_la-GetMatlabVariable.lo \
-@MATIO_TRUE@ src/c/libscimatio_algo_la-GetMlistVariable.lo
+@MATIO_TRUE@ src/c/libscimatio_algo_la-GetMatlabVariable.lo
@MATIO_TRUE@am__objects_2 = \
@MATIO_TRUE@ src/cpp/libscimatio_algo_la-CreateCellVariable.lo \
@MATIO_TRUE@ src/cpp/libscimatio_algo_la-CreateHyperMatrixVariable.lo \
@MATIO_TRUE@ src/cpp/libscimatio_algo_la-GetIntegerVariable.lo \
@MATIO_TRUE@ src/cpp/libscimatio_algo_la-GetCharVariable.lo \
@MATIO_TRUE@ src/cpp/libscimatio_algo_la-GetDoubleVariable.lo \
-@MATIO_TRUE@ src/cpp/libscimatio_algo_la-GetSparseVariable.lo
+@MATIO_TRUE@ src/cpp/libscimatio_algo_la-GetSparseVariable.lo \
+@MATIO_TRUE@ src/cpp/libscimatio_algo_la-GetMlistVariable.lo
am_libscimatio_algo_la_OBJECTS = $(am__objects_1) $(am__objects_2)
libscimatio_algo_la_OBJECTS = $(am_libscimatio_algo_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
@MATIO_TRUE@ src/c/CreateDoubleVariable.c \
@MATIO_TRUE@ src/c/CreateIntegerVariable.c \
@MATIO_TRUE@ src/c/CreateSparseVariable.c \
-@MATIO_TRUE@ src/c/GetMatlabVariable.c \
-@MATIO_TRUE@ src/c/GetMlistVariable.c
+@MATIO_TRUE@ src/c/GetMatlabVariable.c
#### List of the C++ files ####
@MATIO_TRUE@ src/cpp/GetIntegerVariable.cpp \
@MATIO_TRUE@ src/cpp/GetCharVariable.cpp \
@MATIO_TRUE@ src/cpp/GetDoubleVariable.cpp \
-@MATIO_TRUE@ src/cpp/GetSparseVariable.cpp
+@MATIO_TRUE@ src/cpp/GetSparseVariable.cpp \
+@MATIO_TRUE@ src/cpp/GetMlistVariable.cpp
@MATIO_TRUE@libscimatio_la_LDFLAGS = $(AM_LDFLAGS)
@MATIO_FALSE@GATEWAY_CPP_SOURCES =
src/c/$(am__dirstamp) src/c/$(DEPDIR)/$(am__dirstamp)
src/c/libscimatio_algo_la-GetMatlabVariable.lo: src/c/$(am__dirstamp) \
src/c/$(DEPDIR)/$(am__dirstamp)
-src/c/libscimatio_algo_la-GetMlistVariable.lo: src/c/$(am__dirstamp) \
- src/c/$(DEPDIR)/$(am__dirstamp)
src/cpp/$(am__dirstamp):
@$(MKDIR_P) src/cpp
@: > src/cpp/$(am__dirstamp)
src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
src/cpp/libscimatio_algo_la-GetSparseVariable.lo: \
src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
+src/cpp/libscimatio_algo_la-GetMlistVariable.lo: \
+ src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
libscimatio-algo.la: $(libscimatio_algo_la_OBJECTS) $(libscimatio_algo_la_DEPENDENCIES) $(EXTRA_libscimatio_algo_la_DEPENDENCIES)
$(AM_V_CXXLD)$(CXXLINK) $(libscimatio_algo_la_OBJECTS) $(libscimatio_algo_la_LIBADD) $(LIBS)
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscimatio_algo_la-CreateMatlabVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscimatio_algo_la-CreateSparseVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscimatio_algo_la-GetMatlabVariable.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscimatio_algo_la-GetMlistVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscimatio_algo_la-matfile_manager.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-ConvertSciVarToMatVar.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-CreateCellVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-GetCharVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-GetDoubleVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-GetIntegerVariable.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-GetMlistVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-GetSparseVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-GetStructVariable.Plo@am__quote@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/libscimatio_algo_la-GetMatlabVariable.lo `test -f 'src/c/GetMatlabVariable.c' || echo '$(srcdir)/'`src/c/GetMatlabVariable.c
-src/c/libscimatio_algo_la-GetMlistVariable.lo: src/c/GetMlistVariable.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/c/libscimatio_algo_la-GetMlistVariable.lo -MD -MP -MF src/c/$(DEPDIR)/libscimatio_algo_la-GetMlistVariable.Tpo -c -o src/c/libscimatio_algo_la-GetMlistVariable.lo `test -f 'src/c/GetMlistVariable.c' || echo '$(srcdir)/'`src/c/GetMlistVariable.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/c/$(DEPDIR)/libscimatio_algo_la-GetMlistVariable.Tpo src/c/$(DEPDIR)/libscimatio_algo_la-GetMlistVariable.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/c/GetMlistVariable.c' object='src/c/libscimatio_algo_la-GetMlistVariable.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/libscimatio_algo_la-GetMlistVariable.lo `test -f 'src/c/GetMlistVariable.c' || echo '$(srcdir)/'`src/c/GetMlistVariable.c
-
sci_gateway/c/libscimatio_la-gw_matio.lo: sci_gateway/c/gw_matio.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sci_gateway/c/libscimatio_la-gw_matio.lo -MD -MP -MF sci_gateway/c/$(DEPDIR)/libscimatio_la-gw_matio.Tpo -c -o sci_gateway/c/libscimatio_la-gw_matio.lo `test -f 'sci_gateway/c/gw_matio.c' || echo '$(srcdir)/'`sci_gateway/c/gw_matio.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) sci_gateway/c/$(DEPDIR)/libscimatio_la-gw_matio.Tpo sci_gateway/c/$(DEPDIR)/libscimatio_la-gw_matio.Plo
@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) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscimatio_algo_la-GetSparseVariable.lo `test -f 'src/cpp/GetSparseVariable.cpp' || echo '$(srcdir)/'`src/cpp/GetSparseVariable.cpp
+src/cpp/libscimatio_algo_la-GetMlistVariable.lo: src/cpp/GetMlistVariable.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscimatio_algo_la-GetMlistVariable.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscimatio_algo_la-GetMlistVariable.Tpo -c -o src/cpp/libscimatio_algo_la-GetMlistVariable.lo `test -f 'src/cpp/GetMlistVariable.cpp' || echo '$(srcdir)/'`src/cpp/GetMlistVariable.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscimatio_algo_la-GetMlistVariable.Tpo src/cpp/$(DEPDIR)/libscimatio_algo_la-GetMlistVariable.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/cpp/GetMlistVariable.cpp' object='src/cpp/libscimatio_algo_la-GetMlistVariable.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) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscimatio_algo_la-GetMlistVariable.lo `test -f 'src/cpp/GetMlistVariable.cpp' || echo '$(srcdir)/'`src/cpp/GetMlistVariable.cpp
+
mostlyclean-libtool:
-rm -f *.lo
<ClCompile Include="src\cpp\GetCharVariable.cpp" />
<ClCompile Include="src\cpp\GetDoubleVariable.cpp" />
<ClCompile Include="src\cpp\GetIntegerVariable.cpp" />
+ <ClCompile Include="src\cpp\GetMlistVariable.cpp" />
<ClCompile Include="src\cpp\GetSparseVariable.cpp" />
<ClCompile Include="src\cpp\GetStructVariable.cpp" />
<ClCompile Include="src\c\CreateBooleanVariable.c" />
<ClCompile Include="src\c\CreateSparseVariable.c" />
<ClCompile Include="src\c\DllmainMatio.c" />
<ClCompile Include="src\c\GetMatlabVariable.c" />
- <ClCompile Include="src\c\GetMlistVariable.c" />
<ClCompile Include="sci_gateway\c\gw_matio.c" />
<ClCompile Include="src\c\matfile_manager.c" />
</ItemGroup>
<ClCompile Include="src\c\GetMatlabVariable.c">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\c\GetMlistVariable.c">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="sci_gateway\c\gw_matio.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\cpp\GetSparseVariable.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\cpp\GetMlistVariable.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\c\CreateMatlabVariable.h">
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2008 - INRIA - Vincent COUVERT
- * Copyright (C) 2010 - DIGITEO - Yann COLLETTE
- *
- * 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 <string.h>
-
-#include "GetMatlabVariable.h"
-#include "sci_types.h"
-#include "api_scilab.h"
-#include "freeArrayOfString.h"
-#include "sci_malloc.h"
-
-matvar_t *GetMlistVariable(void *pvApiCtx, int iVar, const char *name, int matfile_version, int * parent, int item_position)
-{
- char **fieldNames = NULL;
- int * pilen = NULL;
- int nbRow = 0, nbFields = 0, i;
- int * var_addr = NULL;
- int var_type;
- SciErr sciErr;
- matvar_t * tmp_res = NULL;
-
- if ((parent == NULL) && (item_position == -1))
- {
- sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &var_addr);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
- }
- else if ((parent != NULL) && (item_position == -1))
- {
- var_addr = parent;
- }
- else
- {
- sciErr = getListItemAddress(pvApiCtx, parent, item_position, &var_addr);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
- }
-
- sciErr = getVarType(pvApiCtx, var_addr, &var_type);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
-
- if (var_type == sci_mlist)
- {
- /* FIRST LIST ENTRY: fieldnames */
- sciErr = getMatrixOfStringInList(pvApiCtx, var_addr, 1, &nbRow, &nbFields, NULL, NULL);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
- pilen = (int *)MALLOC(nbRow * nbFields * sizeof(int));
- fieldNames = (char **)MALLOC(nbRow * nbFields * sizeof(char *));
- sciErr = getMatrixOfStringInList(pvApiCtx, var_addr, 1, &nbRow, &nbFields, pilen, NULL);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
- for (i = 0; i < nbRow * nbFields; i++)
- {
- fieldNames[i] = (char *)MALLOC((pilen[i] + 1) * sizeof(char));
- }
- sciErr = getMatrixOfStringInList(pvApiCtx, var_addr, 1, &nbRow, &nbFields, pilen, fieldNames);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
- FREE(pilen);
-
- if (strcmp(fieldNames[0], "ce") == 0)
- {
- freeArrayOfString(fieldNames, nbRow * nbFields);
- return GetCellVariable(pvApiCtx, iVar, name, matfile_version, parent, item_position);
- }
- else if (strcmp(fieldNames[0], "st") == 0)
- {
- tmp_res = GetStructVariable(pvApiCtx, iVar, name, matfile_version, parent, item_position);
- freeArrayOfString(fieldNames, nbFields);
- return tmp_res;
- }
- else if (strcmp(fieldNames[0], "hm") == 0)
- {
- /* TODO */
- Scierror(999, _("%s: Mlists of type %s can not be written to Matlab binary files.\n"), "GetMlistVariable", fieldNames[0]);
- freeArrayOfString(fieldNames, nbFields);
- return NULL;
- }
- else
- {
- Scierror(999, _("%s: Mlists of type %s can not be written to Matlab binary files.\n"), "GetMlistVariable", fieldNames[0]);
- freeArrayOfString(fieldNames, nbFields);
- return NULL;
- }
- }
- else
- {
- Scierror(999, _("%s: Wrong type for first input argument: Mlist expected.\n"), "GetMlistVariable");
- return NULL;
- }
-}
matvar_t *ConvertSciVarToMatVar(InternalType* pIT, const char *name, int matfile_version)
{
- int Dims = pIT->getAs<GenericType>()->getDims();
- int* pDims = pIT->getAs<GenericType>()->getDimsArray();
- int isize = pIT->getAs<GenericType>()->getSize();
- size_t* psize_t = (size_t*)MALLOC(Dims * sizeof(size_t));
- struct mat_complex_split_t mat5ComplexData;
-
- for (int i = 0; i < Dims; i++)
- {
- psize_t[i] = (int)pDims[i];
- }
-
switch (pIT->getType())
{
case GenericType::ScilabDouble:
break;
case GenericType::ScilabCell:
{
- matvar_t **cellEntries = NULL;
-
- cellEntries = (matvar_t **)MALLOC(sizeof(matvar_t*) * isize);
- if (cellEntries == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "ConvertSciVarToMatVar");
- return NULL;
- }
-
- types::InternalType** ppIT = pIT->getAs<Cell>()->get();
-
- for (int K = 0; K < isize; K++)
- {
- cellEntries[K] = ConvertSciVarToMatVar(ppIT[K], name, matfile_version);
- if (cellEntries[K] == NULL)
- {
- FREE(cellEntries);
- FREE(psize_t);
- return NULL;
- }
- }
-
- return Mat_VarCreate(name, MAT_C_CELL, MAT_T_CELL, Dims, psize_t, cellEntries, 0);
+ return GetCellMatVar(pIT->getAs<Cell>(), name, matfile_version);
}
break;
case GenericType::ScilabStruct:
{
- matvar_t **structEntries = NULL;
- String* pFieldNames = pIT->getAs<Struct>()->getFieldNames();
- wchar_t** ppwchFieldNames = pFieldNames->get();
- int isizeFieldNames = pFieldNames->getSize();
-
- structEntries = (matvar_t **)MALLOC(sizeof(matvar_t*) * isize * isizeFieldNames + 1);
- if (structEntries == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "ConvertSciVarToMatVar");
- return NULL;
- }
-
- for (int K = 0; K < isize * isizeFieldNames + 1; K++)
- {
- structEntries[K] = NULL;
- }
-
- SingleStruct** ppSingleStruct = pIT->getAs<Struct>()->get();
- for (int i = 0; i < isize; i++)
- {
- for (int j = 0; j < isizeFieldNames; j++)
- {
- structEntries[i * isizeFieldNames + j] = ConvertSciVarToMatVar(ppSingleStruct[i]->get(pFieldNames->get(j)), wide_string_to_UTF8(pFieldNames->get(j)), matfile_version);
- if (structEntries[i * isizeFieldNames + j] == NULL)
- {
- FREE(structEntries);
- FREE(psize_t);
- return NULL;
- }
- }
- }
-
- return Mat_VarCreate(name, MAT_C_STRUCT, MAT_T_STRUCT, isize * isizeFieldNames, psize_t, structEntries, 0);
+ return GetStructMatVar(pIT->getAs<Struct>(), name, matfile_version);
+ }
+ break;
+ case GenericType::ScilabMList:
+ {
+ return GetMListMatVar(pIT->getAs<MList>(), name, matfile_version);
}
break;
default:
*
*/
+#include "GetMatlabVariable.hxx"
#include "gatewaystruct.hxx"
-#include "cell.hxx"
#include "context.hxx"
#include "ConvertSciVarToMatVar.hxx"
extern "C"
{
-#include "GetMatlabVariable.h"
#include "sci_types.h"
#include "api_scilab.h"
#include "freeArrayOfString.h"
matvar_t *GetCellVariable(void *pvApiCtx, int iVar, const char *name, int matfile_version, int * parent, int item_position)
{
- GatewayStruct* pStr = (GatewayStruct*)pvApiCtx;
- typed_list in = *pStr->m_pIn;
- InternalType** out = pStr->m_pOut;
- int Dims = 1;
- int* pDims = NULL;
- int prodDims = 1;
+ types::GatewayStruct* pGS = (types::GatewayStruct*)pvApiCtx;
+ types::typed_list in = *pGS->m_pIn;
- int nbFields = 0;
- int K = 0;
- size_t *pszDims = NULL;
+ if (in[iVar - 1]->isCell() == false)
+ {
+ Scierror(999, _("%s: Wrong type for first input argument: String matrix expected.\n"), "GetCellVariable");
+ return NULL;
+ }
+
+ types::Cell* pCell = in[iVar - 1]->getAs<types::Cell>();
+
+ return GetCellMatVar(pCell, name, matfile_version);
+}
+matvar_t* GetCellMatVar(types::Cell* pCell, const char* name, int matfile_version)
+{
matvar_t **cellEntries = NULL;
- int * var_addr = NULL;
- Cell* pCell = in[iVar - 1]->getAs<Cell>();
- Dims = pCell->getDims();
- pDims = pCell->getDimsArray();
- prodDims = pCell->getSize();
+ int Dims = pCell->getDims();
+ int* pDims = pCell->getDimsArray();
+ int prodDims = pCell->getSize();
+
+ matvar_t* pMatVarOut = NULL;
/* OTHERS LIST ENTRIES: ALL CELL VALUES */
- pszDims = (size_t*)MALLOC(Dims * sizeof(size_t));
+ size_t* pszDims = (size_t*)MALLOC(Dims * sizeof(size_t));
if (pszDims == NULL)
{
- Scierror(999, _("%s: No more memory.\n"), "GetCellVariable");
+ Scierror(999, _("%s: No more memory.\n"), "GetCellMatVar");
return NULL;
}
/* Total number of entries */
- for (K = 0; K < Dims; K++)
+ for (int K = 0; K < Dims; ++K)
{
pszDims[K] = ((int*)pDims)[K];
}
- cellEntries = (matvar_t **) MALLOC(sizeof(matvar_t*) * prodDims);
+ cellEntries = (matvar_t **)MALLOC(sizeof(matvar_t*) * prodDims);
if (cellEntries == NULL)
{
- Scierror(999, _("%s: No more memory.\n"), "GetCellVariable");
+ Scierror(999, _("%s: No more memory.\n"), "GetCellMatVar");
return NULL;
}
types::InternalType** ppIT = pCell->get();
- for (K = 0; K < prodDims; K++)
+ for (int K = 0; K < prodDims; ++K)
{
cellEntries[K] = ConvertSciVarToMatVar(ppIT[K], name, matfile_version);
if (cellEntries[K] == NULL)
}
}
- return Mat_VarCreate(name, MAT_C_CELL, MAT_T_CELL, Dims, pszDims, cellEntries, 0);
-}
\ No newline at end of file
+ pMatVarOut = Mat_VarCreate(name, MAT_C_CELL, MAT_T_CELL, Dims, pszDims, cellEntries, 0);
+
+ FREE(pszDims);
+
+ return pMatVarOut;
+}
#include "context.hxx"
#include "string.hxx"
#include "sparse.hxx"
+#include "cell.hxx"
+#include "mlist.hxx"
+
extern "C"
{
matvar_t* GetSparseMatVar(types::Sparse* pSparse, const char* name);
+matvar_t* GetStructMatVar(types::Struct* pStruct, const char* name, int matfile_version);
+
+matvar_t* GetCellMatVar(types::Cell* pCell, const char* name, int matfile_version);
+
+matvar_t* GetMListMatVar(types::MList* pMist, const char* name, int matfile_version);
+
#endif /* !__GETMATLABVARIABLE_HXX__ */
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008 - INRIA - Vincent COUVERT
+ * Copyright (C) 2010 - DIGITEO - Yann COLLETTE
+ *
+ * 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 "GetMatlabVariable.hxx"
+
+extern "C"
+{
+#include <string.h>
+
+
+#include "sci_types.h"
+#include "api_scilab.h"
+#include "freeArrayOfString.h"
+#include "sci_malloc.h"
+}
+
+matvar_t *GetMlistVariable(void *pvApiCtx, int iVar, const char *name, int matfile_version, int * parent, int item_position)
+{
+
+ types::GatewayStruct* pGS = (types::GatewayStruct*)pvApiCtx;
+ types::typed_list in = *pGS->m_pIn;
+
+ if (in[iVar - 1]->isMList() == false)
+ {
+ Scierror(999, _("%s: Wrong type for argument %d: MList expected.\n"), "GetMlistVariable");
+ return NULL;
+ }
+
+ types::MList* pMList = in[iVar - 1]->getAs<types::MList>();
+
+ return GetMListMatVar(pMList, name, matfile_version);
+}
+
+
+matvar_t* GetMListMatVar(types::MList* pMist, const char* name, int matfile_version)
+{
+ char* pcName = wide_string_to_UTF8(pMist->getFieldNames()->get(0));
+ Scierror(999, _("%s: Mlists of type %s can not be written to Matlab binary files.\n"), "GetMListMatVar", pcName);
+ FREE(pcName);
+ return NULL;
+}
}
matvar_t *GetStructVariable(void *pvApiCtx, int iVar, const char *name, int matfile_version, int * parent, int item_position)
-//(void *pvApiCtx, int iVar, const char *name, int matfile_version, char **fieldNames, int nbFields, int * parent, int item_position)
{
- GatewayStruct* pStr = (GatewayStruct*)pvApiCtx;
- typed_list in = *pStr->m_pIn;
- InternalType** out = pStr->m_pOut;
- int Dims = 1;
- int* pDims = NULL;
- int prodDims = 1;
+ types::GatewayStruct* pGS = (types::GatewayStruct*)pvApiCtx;
+ types::typed_list in = *pGS->m_pIn;
- int nbFields = 0;
- int K = 0;
- size_t *pszDims = NULL;
+ if (in[iVar - 1]->isStruct() == false)
+ {
+ Scierror(999, _("%s: Wrong type for first input argument: String matrix expected.\n"), "GetStructVariable");
+ return NULL;
+ }
+ types::Struct* pStruct = in[iVar - 1]->getAs<types::Struct>();
+
+ return GetStructMatVar(pStruct, name, matfile_version);
+}
+
+matvar_t* GetStructMatVar(types::Struct* pStruct, const char *name, int matfile_version)
+{
matvar_t **structEntries = NULL;
- int * var_addr = NULL;
- Struct* pStruct = in[iVar - 1]->getAs<Struct>();
- Dims = pStruct->getDims();
- pDims = pStruct->getDimsArray();
- prodDims = pStruct->getSize();
+ int Dims = pStruct->getDims();
+ int* pDims = pStruct->getDimsArray();
+ int prodDims = pStruct->getSize();
+
+ matvar_t* pMatVarOut = NULL;
/* OTHERS LIST ENTRIES: ALL CELL VALUES */
- pszDims = (size_t*)MALLOC(Dims * sizeof(size_t));
+ size_t* pszDims = (size_t*)MALLOC(Dims * sizeof(size_t));
if (pszDims == NULL)
{
- Scierror(999, _("%s: No more memory.\n"), "GetStructVariable");
+ Scierror(999, _("%s: No more memory.\n"), "GetStructMatVar");
return NULL;
}
+ String* pFieldNames = pStruct->getFieldNames();
+ wchar_t** ppwchFieldNames = pFieldNames->get();
+ int isizeFieldNames = pFieldNames->getSize();
+
/* Total number of entries */
- for (K = 0; K < Dims; K++)
+ for (int K = 0; K < Dims; ++K)
{
pszDims[K] = ((int*)pDims)[K];
}
-
- String* pFieldNames = pStruct->getFieldNames();
- wchar_t** ppwchFieldNames = pFieldNames->get();
- int isizeFieldNames = pFieldNames->getSize();
+ pszDims[1] = pszDims[1] * isizeFieldNames;
structEntries = (matvar_t **)MALLOC(sizeof(matvar_t*) * prodDims * isizeFieldNames + 1);
if (structEntries == NULL)
{
- Scierror(999, _("%s: No more memory.\n"), "GetStructVariable");
+ Scierror(999, _("%s: No more memory.\n"), "GetStructMatVar");
return NULL;
}
- for (int K = 0; K < prodDims * isizeFieldNames + 1; K++)
+ for (int K = 0; K < prodDims * isizeFieldNames + 1; ++K)
{
structEntries[K] = NULL;
}
SingleStruct** ppSingleStruct = pStruct->get();
+
for (int i = 0; i < prodDims; i++)
{
for (int j = 0; j < isizeFieldNames; j++)
}
}
- return Mat_VarCreate(name, MAT_C_STRUCT, MAT_T_STRUCT, prodDims * isizeFieldNames, pszDims, structEntries, 0);
+ pMatVarOut = Mat_VarCreate(name, MAT_C_STRUCT, MAT_T_STRUCT, prodDims , pszDims, structEntries, 0);
+
+ FREE(pszDims);
+ return pMatVarOut;
}