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; --- 188 unchanged lines hidden (view full) --- 197 * 198 * 199 * Auto generated C++ code started by $__file__:$__line__ 200 */ 201 202#ifndef ${{self.c_ident}}_H 203#define ${{self.c_ident}}_H 204 |
205#include <iostream> 206 |
207#include "mem/ruby/common/Global.hh" 208#include "mem/gems_common/Allocator.hh" 209''') 210 211 for dm in self.data_members.values(): 212 if not dm.type.isPrimitive: 213 code('#include "mem/protocol/$0.hh"', dm.type.c_ident) 214 --- 105 unchanged lines hidden (view full) --- 320 #Set methods for each field 321 code('// Mutator methods for each field') 322 for dm in self.data_members.values(): 323 code(''' 324/** \\brief Mutator method for ${{dm.ident}} field */ 325void set${{dm.ident}}(const ${{dm.type.c_ident}}& local_${{dm.ident}}) { m_${{dm.ident}} = local_${{dm.ident}}; } 326''') 327 |
328 code('void print(std::ostream& out) const;') |
329 code.dedent() 330 code(' //private:') 331 code.indent() 332 333 # Data members for each field 334 for dm in self.data_members.values(): 335 if "abstract" not in dm: 336 const = "" --- 18 unchanged lines hidden (view full) --- 355 if self.isMessage: 356 code('unsigned proc_id;') 357 358 code.dedent() 359 code('};') 360 361 code(''' 362// Output operator declaration |
363std::ostream& operator<<(std::ostream& out, const ${{self.c_ident}}& obj); |
364 365// Output operator definition 366extern inline |
367std::ostream& operator<<(std::ostream& out, const ${{self.c_ident}}& obj) |
368{ 369 obj.print(out); |
370 out << std::flush; |
371 return out; 372} 373 374#endif // ${{self.c_ident}}_H 375''') 376 377 code.write(path, "%s.hh" % self.c_ident) 378 379 def printTypeCC(self, path): 380 code = self.symtab.codeFormatter() 381 382 code(''' 383/** \\file ${{self.c_ident}}.cc 384 * 385 * Auto generated C++ code started by $__file__:$__line__ 386 */ 387 |
388#include <iostream> 389 |
390#include "mem/protocol/${{self.c_ident}}.hh" |
391 392using namespace std; |
393''') 394 395 if self.isMessage: 396 code('Allocator<${{self.c_ident}}>* ${{self.c_ident}}::s_allocator_ptr = NULL;') 397 code(''' 398/** \\brief Print the state of this object */ 399void ${{self.c_ident}}::print(ostream& out) const 400{ --- 21 unchanged lines hidden (view full) --- 422 code(''' 423/** \\file ${{self.c_ident}}.hh 424 * 425 * Auto generated C++ code started by $__file__:$__line__ 426 */ 427#ifndef ${{self.c_ident}}_H 428#define ${{self.c_ident}}_H 429 |
430#include <iostream> 431#include <string> 432 |
433#include "mem/ruby/common/Global.hh" 434 435/** \\enum ${{self.c_ident}} 436 * \\brief ${{self.desc}} 437 */ 438enum ${{self.c_ident}} { 439 ${{self.c_ident}}_FIRST, 440''') --- 6 unchanged lines hidden (view full) --- 447 init = ' = %s_FIRST' % self.c_ident 448 else: 449 init = '' 450 code('${{self.c_ident}}_${{enum.ident}}$init, /**< $desc */') 451 code.dedent() 452 code(''' 453 ${{self.c_ident}}_NUM 454}; |
455${{self.c_ident}} string_to_${{self.c_ident}}(const std::string& str); 456std::string ${{self.c_ident}}_to_string(const ${{self.c_ident}}& obj); |
457${{self.c_ident}} &operator++(${{self.c_ident}} &e); 458''') 459 460 # MachineType hack used to set the base component id for each Machine 461 if self.isMachineType: 462 code(''' 463int ${{self.c_ident}}_base_level(const ${{self.c_ident}}& obj); 464MachineType ${{self.c_ident}}_from_base_level(int); 465int ${{self.c_ident}}_base_number(const ${{self.c_ident}}& obj); 466int ${{self.c_ident}}_base_count(const ${{self.c_ident}}& obj); 467''') 468 469 for enum in self.enums.itervalues(): 470 code('#define MACHINETYPE_${{enum.ident}} 1') 471 472 # Trailer 473 code(''' |
474std::ostream& operator<<(std::ostream& out, const ${{self.c_ident}}& obj); |
475 476#endif // ${{self.c_ident}}_H 477''') 478 479 code.write(path, "%s.hh" % self.c_ident) 480 481 def printEnumCC(self, path): 482 code = self.symtab.codeFormatter() 483 code(''' 484/** \\file ${{self.c_ident}}.hh 485 * 486 * Auto generated C++ code started by $__file__:$__line__ 487 */ 488 |
489#include <iostream> 490#include <string> 491 |
492#include "mem/protocol/${{self.c_ident}}.hh" 493 |
494using namespace std; 495 |
496''') 497 498 if self.isMachineType: 499 for enum in self.enums.itervalues(): 500 code('#include "mem/protocol/${{enum.ident}}_Controller.hh"') 501 502 code(''' 503ostream& operator<<(ostream& out, const ${{self.c_ident}}& obj) --- 166 unchanged lines hidden --- |