%_save can recover the struct and cell data 75/16375/3
Sylvain GENIN [Wed, 15 Apr 2015 15:11:23 +0000 (17:11 +0200)]
Change-Id: I7fe8491dc7e3a7898733342a160b2b86ff8fd226

scilab/modules/io/macros/%_save.sci

index 8f0f0c6..778dc3e 100644 (file)
@@ -43,7 +43,40 @@ function [] = %_save(%__filename__, varargin)
     endfunction
 
     function result = inspectList(l)
-        if typeof(l)=="list" then
+        if or(typeof(l)==["cell","st"]) then
+            if typeof(l)=="st" then
+                fieldNames = fieldnames(l);
+            else
+                fieldNames = l;
+            end
+
+            for kField = 1:size(fieldNames,"*")
+
+                if typeof(l)=="st" then
+                    fieldValue = l(fieldNames(kField));
+                else
+                    fieldValue = l{kField};
+                end
+
+                if typeof(fieldValue) == "handle" then
+                    fieldValue = extractMatrixHandle(fieldValue);
+                elseif isMacro(fieldValue) | isCompiledMacro(fieldValue) then
+                    //build an arbitrary name to the macro
+                    fieldValue = extractMacro(fieldValue, "function");
+                elseif isList(fieldValue) then
+                    fieldValue = inspectList(fieldValue);
+                end
+
+                if typeof(l)=="st" then
+                    l(fieldNames(kField)) = fieldValue;
+                else
+                    l{kField} = fieldValue;
+                end
+
+            end
+            result = l;
+
+        elseif typeof(l)=="list" then
             result = list();
             for %__i__ = definedfields(l)
                 if typeof(l(%__i__)) == "handle" then