Commit 8fc1c293 authored by Matthew Dawson's avatar Matthew Dawson
Browse files

Get the new table tool box generating code.

It can now save itself properly, and generate eml.


git-svn-id: https://groke.mcmaster.ca/svn/grad/colin/branches/TableTool_refactor@8775 57e6efec-57d4-0310-aeb1-a6c144bb1a8b
parent 6b8142f6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@
function code = generate_eml_code(object)
code = [];
code = [code object.generate_preamble];
code = [code object.generate_eml_cond(object.data.Grid1,object.data.Grid2,0)];
code = [code object.generate_eml_cond(object.data.top_cond,object.data.left_cond,0)];

end

+13 −10
Original line number Diff line number Diff line
@@ -12,8 +12,11 @@
%   code:string - string of eml code
% Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification
function code = generate_eml_cond(object,g1,g2,depth)

function code = generate_eml_cond(object,g1,g2,depth,g1p,g2p)
if nargin == 4
    g1p = [];
    g2p = [];
end



@@ -21,8 +24,8 @@ space = '';
for i=1:depth
    space = [space sprintf('  ')];
end
g1cond1 = g1.cells(1).cond_text;
g2cond1 = g2.cells(1).cond_text;
g1cond1 = g1.get_cell(1).get_matlab_string;
g2cond1 = g2.get_cell(1).get_matlab_string;
code = [];
%1D horizontal
if(~isempty(g1cond1) && isempty(g2cond1))
@@ -35,8 +38,8 @@ if(~isempty(g1cond1) && isempty(g2cond1))
else
    
    elsecell = [];
    for i=1:size(g2.cells,2)
        g2cond = g2.cells(i).cond_text;
    for i=1:g2.get_children_count(g2p)
        g2cond = g2.get_child_cell(g2p, i).get_matlab_string
        % condition string of otherwise corresponds to an else
        % statement, we allow this statement to be in any order
        % in the cells of the grid, so we need to find where it
@@ -47,17 +50,17 @@ else
            continue
        end
        if (i == 1)
            code = [code sprintf('%sif(%s)\n',space,(strtrim(char(g2.cells(i).cond_text))))];
            code = [code sprintf('%sif(%s)\n',space,(strtrim(g2cond)))];
        else
            code = [code sprintf('%selseif(%s)\n',space,(strtrim(char(g2.cells(i).cond_text))))];
            code = [code sprintf('%selseif(%s)\n',space,(strtrim(g2cond)))];
        end
        
        if(~isempty(g2.cells(i).subgrid))
        if g2.get_children_count(g2.get_child_cell(g2p, i)) ~= 0
            code = [code object.generate_eml_cond(g1,g2.cells(i).subgrid,depth+1)];
        else
            if (~isempty(g1cond1))
                if object.data.multi_mode == 0
                    code = [code object.generate_eml_horizontal(g1,g2.cells(i),depth+1)];
                    code = [code object.generate_eml_horizontal(g1,i,depth+1)];
                else
                    code = [code object.generate_eml_multi(g1,g2.cells(i),depth+1)];
                end
+7 −7
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
%   code:string - string of eml code
% Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification
function code = generate_eml_horizontal(object,g1,g2_cell,depth)
function code = generate_eml_horizontal(object,g1,g2_cell_index,depth)
space = '';
for i=1:depth
    space = [space sprintf('  ')];
@@ -20,8 +20,8 @@ end
code = [];

elsecell = [];
for i=1:size(g1.cells,2)
    g1cond = g1.cells(i).cond_text;
for i=1:g1.length
    g1cond = g1.get_cell(i).get_matlab_string;
    % condition string of otherwise corresponds to an else
    % statement, we allow this statement to be in any order
    % in the cells of the grid, so we need to find where it
@@ -32,13 +32,13 @@ for i=1:size(g1.cells,2)
        continue
    end
    if (i == 1)
        code = [code sprintf('%sif(%s)\n',space,strtrim(char(g1.cells(i).cond_text)))];
        code = [code sprintf('%sif(%s)\n',space,strtrim(char(g1cond)))];
    else
        code = [code sprintf('%selseif(%s)\n',space,strtrim(char(g1.cells(i).cond_text)))];
        code = [code sprintf('%selseif(%s)\n',space,strtrim(char(g1cond)))];
    end
    resultcell = object.data.Grid0.search_return(g1.cells(i),g2_cell);
    resultcell = object.data.outputs_grid.get_cell(g2_cell_index, i);
    if(~isempty(resultcell))
        code = [code sprintf('%soutput = %s;\n',[space '  '],EMLGenerator.type_convert('output',object.datatype,strtrim(char(resultcell.result_text))))];
        code = [code sprintf('%soutput = %s;\n',[space '  '],EMLGenerator.type_convert('output',object.datatype,strtrim(char(resultcell.get_matlab_string))))];
        
    else
    end
+2 −8
Original line number Diff line number Diff line
@@ -59,15 +59,9 @@ end
% guaranteed to
% be filled in, regardless of the dimensionality of the table.

left_top_right_top_cell = object.data.Grid2.cells(1);
while size(left_top_right_top_cell.subgrid) ~= 0
    left_top_right_top_cell = left_top_right_top_cell.subgrid.cells(1);
end


if (object.data.multi_mode == 1)
    for i=1:size(object.data.Grid1.cells,2)
        parsed_output = EMLGenerator.parse_inputs(strtrim(char(object.data.Grid1.cells(i).cond_text)));
        parsed_output = EMLGenerator.parse_inputs(strtrim(char(object.data.top_cond.get_cell(i))));
        
        output_str = char(parsed_output{1}(1));

@@ -77,7 +71,7 @@ if (object.data.multi_mode == 1)
    
else
    test  = 'output';
    output_string = EMLGenerator.type_convert(test,object.datatype,char(object.data.Grid0.Cells(1).result_text) );
    output_string = EMLGenerator.type_convert(test,object.datatype,char(object.data.outputs_grid.get_cell(1, 1).get_matlab_string) );
    code = [code sprintf('output=%s;\n', output_string )];
    
end
+7 −0
Original line number Diff line number Diff line
@@ -181,6 +181,13 @@ object.saved = 1;
object.default_prover = object.CVC_const;


object.settings = TTSettings();
if isfield(object.data.settings, 'set')
    object.settings.setvalues(object.Data.settings);
else
    object.settings.init();
end

object.undo_man = UndoManager();


Loading