Skip to content
Snippets Groups Projects
Commit 59ea2617 authored by Matthew Dawson's avatar Matthew Dawson
Browse files

Add support for registering a Simulink Enumeration with jTET.

To support enumerations, jTET needs to know about the contents of the
enumeration.  TET now provides a function to do show, taking in the name of
an enumeration, and registering the various details with jTET automatically.
parent 168dbdd4
No related branches found
No related tags found
1 merge request!3Add Enumeration support to the TET
......@@ -12,6 +12,35 @@ classdef (Sealed) TET < handle
function variableParser = getVariableParser(obj)
variableParser = obj.variableParser;
end
%% Register an enumeration type with the TET.
%
% This function registers a Simulink compatibile enumeration type
% with the TET. This allows the enumerated value to be used in
% tables.
% Note: the enumeration must derive from Simulink.IntEnumType
% to be used in the Simulink model.
% Note: each enumerated value must have a distinct value,
% otherwise the type checker may allow invalid tables.
%
% obj - This object
% enum - A string representing the enumeration type name.
function type = registerEnumeration(obj, enum)
enumValues = enumeration(enum);
[~, enumConstants] = enumeration(enum);
if size(enumValues, 1) ~= size(enumConstants, 1)
throw(MException('TET:registerEnumeration', ...
'Enumeration constants share the same concrete value'));
end
type = ca.mcscert.jtet.expression.EnumerationVariableType(enum);
typeEnumConstants = type.enumerationValues;
for i=1:size(enumConstants, 1)
java.lang.String(enumConstants{i})
typeEnumConstants.add(java.lang.String(enumConstants{i}));
end
obj.variableParser.addCustomType(enum, type);
end
end
methods (Access = private)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment