commands.cxx

changeset 65
ec04357f5bb9
parent 54
8cc91ef94754
child 67
0a202714eea4
equal deleted inserted replaced
64:dc5db6335601 65:ec04357f5bb9
161 t = t.tolower(); 161 t = t.tolower();
162 return !t.compare ("int") ? TYPE_INT : 162 return !t.compare ("int") ? TYPE_INT :
163 !t.compare ("float") ? TYPE_FLOAT : 163 !t.compare ("float") ? TYPE_FLOAT :
164 !t.compare ("str") ? TYPE_STRING : 164 !t.compare ("str") ? TYPE_STRING :
165 !t.compare ("void") ? TYPE_VOID : 165 !t.compare ("void") ? TYPE_VOID :
166 !t.compare ("bool") ? TYPE_INT : -1; 166 !t.compare ("bool") ? TYPE_BOOL : -1;
167 } 167 }
168 168
169 // ============================================================================ 169 // ============================================================================
170 // Inverse operation - type name by value 170 // Inverse operation - type name by value
171 str GetTypeName (int r) {
172 switch (r) {
173 case TYPE_INT: return "int"; break;
174 case TYPE_STRING: return "str"; break;
175 case TYPE_VOID: return "void"; break;
176 case TYPE_FLOAT: return "float"; break;
177 case TYPE_BOOL: return "bool"; break;
178 }
179
180 return "";
181 }
182
183 // ============================================================================
171 str GetReturnTypeName (int r) { 184 str GetReturnTypeName (int r) {
172 switch (r) { 185 switch (r) {
173 case RETURNVAL_INT: return "int"; break; 186 case RETURNVAL_INT: return "int"; break;
174 case RETURNVAL_STRING: return "str"; break; 187 case RETURNVAL_STRING: return "str"; break;
175 case RETURNVAL_VOID: return "void"; break; 188 case RETURNVAL_VOID: return "void"; break;
193 206
194 // ============================================================================ 207 // ============================================================================
195 // Returns the prototype of the command 208 // Returns the prototype of the command
196 str GetCommandPrototype (CommandDef* comm) { 209 str GetCommandPrototype (CommandDef* comm) {
197 str text; 210 str text;
198 text += GetReturnTypeName (comm->returnvalue); 211 text += GetTypeName (comm->returnvalue);
199 text += ' '; 212 text += ' ';
200 text += comm->name; 213 text += comm->name;
201 text += '('; 214 text += '(';
202 215
203 bool hasOptionalArguments = false; 216 bool hasOptionalArguments = false;
208 } 221 }
209 222
210 if (i) 223 if (i)
211 text += ", "; 224 text += ", ";
212 225
213 text += GetReturnTypeName (comm->argtypes[i]); 226 text += GetTypeName (comm->argtypes[i]);
214 text += ' '; 227 text += ' ';
215 text += comm->argnames[i]; 228 text += comm->argnames[i];
216 229
217 if (i >= comm->numargs) { 230 if (i >= comm->numargs) {
218 text += '='; 231 text += '=';

mercurial