Deleted Added
sdiff udiff text old ( 6999:f226c098c393 ) new ( 7002:48a19d52d939 )
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;

--- 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 "mem/ruby/common/Global.hh"
206#include "mem/gems_common/Allocator.hh"
207''')
208
209 for dm in self.data_members.values():
210 if not dm.type.isPrimitive:
211 code('#include "mem/protocol/$0.hh"', dm.type.c_ident)
212

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

318 #Set methods for each field
319 code('// Mutator methods for each field')
320 for dm in self.data_members.values():
321 code('''
322/** \\brief Mutator method for ${{dm.ident}} field */
323void set${{dm.ident}}(const ${{dm.type.c_ident}}& local_${{dm.ident}}) { m_${{dm.ident}} = local_${{dm.ident}}; }
324''')
325
326 code('void print(ostream& out) const;')
327 code.dedent()
328 code(' //private:')
329 code.indent()
330
331 # Data members for each field
332 for dm in self.data_members.values():
333 if "abstract" not in dm:
334 const = ""

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

353 if self.isMessage:
354 code('unsigned proc_id;')
355
356 code.dedent()
357 code('};')
358
359 code('''
360// Output operator declaration
361ostream& operator<<(ostream& out, const ${{self.c_ident}}& obj);
362
363// Output operator definition
364extern inline
365ostream& operator<<(ostream& out, const ${{self.c_ident}}& obj)
366{
367 obj.print(out);
368 out << flush;
369 return out;
370}
371
372#endif // ${{self.c_ident}}_H
373''')
374
375 code.write(path, "%s.hh" % self.c_ident)
376
377 def printTypeCC(self, path):
378 code = self.symtab.codeFormatter()
379
380 code('''
381/** \\file ${{self.c_ident}}.cc
382 *
383 * Auto generated C++ code started by $__file__:$__line__
384 */
385
386#include "mem/protocol/${{self.c_ident}}.hh"
387''')
388
389 if self.isMessage:
390 code('Allocator<${{self.c_ident}}>* ${{self.c_ident}}::s_allocator_ptr = NULL;')
391 code('''
392/** \\brief Print the state of this object */
393void ${{self.c_ident}}::print(ostream& out) const
394{

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

416 code('''
417/** \\file ${{self.c_ident}}.hh
418 *
419 * Auto generated C++ code started by $__file__:$__line__
420 */
421#ifndef ${{self.c_ident}}_H
422#define ${{self.c_ident}}_H
423
424#include "mem/ruby/common/Global.hh"
425
426/** \\enum ${{self.c_ident}}
427 * \\brief ${{self.desc}}
428 */
429enum ${{self.c_ident}} {
430 ${{self.c_ident}}_FIRST,
431''')

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

438 init = ' = %s_FIRST' % self.c_ident
439 else:
440 init = ''
441 code('${{self.c_ident}}_${{enum.ident}}$init, /**< $desc */')
442 code.dedent()
443 code('''
444 ${{self.c_ident}}_NUM
445};
446${{self.c_ident}} string_to_${{self.c_ident}}(const string& str);
447string ${{self.c_ident}}_to_string(const ${{self.c_ident}}& obj);
448${{self.c_ident}} &operator++(${{self.c_ident}} &e);
449''')
450
451 # MachineType hack used to set the base component id for each Machine
452 if self.isMachineType:
453 code('''
454int ${{self.c_ident}}_base_level(const ${{self.c_ident}}& obj);
455MachineType ${{self.c_ident}}_from_base_level(int);
456int ${{self.c_ident}}_base_number(const ${{self.c_ident}}& obj);
457int ${{self.c_ident}}_base_count(const ${{self.c_ident}}& obj);
458''')
459
460 for enum in self.enums.itervalues():
461 code('#define MACHINETYPE_${{enum.ident}} 1')
462
463 # Trailer
464 code('''
465ostream& operator<<(ostream& out, const ${{self.c_ident}}& obj);
466
467#endif // ${{self.c_ident}}_H
468''')
469
470 code.write(path, "%s.hh" % self.c_ident)
471
472 def printEnumCC(self, path):
473 code = self.symtab.codeFormatter()
474 code('''
475/** \\file ${{self.c_ident}}.hh
476 *
477 * Auto generated C++ code started by $__file__:$__line__
478 */
479
480#include "mem/protocol/${{self.c_ident}}.hh"
481
482''')
483
484 if self.isMachineType:
485 for enum in self.enums.itervalues():
486 code('#include "mem/protocol/${{enum.ident}}_Controller.hh"')
487
488 code('''
489ostream& operator<<(ostream& out, const ${{self.c_ident}}& obj)

--- 166 unchanged lines hidden ---