%% generate_preamble % generates the preamble for the eml code, the preamble is % everything before the first if statement, this is seperated % out to make the code simpler. % inputs: % object:EMLGenerator - current object % outputs: % code:string - string of eml code function code = generate_preamble(object) code = []; %generate input list parsed_input = EMLGenerator.parse_inputs(object.data.function_inputs); input = []; for i= 1:size(parsed_input,2) input = [input char(parsed_input{i}(1))]; if i ~= size(parsed_input,2) input = [input ','] end end code = sprintf('function output = %s(%s)\n%s\n',object.data.function_name,input,'%%#eml'); % simulink forces you to have an output for all execution paths % since it can't compute completness and disjointness we need % to have a default value, if the user builds the table % properly the default value will never be used. since % different types might have a different default value, the % temporary solution is just to use one of the outputs from our % table, we will use the first cell because it is % guaranteed to % be filled in, regardless of the dimensionality of the table. code = [code sprintf('output=%s;\n',EMLGenerator.type_convert(object.datatype,char(object.data.Grid0.Cells(1).result_text)))]; end