Skip to content

Commit

Permalink
KEIL/GNU choice for #967 (ARM code export) moved from Diagram menu to…
Browse files Browse the repository at this point in the history
… export options
  • Loading branch information
codemanyak committed Apr 15, 2021
1 parent 0627df9 commit 88f11cd
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 31 deletions.
7 changes: 4 additions & 3 deletions src/lu/fisch/structorizer/elements/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,10 @@
* @author Bob Fisch
*/
public abstract class Element {
// START AS 4 ARM
public static boolean ARM_GNU=false;
// END AS 4 ARM

// START AS 2021-03-25: Enh. #967 (ARM code variant) - KGU 2021-04-15 disabled
//public static boolean ARM_GNU = false;
// END AS 2021-03-25
/** This enumeration type distinguishes drawing contexts for selection display */
// START KGU#906 2021-01-06: Enh. #905 need another context to suppress triangles
//public enum DrawingContext {DC_STRUCTORIZER, DC_ARRANGER};
Expand Down
12 changes: 11 additions & 1 deletion src/lu/fisch/structorizer/generators/ArmGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* A. Simonetta 2021-04-02 Several revisions as requested
* Kay Gürtzig 2021-04-09 Syntax correction, some adaptations to fit into Structorizer environment
* Kay Gürtzig 2021-04-14 Issue #738: Highlighting map faults mended
* Kay Gürtzig 2021-04-15 Source for
*
******************************************************************************************************
*
Expand Down Expand Up @@ -152,7 +153,10 @@ public String toString() {
* If the variable is true then the generator will translate the code for the GNU compiler
* else the generator will translate the code for the Keil compiler
*/
private final boolean gnuEnabled = Element.ARM_GNU;
// START KGU#968 2021-04-15: Setting now comes from an export options
//private final boolean gnuEnabled = Element.ARM_GNU;
private boolean gnuEnabled = false;
// END KGU#968 2021-04-15

/**
* Variable used for naming arrays (v_0, v_1...)
Expand Down Expand Up @@ -228,6 +232,12 @@ protected String getOutputReplacer() {

@Override
public String generateCode(Root _root, String _indent, boolean _public) {
// START KGU#968 2021-04-15: New mechanism to retrieve gnuEnabled option
Object optionGnu = this.getPluginOption("gnuCode", gnuEnabled);
if (optionGnu instanceof Boolean) {
gnuEnabled = (Boolean) optionGnu;
}
// END KGU#968 2021-04-15
// START KGU#705 2021-04-14: Enh. #738 (Direct code changes compromise codeMap)
//if (topLevel && gnuEnabled) {
// code.add(difference[0][2]);
Expand Down
6 changes: 4 additions & 2 deletions src/lu/fisch/structorizer/generators/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3810,8 +3810,10 @@ public File exportCode(Root _root, File _proposedDirectory, Frame _frame, IRouti

// START KGU#705 2019-09-23: Enh. #738
/**
* This is a very reduced version of {@link #exportCode(Root, File, Frame, IRoutinePool)} for live
* code preview as there is no file selection etc.
* This is a very reduced version of {@link #exportCode(Root, File, Frame, IRoutinePool)}
* for live code preview as there is no file selection etc.<br/>
* Plugin-specific options should already have been assigned, general export options
* will be fetched from {@link Ini} here.
* @param _root - program or top-level routine diagram (call hierarchy root)
* @param _frame - the GUI Frame object responsible for this action
* @param _routinePool - {@link Arranger} or some other routine pool for subroutine analysis
Expand Down
44 changes: 27 additions & 17 deletions src/lu/fisch/structorizer/gui/Diagram.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,16 @@
* Kay Gürtzig 2021-03-02 Bugfix #951: On FilesDrop for source files the language-specific options weren't used
* Kay Gürtzig 2021-03-03 Issue #954: Modified behaviour of "Clear all Breakpoints" button
* Kay Gürtzig 2021-04-14 Bugfix #969: Precaution against relative paths in currentDirectory
* Kay Gürtzig 2021-04-16 Enh. #967: ARM code export options retrieved from Ini instead from menu item
*
******************************************************************************************************
*
* Comment: /
*
* 2021-04-16 (Kay Gürtzig, #967 = ARM code export)
* - Alessandro Simonetta had added a Dialog menu item to switch among two ARM code syntax versions
* (GNU/KEIL). As this is not a diagram property, the mechanism was replaced by a plugin-specific
* Boolean export option "gnuCode". On this occasion the option retrieval code had to be fixed.
* 2016-07-31 (Kay Gürtzig, #158)
* - It turned out that circular horizontal selection move is not sensible. It compromises usability
* rather than it helps. With active horizontal mouse scrolling the respective diagram margin is
Expand Down Expand Up @@ -7135,7 +7140,7 @@ public void export(String _generatorClassName, Vector<HashMap<String, String>> _
* Export the given diagram {@code _root} to the programming language
* associated to the generator {@code _generatorClassName}.
*
* @param _generatorClassName - class name of he generator to be used
* @param _generatorClassName - class name of the generator to be used
* @param _specificOptions - generator-specific options
*/
public void export(Root _root, String _generatorClassName, Vector<HashMap<String, String>> _specificOptions) {
Expand All @@ -7162,7 +7167,10 @@ public void export(Root _root, String _generatorClassName, Vector<HashMap<String
}
// END KGU#815 2020-03-20
// START KGU#395 2017-05-11: Enh. #357
this.setPluginSpecificOptions(gen, _generatorClassName, _specificOptions);
// START KGU#968 2021-04-16: Enh. #967 turned out that the wrong class name was passed
//this.setPluginSpecificOptions(gen, _generatorClassName, _specificOptions);
this.setPluginSpecificOptions(gen, gen.getClass().getSimpleName(), _specificOptions);
// END KGU#968 2021-04-16
// END KGU#395 2017-05-11
// START KGU#901 2020-12-29: Issue #901 applay WAIT_CURSOR for time-consuming actions
setCursor(new Cursor(Cursor.WAIT_CURSOR));
Expand Down Expand Up @@ -7354,7 +7362,7 @@ public void updateCodePreview() {
if (plugin.title.equals(generatorName)) {
Class<?> genClass = Class.forName(plugin.className);
gen = (Generator) genClass.getDeclaredConstructor().newInstance();
fetchPluginSpecificExportOptions(gen);
setPluginSpecificOptions(gen, plugin.getKey(), plugin.options);
String code = gen.deriveCode(root,
NSDControl.getFrame(),
arranger,
Expand Down Expand Up @@ -8717,20 +8725,22 @@ protected void setCodePreviewTooltip() {
}
}
// END KGU#705 2019-09-24
// START AS 4 ARM
/**
* Sets the Element.ARM_VISUAL based on the menu choice
*
* @param _arm - true to switch in arm GNU mode (false for KEIL syntax compiler)
*/
public void setOperationArmVisual(boolean _arm) {
Element.ARM_GNU = _arm;
this.resetDrawingInfo();
NSDControl.doButtons();
updateCodePreview();
redraw();
}
//END AS 4 ARM

// START AS 2021-03-25: Enh. #967 (mode for ARM code export) - KGU 2021-04-15 replaced by export option
///**
// * Sets the Element.ARM_VISUAL based on the menu choice
// *
// * @param _arm - true to switch in arm GNU mode (false for KEIL syntax compiler)
// */
//public void setOperationArmVisual(boolean _arm) {
// Element.ARM_GNU = _arm;
// this.resetDrawingInfo();
// NSDControl.doButtons();
// updateCodePreview();
// redraw();
//}
//END AS 2021-03-25

// START KGU#258 2016-09-26: Enh. #253
/**
* Opens the import options dialog and processes configuration changes.
Expand Down
4 changes: 2 additions & 2 deletions src/lu/fisch/structorizer/gui/IconLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ public class IconLoader {
"125_plug.png", // introduced with 3.30-14 for #910
"126_info.png", // is to replace the 017_Eye.png in the main toolbox
"127_merge.png", // introduced with 3.30-16 for #915
"128_split.png", // introduced with 3.30-16 for #915
"129_arm.png"
"128_split.png" // introduced with 3.30-16 for #915
//"129_arm.png" // intended for #967 (ARM code export), but not used
};

private static final int[] ICON_SIZES = {
Expand Down
21 changes: 16 additions & 5 deletions src/lu/fisch/structorizer/gui/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,18 @@
* Kay Gürtzig 2021-02-11 Enh. #893: Revalidation of the preference menu enforced after locale setting
* Kay Gürtzig 2021-02-24 Issue #944: Version info announcing Java upgrade to 11 added
* Kay Gürtzig 2021-03-03 Issue #954: Modified behaviour of "Clear all Breakpoints" button
* Kay Gürtzig 2021-04-15 Enh. #967: menu item menuDiagramARM as introduced by A. Simonetta disabled
*
******************************************************************************************************
*
* Comment: /
*
*
* 2021-04-15 Enh. #967 - ARMGenerator (Kay Gürtzig)
* - Alessandro Simonetta (AS) introduced a new checkbox menu item in the Diagram menu to switch
* among Gnu and Keil assembler syntax for ARM code export. While there is no Executor support
* for ARM code content of diagram elements, however, this makes little sense. So a plugin-specific
* export option was inserted to control the ARMGenerator mode instead.
*
******************************************************************************************************///


Expand Down Expand Up @@ -336,7 +343,9 @@ public enum PluginType { GENERATOR, PARSER, IMPORTER, CONTROLLER };

protected final JMenu menuDiagramType = new JMenu("Type");
protected final JCheckBoxMenuItem menuDiagramTypeProgram = new JCheckBoxMenuItem("Main", IconLoader.getIcon(22));
protected final JCheckBoxMenuItem menuDiagramARM = new JCheckBoxMenuItem("GNU compiler for ARM", IconLoader.getIcon(129));
// START AS 2021-03-25: Enh. #967 - KGU 2021-04-15 disabled in favour of a plugin-specific export option
//protected final JCheckBoxMenuItem menuDiagramARM = new JCheckBoxMenuItem("GNU compiler for ARM", IconLoader.getIcon(129));
// END AS 2021-03-25
protected final JCheckBoxMenuItem menuDiagramTypeFunction = new JCheckBoxMenuItem("Sub", IconLoader.getIcon(21));
//START KGU#376 2017-05-16: Enh. #389
protected final JCheckBoxMenuItem menuDiagramTypeInclude = new JCheckBoxMenuItem("Includable", IconLoader.getIcon(71));
Expand Down Expand Up @@ -1366,9 +1375,11 @@ public void actionPerformed(ActionEvent event)
menuDiagram.add(menuDiagramExpand);
menuDiagramExpand.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, 0));
menuDiagramExpand.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { diagram.expandNSD(); doButtons(); } } );
//ARM
menuDiagram.add(menuDiagramARM);
menuDiagramARM.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { diagram.setOperationArmVisual(menuDiagramARM.isSelected()); doButtons(); } } );
// START AS 2021-03-25: Enh. #967 - KGU 2021-04-15 disabled in favour of a plugin-specific export option
// ARM export mode
//menuDiagram.add(menuDiagramARM);
//menuDiagramARM.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { diagram.setOperationArmVisual(menuDiagramARM.isSelected()); doButtons(); } } );
// END AS 2021-03-25
// START KGU#310 2016-12-14: Moved to menu Debug
// // START KGU#277 2016-10-13: Enh. #270
// menuDiagram.add(menuDebugDisable);
Expand Down
4 changes: 3 additions & 1 deletion src/lu/fisch/structorizer/gui/generators.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
<plugin title="PHP" class="lu.fisch.structorizer.generators.PHPGenerator" icon="" reserved_words="abstract,and,array,as,break,case,catch,class,clone,const,continue,declare,default,do,echo,else,elseif,enddeclare,endfor,endforeach,endif,endswith,endwhile,exit,extends,final,finally,for,foreach,function,global,goto,if,implements,include,instanceof,insteadof,interface,namespace,new,or,print,private,protected,public,require,return,static,switch,throw,trait,try,use,var,while,xor,yield" />
<plugin title="Python" class="lu.fisch.structorizer.generators.PythonGenerator" icon="" case_matters="0" reserved_words="and,assert,break,class,continue,def,del,else,elif,except,exec,finally,for,from,global,if,import,in,is,lambda,not,or,pass,print,raise,return,try,while,Data,Float,Int,Numeric,Oxphys,array,close,float,int,input,open,range,type,write,zeros" />
<plugin title="Basic" class="lu.fisch.structorizer.generators.BasGenerator" icon="" case_matters="0" reserved_words="FUNCTION,SUB,REM,LET,AS,DIM,IF,THEN,ELSE,END,SELECT,CASE,FOR,TO,STEP,NEXT,DO,WHILE,UNTIL,LOOP,CALL,RETURN,GOTO,GOSUB,STOP,INPUT,PRINT,READ,DATA,RESTORE,AND,OR,NOT" />
<plugin title="ARM" class="lu.fisch.structorizer.generators.ArmGenerator" icon="" case_matters="0" reserved_words="" />
<plugin title="ARM" class="lu.fisch.structorizer.generators.ArmGenerator" icon="" case_matters="0" reserved_words="">
<option type="Boolean" name="gnuCode" title="Code for GNU compiler (instead of KEIL)" />
</plugin>
<!-- plugin title="COBOL" class="lu.fisch.structorizer.generators.COBOLGenerator" icon="" case_matters="0" reserved_words="ACCEPT,ACCESS,ADD,ADDRESS,ADVANCING,AFTER,ALIGNED,ALL,ALLOCATE,ALPHABET,ALPHABETIC,ALPHANUMERIC,ALSO,ALTER,ALTERNATE,AND,ANY,ANYCASE,ARE,AREA,AREAS,ARITHMETIC,AS,ASCENDING,ASCII,ASSIGN,AT,ATTRIBUTE,AUTO,AUTOMATIC,BASED,BEFORE,BELL,BINARY,BIT,BLANK,BLINK,BLOCK,BOOLEAN,BOTTOM,BY,CALL,CANCEL,CAPACITY,CASSETTE,CD,CENTER,CF,CH,CHAIN,CHAINING,CHARACTER,CHARACTERS,CLASS,CLASSIFICATION,CLOSE,COBOL,CODE,COL,COLLATING,COLOR,COLS,COLUMN,COLUMNS,COMMA,COMMIT,COMMON,COMMUNICATION,COMP,COMPUTATIONAL,COMPUTE,CONDITION,CONFIGURATION,CONSTANT,CONTAINS,CONTENT,CONTINUE,CONTROL,CONTROLS,CONVERSION,CONVERTING,COPY,CORR,CORRESPONDING,COUNT,CRT,CURRENCY,CURSOR,CYCLE,DATA,DATE,DAY,DE,DEBUGGING,DECLARATIVES,DEFAULT,DELETE,DELIMITED,DELIMITER,DEPENDING,DESCENDING,DESTINATION,DETAIL,DISABLE,DISC,DISK,DISPLAY,DIVIDE,DIVISION,DOWN,DUPLICATES,DYNAMIC,EBCDIC,EC,ECHO,EGI,ELSE,EMI,ENABLE,END,ENVIRONMENT,EO,EOL,EOP,EOS,EQUAL,ERASE,ERROR,ESCAPE,ESI,EVALUATE,EXCEPTION,EXCLUSIVE,EXIT,EXPANDS,EXTEND,EXTERN,EXTERNAL,FACTORY,FALSE,FD,FILE,FILLER,FINAL,FIRST,FIXED,FOOTING,FOR,FOREVER,FORMAT,FREE,FROM,FULL,FUNCTION,GENERATE,GET,GIVING,GLOBAL,GO,GOBACK,GREATER,GRID,GROUP,HEADING,HIGHLIGHT,ID,IDENTIFICATION,IF,IGNORE,IGNORING,IMPLEMENTS,IN,INDEX,INDEXED,INDICATE,INHERITS,INITIAL,INITIALIZE,INITIALIZED,INITIATE,INPUT,INSPECT,INTERFACE,INTERMEDIATE,INTO,INTRINSIC,INVALID,INVOKE,IS,JUST,JUSTIFIED,KEPT,KEY,KEYBOARD,LABEL,LAST,LC_ALL,LC_COLLATE,LC_CTYPE,LC_MESSAGES,LC_MONETARY,LC_NUMERIC,LC_TIME,LEADING,LEFT,LEFTLINE,LENGTH,LESS,LIMIT,LIMITS,LINAGE,LINE,LINES,LINKAGE,LOCALE,LOCK,LOWER,LOWLIGHT,MANUAL,MEMORY,MERGE,MESSAGE,METHOD,MINUS,MODE,MOVE,MULTIPLE,MULTIPLY,NAME,NATIONAL,NATIVE,NEGATIVE,NESTED,NEXT,NO,NONE,NORMAL,NOT,NOTHING,NULL,NULLS,NUMBER,NUMBERS,NUMERIC,OBJECT,OCCURS,OF,OFF,OMITTED,ON,ONLY,OPEN,OPTIONAL,OPTIONS,OR,ORDER,ORGANIZATION,OTHER,OUTPUT,OVERFLOW,OVERLINE,OVERRIDE,PADDING,PAGE,PARAGRAPH,PERFORM,PF,PH,PIC,PICTURE,PLUS,POINTER,POSITION,POSITIVE,PREFIXED,PRESENT,PREVIOUS,PRINT,PRINTER,PRINTING,PROCEDURE,PROCEDURES,PROCEED,PROGRAM,PROHIBITED,PROMPT,PROPERTY,PROTECTED,PROTOTYPE,PURGE,QUEUE,QUOTE,QUOTES,RAISE,RAISING,RANDOM,RD,READ,RECEIVE,RECORD,RECORDING,RECORDS,RECURSIVE,REDEFINES,REEL,REFERENCE,REFERENCES,RELATION,RELATIVE,RELEASE,REMAINDER,REMOVAL,RENAMES,REPLACE,REPLACING,REPORT,REPORTING,REPORTS,REPOSITORY,REQUIRED,RESERVE,RESET,RESUME,RETRY,RETURN,RETURNING,REVERSE,REVERSED,REWIND,REWRITE,RF,RH,RIGHT,ROLLBACK,ROUNDED,ROUNDING,RUN,S,SAME,SCREEN,SCROLL,SD,SEARCH,SECONDS,SECTION,SECURE,SEGMENT,SELECT,SELF,SEND,SENTENCE,SEPARATE,SEQUENCE,SEQUENTIAL,SET,SHARING,SHORT,SIGN,SIGNED,SIZE,SORT,SOURCE,SOURCES,SPACE,SPACES,STANDARD,START,STATEMENT,STATIC,STATUS,STDCALL,STEP,STOP,STRING,STRONG,SUBTRACT,SUM,SUPER,SUPPRESS,SYMBOL,SYMBOLIC,SYNC,SYNCHRONIZED,TAB,TABLE,TALLYING,TAPE,TERMINAL,TERMINATE,TEST,TEXT,THAN,THEN,THROUGH,THRU,TIME,TIMES,TO,TOP,TRAILING,TRANSFORM,TRUE,TRUNCATION,TYPE,TYPEDEF,UUNBOUNDED,UNDERLINE,UNIT,UNIVERSAL,UNLOCK,UNSIGNED,UNSTRING,UNTIL,UP,UPDATE,UPON,UPPER,USAGE,USE,USER,USING,VALID,VALIDATE,VALUE,VALUES,VARIABLE,VARYING,WAIT,WHEN,WITH,WORDS,WRITE,YYYYDDD,YYYYMMDD,ZERO,ZEROES,ZEROS">
<option type="Boolean" name="fixedFormat" title="Fixed-form format" help="Use fixed-form reference format, otherwise free-form is used"/>
<option type="Boolean" name="underscores2hyphens" title="Underscores to hyphens in names" help="Decide if underscores in identifiers are to be replaced by hyphens"/>
Expand Down

0 comments on commit 88f11cd

Please sign in to comment.