mpi module plugged.
[scilab.git] / scilab / modules / mpi / src / c / serialization.c
index 29303eb..ce1cfbc 100644 (file)
@@ -15,6 +15,7 @@
 #include "BOOL.h"
 #include "sci_malloc.h"
 #include "serialization.h"
+#include "elem_common.h"
 
 static int serialize_double(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize)
 {
@@ -430,28 +431,36 @@ static int serialize_sparse(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_p
 
 int serialize_to_mpi(void *_pvCtx, int *_piAddr, int **_piBuffer, int *_piBufferSize)
 {
-    switch (*_piAddr)
+    int iType = 0;
+    SciErr sciErr = getVarType(_pvCtx, _piAddr, &iType);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 0;
+    }
+
+    switch (iType)
     {
         case sci_matrix:
-            return serialize_double(pvApiCtx, _piAddr, _piBuffer, _piBufferSize);
+            return serialize_double(_pvCtx, _piAddr, _piBuffer, _piBufferSize);
             break;
         case sci_strings:
-            return serialize_string(pvApiCtx, _piAddr, _piBuffer, _piBufferSize);
+            return serialize_string(_pvCtx, _piAddr, _piBuffer, _piBufferSize);
             break;
         case sci_boolean:
-            return serialize_boolean(pvApiCtx, _piAddr, _piBuffer, _piBufferSize);
+            return serialize_boolean(_pvCtx, _piAddr, _piBuffer, _piBufferSize);
             break;
         case sci_sparse:
-            return serialize_sparse(pvApiCtx, _piAddr, _piBuffer, _piBufferSize, TRUE);
+            return serialize_sparse(_pvCtx, _piAddr, _piBuffer, _piBufferSize, TRUE);
             break;
         case sci_boolean_sparse:
-            return serialize_sparse(pvApiCtx, _piAddr, _piBuffer, _piBufferSize, FALSE);
+            return serialize_sparse(_pvCtx, _piAddr, _piBuffer, _piBufferSize, FALSE);
             break;
         case sci_ints:
-            return serialize_int(pvApiCtx, _piAddr, _piBuffer, _piBufferSize);
+            return serialize_int(_pvCtx, _piAddr, _piBuffer, _piBufferSize);
             break;
         default:
             return -1;
             break;
     }
-}
\ No newline at end of file
+}