コード例 #1
0
def main():
    out = MyMultiSectionFactory(sys.argv[1], sys.argv[3:])
    root_module = module_init()
    root_module.add_include('"everything.h"')

    register_types(root_module)

    ns3modulegen_core_customizations.Simulator_customizations(root_module)
    ns3modulegen_core_customizations.CommandLine_customizations(root_module)
    ns3modulegen_core_customizations.TypeId_customizations(root_module)
    ns3modulegen_core_customizations.add_std_ofstream(root_module)


    for local_module in LOCAL_MODULES:
        mod = __import__(local_module)
        mod.register_types(root_module)

    ns3modulegen_core_customizations.generate_callback_classes(root_module.after_forward_declarations,
                                                               callbacks_list.callback_classes)


    register_methods(root_module)

    for local_module in LOCAL_MODULES:
        mod = __import__(local_module)
        mod.register_methods(root_module)

    ns3modulegen_core_customizations.Object_customizations(root_module)
    ns3modulegen_core_customizations.Attribute_customizations(root_module)

    register_functions(root_module)

    for local_module in LOCAL_MODULES:
        mod = __import__(local_module)
        mod.register_functions(root_module)

    enabled_features = os.environ['NS3_ENABLED_FEATURES'].split(',')

    # if GtkConfigStore support is disabled, disable the class wrapper
    if 'GtkConfigStore' not in enabled_features:
        try:
            root_module.classes.remove(root_module['ns3::GtkConfigStore'])
        except KeyError:
            pass

    # if no sqlite, the class SqliteDataOutput is disabled
    if 'SqliteDataOutput' not in enabled_features:
        try:
            root_module.classes.remove(root_module['ns3::SqliteDataOutput'])
        except KeyError:
            pass

    if 'Threading' not in enabled_features:
        for clsname in ['SystemThread', 'SystemMutex', 'SystemCondition', 'CriticalSection', 'SimpleRefCount< ns3::SystemThread, ns3::empty >']:
            root_module.classes.remove(root_module['ns3::%s' % clsname])

    if 'EmuNetDevice' not in enabled_features:
        for clsname in ['EmuNetDevice', 'EmuHelper']:
            root_module.classes.remove(root_module['ns3::%s' % clsname])
        root_module.enums.remove(root_module['ns3::EmuNetDevice::EncapsulationMode'])

    if 'RealTime' not in enabled_features:
        for clsname in ['WallClockSynchronizer', 'RealtimeSimulatorImpl']:
            root_module.classes.remove(root_module['ns3::%s' % clsname])
        root_module.enums.remove(root_module['ns3::RealtimeSimulatorImpl::SynchronizationMode'])

    if 'TapBridge' not in enabled_features:
        for clsname in ['TapBridge', 'TapBridgeHelper']:
            root_module.classes.remove(root_module['ns3::%s' % clsname])
        root_module.enums.remove(root_module['ns3::TapBridge::Mode'])

    root_module.generate(out, '_ns3')

    out.close()
コード例 #2
0
ファイル: ns3modulegen.py プロジェクト: NKSG/ns3
def main():
    out = MyMultiSectionFactory(sys.argv[1], sys.argv[3:])
    root_module = module_init()
    root_module.add_include('"everything.h"')

    register_types(root_module)

    ns3modulegen_core_customizations.Simulator_customizations(root_module)
    ns3modulegen_core_customizations.CommandLine_customizations(root_module)
    ns3modulegen_core_customizations.TypeId_customizations(root_module)
    ns3modulegen_core_customizations.add_std_ofstream(root_module)
    ns3modulegen_core_customizations.add_ipv4_address_tp_hash(root_module)


    for local_module in LOCAL_MODULES:
        mod = __import__(local_module)
        mod.register_types(root_module)

    ns3modulegen_core_customizations.generate_callback_classes(root_module.after_forward_declarations,
                                                               callbacks_list.callback_classes)


    register_methods(root_module)

    for local_module in LOCAL_MODULES:
        mod = __import__(local_module)
        mod.register_methods(root_module)

    ns3modulegen_core_customizations.Object_customizations(root_module)
    ns3modulegen_core_customizations.Attribute_customizations(root_module)

    register_functions(root_module)

    for local_module in LOCAL_MODULES:
        mod = __import__(local_module)
        mod.register_functions(root_module)

    enabled_features = os.environ['NS3_ENABLED_FEATURES'].split(',')

    # if GtkConfigStore support is disabled, disable the class wrapper
    if 'GtkConfigStore' not in enabled_features:
        try:
            root_module.classes.remove(root_module['ns3::GtkConfigStore'])
        except KeyError:
            pass

    # if no sqlite, the class SqliteDataOutput is disabled
    if 'SqliteDataOutput' not in enabled_features:
        try:
            root_module.classes.remove(root_module['ns3::SqliteDataOutput'])
        except KeyError:
            pass

    if 'Threading' not in enabled_features:
        for clsname in ['SystemThread', 'SystemMutex', 'SystemCondition', 'CriticalSection',
                        'SimpleRefCount< ns3::SystemThread, ns3::empty, ns3::DefaultDeleter<ns3::SystemThread> >']:
            root_module.classes.remove(root_module['ns3::%s' % clsname])

    if 'EmuNetDevice' not in enabled_features:
        for clsname in ['EmuNetDevice', 'EmuHelper']:
            root_module.classes.remove(root_module['ns3::%s' % clsname])
        root_module.enums.remove(root_module['ns3::EmuNetDevice::EncapsulationMode'])

    if 'RealTime' not in enabled_features:
        for clsname in ['WallClockSynchronizer', 'RealtimeSimulatorImpl']:
            root_module.classes.remove(root_module['ns3::%s' % clsname])
        root_module.enums.remove(root_module['ns3::RealtimeSimulatorImpl::SynchronizationMode'])

    if 'TapBridge' not in enabled_features:
        for clsname in ['TapBridge', 'TapBridgeHelper']:
            root_module.classes.remove(root_module['ns3::%s' % clsname])
        root_module.enums.remove(root_module['ns3::TapBridge::Mode'])

    root_module.generate(out, '_ns3')

    out.close()
