Type.py (6999:f226c098c393) Type.py (7002:48a19d52d939)
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
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
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
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
326 code('void print(ostream& out) const;')
328 code('void print(std::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
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
361ostream& operator<<(ostream& out, const ${{self.c_ident}}& obj);
363std::ostream& operator<<(std::ostream& out, const ${{self.c_ident}}& obj);
362
363// Output operator definition
364extern inline
364
365// Output operator definition
366extern inline
365ostream& operator<<(ostream& out, const ${{self.c_ident}}& obj)
367std::ostream& operator<<(std::ostream& out, const ${{self.c_ident}}& obj)
366{
367 obj.print(out);
368{
369 obj.print(out);
368 out << flush;
370 out << std::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
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
386#include "mem/protocol/${{self.c_ident}}.hh"
390#include "mem/protocol/${{self.c_ident}}.hh"
391
392using namespace std;
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
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
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};
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};
446${{self.c_ident}} string_to_${{self.c_ident}}(const string& str);
447string ${{self.c_ident}}_to_string(const ${{self.c_ident}}& obj);
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);
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('''
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('''
465ostream& operator<<(ostream& out, const ${{self.c_ident}}& obj);
474std::ostream& operator<<(std::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
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
480#include "mem/protocol/${{self.c_ident}}.hh"
481
492#include "mem/protocol/${{self.c_ident}}.hh"
493
494using namespace std;
495
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 ---
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 ---