comparison libinterp/corefcn/cellfun.cc @ 16003:3b3321f9db9f

arrayfun: adding IDs to error messages in accordance with error_ids.
author Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
date Tue, 05 Feb 2013 10:55:45 +0100
parents 2fc554ffbc28
children 1045790f9be4
comparison
equal deleted inserted replaced
15997:d53fa7e43aa9 16003:3b3321f9db9f
1131 int nargin = args.length (); 1131 int nargin = args.length ();
1132 int nargout1 = (nargout < 1 ? 1 : nargout); 1132 int nargout1 = (nargout < 1 ? 1 : nargout);
1133 1133
1134 if (nargin < 2) 1134 if (nargin < 2)
1135 { 1135 {
1136 error ("arrayfun: function requires at least 2 arguments"); 1136 error_with_id ("Octave:invalid-fun-call",
1137 "arrayfun: function requires at least 2 arguments");
1137 print_usage (); 1138 print_usage ();
1138 return retval; 1139 return retval;
1139 } 1140 }
1140 1141
1141 octave_value func = args(0); 1142 octave_value func = args(0);
1162 else 1163 else
1163 { 1164 {
1164 func = symbol_table::find_function (name); 1165 func = symbol_table::find_function (name);
1165 1166
1166 if (func.is_undefined ()) 1167 if (func.is_undefined ())
1167 error ("arrayfun: invalid function NAME: %s", name.c_str ()); 1168 error_with_id ("Octave:invalid-input-arg",
1169 "arrayfun: invalid function NAME: %s", name.c_str ());
1168 1170
1169 symbol_table_lookup = true; 1171 symbol_table_lookup = true;
1170 } 1172 }
1171 1173
1172 if (error_state) 1174 if (error_state)
1240 1242
1241 for (int i = j+1; i < nargin; i++) 1243 for (int i = j+1; i < nargin; i++)
1242 { 1244 {
1243 if (mask[i] && inputs[i].dims () != fdims) 1245 if (mask[i] && inputs[i].dims () != fdims)
1244 { 1246 {
1245 error ("arrayfun: dimensions mismatch"); 1247 error_with_id ("Octave:invalid-input-arg",
1248 "arrayfun: dimensions mismatch");
1246 return retval; 1249 return retval;
1247 } 1250 }
1248 } 1251 }
1249 break; 1252 break;
1250 } 1253 }
1287 if (error_state) 1290 if (error_state)
1288 return retval; 1291 return retval;
1289 1292
1290 if (nargout > 0 && tmp.length () < nargout) 1293 if (nargout > 0 && tmp.length () < nargout)
1291 { 1294 {
1292 error ("arrayfun: function returned fewer than nargout values"); 1295 error_with_id ("Octave:invalid-fun-call",
1296 "arrayfun: function returned fewer than nargout values");
1293 return retval; 1297 return retval;
1294 } 1298 }
1295 1299
1296 if (nargout > 0 1300 if (nargout > 0
1297 || (nargout == 0 1301 || (nargout == 0
1312 1316
1313 if (val.numel () == 1) 1317 if (val.numel () == 1)
1314 retv[j] = val.resize (fdims); 1318 retv[j] = val.resize (fdims);
1315 else 1319 else
1316 { 1320 {
1317 error ("arrayfun: all values must be scalars when UniformOutput = true"); 1321 error_with_id ("Octave:invalid-fun-call",
1322 "arrayfun: all values must be scalars when UniformOutput = true");
1318 break; 1323 break;
1319 } 1324 }
1320 } 1325 }
1321 } 1326 }
1322 } 1327 }
1339 if (error_state) 1344 if (error_state)
1340 break; 1345 break;
1341 } 1346 }
1342 else 1347 else
1343 { 1348 {
1344 error ("arrayfun: all values must be scalars when UniformOutput = true"); 1349 error_with_id ("Octave:invalid-fun-call",
1350 "arrayfun: all values must be scalars when UniformOutput = true");
1345 break; 1351 break;
1346 } 1352 }
1347 } 1353 }
1348 } 1354 }
1349 } 1355 }
1397 if (error_state) 1403 if (error_state)
1398 return retval; 1404 return retval;
1399 1405
1400 if (nargout > 0 && tmp.length () < nargout) 1406 if (nargout > 0 && tmp.length () < nargout)
1401 { 1407 {
1402 error ("arrayfun: function returned fewer than nargout values"); 1408 error_with_id ("Octave:invalid-fun-call",
1409 "arrayfun: function returned fewer than nargout values");
1403 return retval; 1410 return retval;
1404 } 1411 }
1405 1412
1406 if (nargout > 0 1413 if (nargout > 0
1407 || (nargout == 0 1414 || (nargout == 0
1428 retval(j) = results[j]; 1435 retval(j) = results[j];
1429 } 1436 }
1430 } 1437 }
1431 } 1438 }
1432 else 1439 else
1433 error ("arrayfun: argument NAME must be a string or function handle"); 1440 error_with_id ("Octave:invalid-fun-call",
1441 "arrayfun: argument NAME must be a string or function handle");
1434 1442
1435 return retval; 1443 return retval;
1436 } 1444 }
1437 1445
1438 /* 1446 /*