Type.py (6882:898047a3672c) Type.py (6999:f226c098c393)
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;

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

20# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
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;

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

20# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28from m5.util import code_formatter, orderdict
28from m5.util import orderdict
29
30from slicc.util import PairContainer
31from slicc.symbols.Symbol import Symbol
32
33class DataMember(PairContainer):
34 def __init__(self, ident, type, pairs, init_code):
35 super(DataMember, self).__init__(pairs)
36 self.ident = ident

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

186 self.printEnumHH(path)
187 self.printEnumCC(path)
188 else:
189 # User defined structs and messages
190 self.printTypeHH(path)
191 self.printTypeCC(path)
192
193 def printTypeHH(self, path):
29
30from slicc.util import PairContainer
31from slicc.symbols.Symbol import Symbol
32
33class DataMember(PairContainer):
34 def __init__(self, ident, type, pairs, init_code):
35 super(DataMember, self).__init__(pairs)
36 self.ident = ident

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

186 self.printEnumHH(path)
187 self.printEnumCC(path)
188 else:
189 # User defined structs and messages
190 self.printTypeHH(path)
191 self.printTypeCC(path)
192
193 def printTypeHH(self, path):
194 code = code_formatter()
194 code = self.symtab.codeFormatter()
195 code('''
196/** \\file ${{self.c_ident}}.hh
197 *
198 *
199 * Auto generated C++ code started by $__file__:$__line__
200 */
201
202#ifndef ${{self.c_ident}}_H

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

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):
195 code('''
196/** \\file ${{self.c_ident}}.hh
197 *
198 *
199 * Auto generated C++ code started by $__file__:$__line__
200 */
201
202#ifndef ${{self.c_ident}}_H

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

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 = code_formatter()
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"

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

407 # Trailer
408 code('''
409 out << "]";
410}''')
411
412 code.write(path, "%s.cc" % self.c_ident)
413
414 def printEnumHH(self, path):
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"

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

407 # Trailer
408 code('''
409 out << "]";
410}''')
411
412 code.write(path, "%s.cc" % self.c_ident)
413
414 def printEnumHH(self, path):
415 code = code_formatter()
415 code = self.symtab.codeFormatter()
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

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

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):
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

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

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 = code_formatter()
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

--- 174 unchanged lines hidden ---
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

--- 174 unchanged lines hidden ---