[Ns-developers] Status of Python bindings
Gustavo Carneiro
gjcarneiro at gmail.com
Sun May 11 11:39:04 PDT 2008
2008/5/11 Mathieu Lacage <mathieu.lacage at sophia.inria.fr>:
> On Sun, 2008-05-11 at 19:08 +0100, Gustavo Carneiro wrote:
>
> > I hope it helps. Next I will will prototype the other API changes you
> > suggested, then work on applying it to the NS-3 case, and finally work
> > on splitting the generated script into several files, one per module.
> > This might take a few weeks, so be patient... :P
>
> I wonder if you have already tried to figure out the structure of each
> of these split files. i.e., if I wanted to write them by hand, how would
> you suggest that they be structured ?
I have not thought much; first thing that comes to mind is:
------ns3modulegen_node.py----------
def register_types(root_module):
...
def register_functions(root_module):
...
------ns3modulegen_wifi.py----------
def register_types(root_module):
...
def register_functions(root_module):
...
------ns3modulegen.py (main file)----------
import ns3modulegen_node
import ns3modulegen_wifi
...
def register_types(module):
ns3modulegen_node.register_types(module)
ns3modulegen_wifi.register_types(module)
...
def register_functions(module):
ns3modulegen_node.register_functions(module)
ns3modulegen_wifi.register_functions(module)
...
def main():
out = FileCodeSink(sys.stdout)
root_module = module_init()
register_types(root_module)
register_methods(root_module)
register_functions(root_module)
write_preamble(out)
root_module.generate(out)
This structure does not allow local customization files. I would have to
think better about that... Perhaps something involving "try: import
ns3modulegen_wifi_local except ImportError: pass", i.e. if a xxx_local.py
file is found, use it, else ignore it. Details to be figured out at
implementation time (thinking in abstract is harder).
--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
More information about the Ns-developers
mailing list