SimObject.py (11231:75c0e4915c05) | SimObject.py (11787:af41594e9b3c) |
---|---|
1# Copyright (c) 2012 ARM Limited 2# All rights reserved. 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license --- 484 unchanged lines hidden (view full) --- 493 494 # Export methods are automatically inherited via C++, so we 495 # don't want the method declarations to get inherited on the 496 # python side (and thus end up getting repeated in the wrapped 497 # versions of derived classes). The code below basicallly 498 # suppresses inheritance by substituting in the base (null) 499 # versions of these methods unless a different version is 500 # explicitly supplied. | 1# Copyright (c) 2012 ARM Limited 2# All rights reserved. 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license --- 484 unchanged lines hidden (view full) --- 493 494 # Export methods are automatically inherited via C++, so we 495 # don't want the method declarations to get inherited on the 496 # python side (and thus end up getting repeated in the wrapped 497 # versions of derived classes). The code below basicallly 498 # suppresses inheritance by substituting in the base (null) 499 # versions of these methods unless a different version is 500 # explicitly supplied. |
501 for method_name in ('export_methods', 'export_method_cxx_predecls', 502 'export_method_swig_predecls'): | 501 for method_name in ('export_methods', 'export_method_swig_predecls'): |
503 if method_name not in cls.__dict__: 504 base_method = getattr(MetaSimObject, method_name) 505 m = MethodType(base_method, cls, MetaSimObject) 506 setattr(cls, method_name, m) 507 508 # Now process the _value_dict items. They could be defining 509 # new (or overriding existing) parameters or ports, setting 510 # class keywords (e.g., 'abstract'), or setting parameter --- 149 unchanged lines hidden (view full) --- 660 code('%import "python/m5/internal/param_$cls.i"') 661 662 # Hook for exporting additional C++ methods to Python via SWIG. 663 # Default is none, override using @classmethod in class definition. 664 def export_methods(cls, code): 665 pass 666 667 # Generate the code needed as a prerequisite for the C++ methods | 502 if method_name not in cls.__dict__: 503 base_method = getattr(MetaSimObject, method_name) 504 m = MethodType(base_method, cls, MetaSimObject) 505 setattr(cls, method_name, m) 506 507 # Now process the _value_dict items. They could be defining 508 # new (or overriding existing) parameters or ports, setting 509 # class keywords (e.g., 'abstract'), or setting parameter --- 149 unchanged lines hidden (view full) --- 659 code('%import "python/m5/internal/param_$cls.i"') 660 661 # Hook for exporting additional C++ methods to Python via SWIG. 662 # Default is none, override using @classmethod in class definition. 663 def export_methods(cls, code): 664 pass 665 666 # Generate the code needed as a prerequisite for the C++ methods |
668 # exported via export_methods() to be compiled in the _wrap.cc 669 # file. Typically generates one or more #include statements. If 670 # any methods are exported, typically at least the C++ header 671 # declaring the relevant SimObject class must be included. 672 def export_method_cxx_predecls(cls, code): 673 pass 674 675 # Generate the code needed as a prerequisite for the C++ methods | |
676 # exported via export_methods() to be processed by SWIG. 677 # Typically generates one or more %include or %import statements. 678 # If any methods are exported, typically at least the C++ header 679 # declaring the relevant SimObject class must be included. 680 def export_method_swig_predecls(cls, code): 681 pass 682 683 # Generate the declaration for this object for wrapping with SWIG. --- 14 unchanged lines hidden (view full) --- 698 code('%module(package="m5.internal") param_$cls') 699 code() 700 code('%{') 701 code('#include "sim/sim_object.hh"') 702 code('#include "params/$cls.hh"') 703 for param in params: 704 param.cxx_predecls(code) 705 code('#include "${{cls.cxx_header}}"') | 667 # exported via export_methods() to be processed by SWIG. 668 # Typically generates one or more %include or %import statements. 669 # If any methods are exported, typically at least the C++ header 670 # declaring the relevant SimObject class must be included. 671 def export_method_swig_predecls(cls, code): 672 pass 673 674 # Generate the declaration for this object for wrapping with SWIG. --- 14 unchanged lines hidden (view full) --- 689 code('%module(package="m5.internal") param_$cls') 690 code() 691 code('%{') 692 code('#include "sim/sim_object.hh"') 693 code('#include "params/$cls.hh"') 694 for param in params: 695 param.cxx_predecls(code) 696 code('#include "${{cls.cxx_header}}"') |
706 cls.export_method_cxx_predecls(code) | |
707 code('''\ 708/** 709 * This is a workaround for bug in swig. Prior to gcc 4.6.1 the STL 710 * headers like vector, string, etc. used to automatically pull in 711 * the cstddef header but starting with gcc 4.6.1 they no longer do. 712 * This leads to swig generated a file that does not compile so we 713 * explicitly include cstddef. Additionally, including version 2.0.4, 714 * swig uses ptrdiff_t without the std:: namespace prefix which is --- 816 unchanged lines hidden --- | 697 code('''\ 698/** 699 * This is a workaround for bug in swig. Prior to gcc 4.6.1 the STL 700 * headers like vector, string, etc. used to automatically pull in 701 * the cstddef header but starting with gcc 4.6.1 they no longer do. 702 * This leads to swig generated a file that does not compile so we 703 * explicitly include cstddef. Additionally, including version 2.0.4, 704 * swig uses ptrdiff_t without the std:: namespace prefix which is --- 816 unchanged lines hidden --- |