hg never lies :) and i'm very happy there seems to be a not-too-complicated 
solution

I have had a good look at this code snippet (more than once) and tried to 
figure out where the information got lost on its way to a C++ param class. 
Thanks for sorting out the confusion. I still hope Steve or Nate can help me in 
getting the SWIG interfaces right for getting both name and length (for the 
vector ports) into a std::vector of ports.

Andreas

________________________________________
From: [email protected] [[email protected]] On Behalf Of nathan 
binkert [[email protected]]
Sent: Tuesday, November 29, 2011 7:45 PM
To: gem5 Developer List
Subject: Re: [gem5-dev] providing port names to C++ via param struct

>        port_names = self._ports.keys()
>        port_names.sort()
>        for port_name in port_names:
>            port = self._port_refs.get(port_name, None)
>            if port != None:
>                setattr(cc_params, port_name, port)
>
> I have no idea why we do this.  It would be interesting to take this code
> out and see if anything breaks.

I don't recall writing the code, but hg says that I did! :)

Looking at the code (and the generated code), I believe that the end
result of the setattr is effectively a nop.  Basically, what's
happening is that swig generates native C++ code for accessing all of
the functions and variables, but it does not generate an actual
extension type (a python class written in C/C++ instead of python).
Swig instead generates a regular python class and a bunch of wrapper
functions that call into the accessor functions (like this):

class SimObject(object):
    def init(self): return _param_SimObject.SimObject_init(self)

The result is that there is a real python class and we're just adding
a python attribute to that python class that never makes it into C++.
If you were to add a C++ param called port_name to swig, then it
should "just work".  Grep seems to say to me that nothing will break
if it gets removed, but I can't promise that.  My best guess is that I
added that so that I could get some context when using pdb.

Make any sense?

  Nate
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev


-- IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium.  Thank you.

_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to