コード例 #3
0
def main(argv):
    logging.basicConfig()
    logging.getLogger("pybindgen.typehandlers").setLevel(logging.DEBUG)

    module_abs_src_path, target, extension_name, output_cc_file_name = argv[1:]
    module_name = os.path.basename(module_abs_src_path)
    out = MyMultiSectionFactory(output_cc_file_name)

    sys.path.insert(0, os.path.join(module_abs_src_path, "bindings"))
    try:
        module_apidefs = __import__("modulegen__%s" % target)
        del sys.modules["modulegen__%s" % target]
        try:
            module_customization = __import__("modulegen_customizations")
            del sys.modules["modulegen_customizations"]
        except ImportError:
            module_customization = object()

        try:
            from callbacks_list import callback_classes
        except ImportError as ex:
            print("***************", repr(ex), file=sys.stderr)
            callback_classes = []
        else:
            print(">>>>>>>>>>>>>>>>", repr(callback_classes), file=sys.stderr)

    finally:
        sys.path.pop(0)

    apidefs_file, dummy = os.path.splitext(module_apidefs.__file__)
    apidefs_file += '.py'
    pybindgen.settings.error_handler = ErrorHandler(apidefs_file)

    root_module = module_apidefs.module_init()
    root_module.set_name(extension_name)
    root_module.add_include('"ns3/%s-module.h"' % module_name)

    ns3modulegen_core_customizations.add_std_ios_openmode(root_module)

    # -----------
    module_apidefs.register_types(root_module)

    if hasattr(module_customization, 'post_register_types'):
        module_customization.post_register_types(root_module)

    # register Callback<...> type handlers
    ns3modulegen_core_customizations.generate_callback_classes(root_module.after_forward_declarations,
                                                               callback_classes)

    # -----------
    module_apidefs.register_methods(root_module)

    if hasattr(module_customization, 'post_register_methods'):
        module_customization.post_register_methods(root_module)

    ns3modulegen_core_customizations.Object_customizations(root_module)
    ns3modulegen_core_customizations.Attribute_customizations(root_module)


    # -----------
    module_apidefs.register_functions(root_module)
    
    if hasattr(module_customization, 'post_register_functions'):
        module_customization.post_register_functions(root_module)


    # -----------
    root_module.generate(out)
コード例 #4
0
        sys.path.pop(0)

    root_module = module_apidefs.module_init()
    root_module.set_name(extension_name)
    root_module.add_include('"ns3/%s-module.h"' % module_name)

    ns3modulegen_core_customizations.add_std_ios_openmode(root_module)

    # -----------
    module_apidefs.register_types(root_module)

    if hasattr(module_customization, 'post_register_types'):
        module_customization.post_register_types(root_module)

    # register Callback<...> type handlers
    ns3modulegen_core_customizations.generate_callback_classes(
        root_module.after_forward_declarations, callback_classes)

    # -----------
    module_apidefs.register_methods(root_module)

    if hasattr(module_customization, 'post_register_methods'):
        module_customization.post_register_methods(root_module)

    ns3modulegen_core_customizations.Object_customizations(root_module)
    ns3modulegen_core_customizations.Attribute_customizations(root_module)

    # -----------
    module_apidefs.register_functions(root_module)

    if hasattr(module_customization, 'post_register_functions'):
        module_customization.post_register_functions(root_module)
コード例 #5
0
            print >> sys.stderr, ">>>>>>>>>>>>>>>>", repr(callback_classes)

    finally:
        sys.path.pop(0)
    
    root_module = module_apidefs.module_init()
    root_module.add_include('"ns3/%s-module.h"' % module_name)

    # -----------
    module_apidefs.register_types(root_module)

    if hasattr(module_customization, 'post_register_types'):
        module_customization.post_register_types(root_module)

    # register Callback<...> type handlers
    ns3modulegen_core_customizations.generate_callback_classes(root_module.after_forward_declarations,
                                                               callback_classes)

    # -----------
    module_apidefs.register_methods(root_module)

    if hasattr(module_customization, 'post_register_methods'):
        module_customization.post_register_methods(root_module)

    ns3modulegen_core_customizations.Object_customizations(root_module)
    ns3modulegen_core_customizations.Attribute_customizations(root_module)


    # -----------
    module_apidefs.register_functions(root_module)
    
    if hasattr(module_customization, 'post_register_functions'):