src/commands.cpp

changeset 135
8b9132fea327
parent 133
dbbdb870c835
child 138
a426c1039655
equal deleted inserted replaced
134:eca2fc0acaa2 135:8b9132fea327
28 28
29 #include <stdlib.h> 29 #include <stdlib.h>
30 #include <stdio.h> 30 #include <stdio.h>
31 #include <string.h> 31 #include <string.h>
32 #include "main.h" 32 #include "main.h"
33 #include "string.h" 33 #include "stringClass.h"
34 #include "commands.h" 34 #include "commands.h"
35 #include "lexer.h" 35 #include "lexer.h"
36 36
37 static List<CommandInfo*> gCommands; 37 static List<CommandInfo*> Commands;
38 38
39 // ============================================================================ 39 // ============================================================================
40 // 40 //
41 void addCommandDefinition (CommandInfo* comm) 41 void addCommandDefinition (CommandInfo* comm)
42 { 42 {
43 // Ensure that there is no conflicts 43 // Ensure that there is no conflicts
44 for (CommandInfo* it : gCommands) 44 for (CommandInfo* it : Commands)
45 {
45 if (it->number == comm->number) 46 if (it->number == comm->number)
47 {
46 error ("Attempted to redefine command #%1 (%2) as %3", 48 error ("Attempted to redefine command #%1 (%2) as %3",
47 gCommands[comm->number]->name, comm->name); 49 Commands[comm->number]->name, comm->name);
50 }
51 }
48 52
49 gCommands << comm; 53 Commands << comm;
50 } 54 }
51 55
52 // ============================================================================ 56 // ============================================================================
53 // Finds a command by name 57 // Finds a command by name
54 CommandInfo* findCommandByName (String fname) 58 CommandInfo* findCommandByName (String fname)
55 { 59 {
56 for (CommandInfo* comm : gCommands) 60 for (CommandInfo* comm : Commands)
57 { 61 {
58 if (fname.toUppercase() == comm->name.toUppercase()) 62 if (fname.toUppercase() == comm->name.toUppercase())
59 return comm; 63 return comm;
60 } 64 }
61 65
117 return text; 121 return text;
118 } 122 }
119 123
120 const List<CommandInfo*>& getCommands() 124 const List<CommandInfo*>& getCommands()
121 { 125 {
122 return gCommands; 126 return Commands;
123 } 127 }

mercurial