Mercurial > hg > octave-nkf
comparison src/ov-class.cc @ 14981:50e9e02d7c0e
maint: periodic merge of default to jit
author | Max Brister <max@2bass.com> |
---|---|
date | Mon, 09 Jul 2012 09:55:35 -0500 |
parents | 460a3c6d8bf1 |
children | f7afecdd87ef |
comparison
equal
deleted
inserted
replaced
14980:bb1f3a9bb122 | 14981:50e9e02d7c0e |
---|---|
519 } | 519 } |
520 break; | 520 break; |
521 | 521 |
522 case '.': | 522 case '.': |
523 { | 523 { |
524 if (map.numel() > 0) | 524 if (map.numel () > 0) |
525 { | 525 { |
526 Cell t = dotref (idx.front ()); | 526 Cell t = dotref (idx.front ()); |
527 | 527 |
528 retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true); | 528 retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true); |
529 } | 529 } |
703 // FIXME -- should the subsasgn method be able to return | 703 // FIXME -- should the subsasgn method be able to return |
704 // more than one value? | 704 // more than one value? |
705 | 705 |
706 if (tmp.length () > 1) | 706 if (tmp.length () > 1) |
707 error ("expecting single return value from @%s/subsasgn", | 707 error ("expecting single return value from @%s/subsasgn", |
708 class_name().c_str ()); | 708 class_name ().c_str ()); |
709 | 709 |
710 else | 710 else |
711 retval = tmp(0); | 711 retval = tmp(0); |
712 | 712 |
713 return retval; | 713 return retval; |
912 } | 912 } |
913 else | 913 else |
914 { | 914 { |
915 if (t_rhs.is_empty ()) | 915 if (t_rhs.is_empty ()) |
916 { | 916 { |
917 map.delete_elements (idx.front()); | 917 map.delete_elements (idx.front ()); |
918 | 918 |
919 if (! error_state) | 919 if (! error_state) |
920 { | 920 { |
921 count++; | 921 count++; |
922 retval = octave_value (this); | 922 retval = octave_value (this); |
997 | 997 |
998 octave_value_list tmp = feval (meth.function_value (), args, 1); | 998 octave_value_list tmp = feval (meth.function_value (), args, 1); |
999 | 999 |
1000 if (!error_state && tmp.length () >= 1) | 1000 if (!error_state && tmp.length () >= 1) |
1001 { | 1001 { |
1002 if (tmp(0).is_object()) | 1002 if (tmp(0).is_object ()) |
1003 error ("subsindex function must return a valid index vector"); | 1003 error ("subsindex function must return a valid index vector"); |
1004 else | 1004 else |
1005 // Index vector returned by subsindex is zero based | 1005 // Index vector returned by subsindex is zero based |
1006 // (why this inconsistency Mathworks?), and so we must | 1006 // (why this inconsistency Mathworks?), and so we must |
1007 // add one to the value returned as the index_vector method | 1007 // add one to the value returned as the index_vector method |
1010 octave_value (1.0)).index_vector (); | 1010 octave_value (1.0)).index_vector (); |
1011 } | 1011 } |
1012 } | 1012 } |
1013 else | 1013 else |
1014 error ("no subsindex method defined for class %s", | 1014 error ("no subsindex method defined for class %s", |
1015 class_name().c_str ()); | 1015 class_name ().c_str ()); |
1016 | 1016 |
1017 return retval; | 1017 return retval; |
1018 } | 1018 } |
1019 | 1019 |
1020 size_t | 1020 size_t |
1134 else | 1134 else |
1135 error ("cname/char method did not return a character string"); | 1135 error ("cname/char method did not return a character string"); |
1136 } | 1136 } |
1137 } | 1137 } |
1138 else | 1138 else |
1139 error ("no char method defined for class %s", class_name().c_str ()); | 1139 error ("no char method defined for class %s", class_name ().c_str ()); |
1140 | 1140 |
1141 return retval; | 1141 return retval; |
1142 } | 1142 } |
1143 | 1143 |
1144 | 1144 |
1272 // First, check to see if there might be an issue with inheritance. | 1272 // First, check to see if there might be an issue with inheritance. |
1273 for (octave_map::const_iterator p = map.begin (); p != map.end (); p++) | 1273 for (octave_map::const_iterator p = map.begin (); p != map.end (); p++) |
1274 { | 1274 { |
1275 std::string key = map.key (p); | 1275 std::string key = map.key (p); |
1276 Cell val = map.contents (p); | 1276 Cell val = map.contents (p); |
1277 if ( val(0).is_object() ) | 1277 if ( val(0).is_object () ) |
1278 { | 1278 { |
1279 dbgstr = "blork"; | 1279 dbgstr = "blork"; |
1280 if( key == val(0).class_name() ) | 1280 if( key == val(0).class_name () ) |
1281 { | 1281 { |
1282 might_have_inheritance = true; | 1282 might_have_inheritance = true; |
1283 dbgstr = "cork"; | 1283 dbgstr = "cork"; |
1284 break; | 1284 break; |
1285 } | 1285 } |
1442 } | 1442 } |
1443 | 1443 |
1444 bool | 1444 bool |
1445 octave_class::save_binary (std::ostream& os, bool& save_as_floats) | 1445 octave_class::save_binary (std::ostream& os, bool& save_as_floats) |
1446 { | 1446 { |
1447 int32_t classname_len = class_name().length (); | 1447 int32_t classname_len = class_name ().length (); |
1448 | 1448 |
1449 os.write (reinterpret_cast<char *> (&classname_len), 4); | 1449 os.write (reinterpret_cast<char *> (&classname_len), 4); |
1450 os << class_name (); | 1450 os << class_name (); |
1451 | 1451 |
1452 octave_map m; | 1452 octave_map m; |
1460 return false; | 1460 return false; |
1461 } | 1461 } |
1462 else | 1462 else |
1463 m = map_value (); | 1463 m = map_value (); |
1464 | 1464 |
1465 int32_t len = m.nfields(); | 1465 int32_t len = m.nfields (); |
1466 os.write (reinterpret_cast<char *> (&len), 4); | 1466 os.write (reinterpret_cast<char *> (&len), 4); |
1467 | 1467 |
1468 octave_map::iterator i = m.begin (); | 1468 octave_map::iterator i = m.begin (); |
1469 while (i != m.end ()) | 1469 while (i != m.end ()) |
1470 { | 1470 { |
2187 | 2187 |
2188 octave_function *fcn = octave_call_stack::caller (); | 2188 octave_function *fcn = octave_call_stack::caller (); |
2189 | 2189 |
2190 if (fcn && fcn->is_class_constructor ()) | 2190 if (fcn && fcn->is_class_constructor ()) |
2191 { | 2191 { |
2192 for (int i = 0; i < args.length(); i++) | 2192 for (int i = 0; i < args.length (); i++) |
2193 { | 2193 { |
2194 std::string class_name = args(i).string_value (); | 2194 std::string class_name = args(i).string_value (); |
2195 | 2195 |
2196 if (! error_state) | 2196 if (! error_state) |
2197 { | 2197 { |
2239 | 2239 |
2240 octave_function *fcn = octave_call_stack::caller (); | 2240 octave_function *fcn = octave_call_stack::caller (); |
2241 | 2241 |
2242 if (fcn && fcn->is_class_constructor ()) | 2242 if (fcn && fcn->is_class_constructor ()) |
2243 { | 2243 { |
2244 for (int i = 0; i < args.length(); i++) | 2244 for (int i = 0; i < args.length (); i++) |
2245 { | 2245 { |
2246 std::string class_name = args(i).string_value (); | 2246 std::string class_name = args(i).string_value (); |
2247 | 2247 |
2248 if (! error_state) | 2248 if (! error_state) |
2249 { | 2249 { |