Deleted Added
sdiff udiff text old ( 7453:1a5db3dd0f62 ) new ( 7805:f249937228b5 )
full compact
1# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
2# Copyright (c) 2009 The Hewlett-Packard Development Company
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 497 unchanged lines hidden (view full) ---

506/** \\file ${{self.c_ident}}.hh
507 *
508 * Auto generated C++ code started by $__file__:$__line__
509 */
510
511#include <iostream>
512#include <string>
513
514#include "mem/protocol/${{self.c_ident}}.hh"
515
516using namespace std;
517
518''')
519
520 if self.isMachineType:
521 for enum in self.enums.itervalues():

--- 21 unchanged lines hidden (view full) ---

543 for enum in self.enums.itervalues():
544 code(' case ${{self.c_ident}}_${{enum.ident}}:')
545 code(' return "${{enum.ident}}";')
546 code.dedent()
547
548 # Trailer
549 code('''
550 default:
551 ERROR_MSG("Invalid range for type ${{self.c_ident}}");
552 return "";
553 }
554}
555
556// Code to convert from a string to the enumeration
557${{self.c_ident}}
558string_to_${{self.c_ident}}(const string& str)
559{
560''')

--- 4 unchanged lines hidden (view full) ---

565 for enum in self.enums.itervalues():
566 code('${start}if (str == "${{enum.ident}}") {')
567 code(' return ${{self.c_ident}}_${{enum.ident}};')
568 start = "} else "
569 code.dedent()
570
571 code('''
572 } else {
573 WARN_EXPR(str);
574 ERROR_MSG("Invalid string conversion for type ${{self.c_ident}}");
575 }
576}
577
578// Code to increment an enumeration type
579${{self.c_ident}}&
580operator++(${{self.c_ident}}& e)
581{
582 assert(e < ${{self.c_ident}}_NUM);

--- 25 unchanged lines hidden (view full) ---

608 code.dedent()
609
610 # total num
611 code('''
612 case ${{self.c_ident}}_NUM:
613 return ${{len(self.enums)}};
614
615 default:
616 ERROR_MSG("Invalid range for type ${{self.c_ident}}");
617 return -1;
618 }
619}
620
621/** \\brief returns the machine type for each base vector index used by NetDest
622 *
623 * \\return the MachineType
624 */
625MachineType

--- 7 unchanged lines hidden (view full) ---

633 for i,enum in enumerate(self.enums.itervalues()):
634 code(' case $i:')
635 code(' return ${{self.c_ident}}_${{enum.ident}};')
636 code.dedent()
637
638 # Trailer
639 code('''
640 default:
641 ERROR_MSG("Invalid range for type ${{self.c_ident}}");
642 return MachineType_NUM;
643 }
644}
645
646/** \\brief The return value indicates the number of components created
647 * before a particular machine\'s components
648 *
649 * \\return the base number of components for each machine
650 */

--- 10 unchanged lines hidden (view full) ---

661 for enum in reversed(self.enums.values()):
662 code(' base += ${{enum.ident}}_Controller::getNumControllers();')
663 code(' case ${{self.c_ident}}_${{enum.ident}}:')
664 code(' break;')
665 code.dedent()
666
667 code('''
668 default:
669 ERROR_MSG("Invalid range for type ${{self.c_ident}}");
670 return -1;
671 }
672
673 return base;
674}
675
676/** \\brief returns the total number of components for each machine
677 * \\return the total number of components for each machine
678 */

--- 9 unchanged lines hidden (view full) ---

688 case ${{self.c_ident}}_${{enum.ident}}:
689 return ${{enum.ident}}_Controller::getNumControllers();
690''')
691
692 # total num
693 code('''
694 case ${{self.c_ident}}_NUM:
695 default:
696 ERROR_MSG("Invalid range for type ${{self.c_ident}}");
697 return -1;
698 }
699}
700''')
701
702 # Write the file
703 code.write(path, "%s.cc" % self.c_ident)
704
705__all__ = [ "Type" ]