Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from __future__ import print_function
import warnings
import sys
import os
import pybindgen.settings
from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
from pybindgen.module import MultiSectionFactory
import ns3modulegen_core_customizations
import logging
pybindgen.settings.wrapper_registry = pybindgen.settings.StdMapWrapperRegistry
import traceback
class ErrorHandler(pybindgen.settings.ErrorHandler):
def __init__(self, apidefs_file):
self.apidefs_file = apidefs_file
def handle_error(self, wrapper, exception, traceback_):
stack = getattr(wrapper, 'stack_where_defined', [])
stack.reverse()
for l in stack:
if l[0] == self.apidefs_file:
warnings.warn_explicit("exception %r in wrapper %s" % (exception, wrapper),
Warning, l[0], l[1])
break
from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
import pybindgen.settings
import warnings
class ErrorHandler(pybindgen.settings.ErrorHandler):
def handle_error(self, wrapper, exception, traceback_):
warnings.warn("exception %r in wrapper %s" % (exception, wrapper))
return True
pybindgen.settings.error_handler = ErrorHandler()
import sys
def module_init():
root_module = Module('dce', cpp_namespace='::ns3')
root_module.add_include('"ns3/dce-module.h"')
root_module.add_include('"ns3/dce-manager-helper.h"')
root_module.add_include('"ns3/dce-application.h"')
root_module.add_include('"ns3/ipv4-dce-routing-helper.h"')
return root_module
from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
import pybindgen.settings
import warnings
class ErrorHandler(pybindgen.settings.ErrorHandler):
def handle_error(self, wrapper, exception, traceback_):
warnings.warn("exception %r in wrapper %s" % (exception, wrapper))
return True
pybindgen.settings.error_handler = ErrorHandler()
import sys
def module_init():
root_module = Module('ns.config_store', cpp_namespace='::ns3')
return root_module
def register_types(module):
root_module = module.get_root()
## callback.h (module 'core'): ns3::CallbackBase [class]
from pygccxml.declarations.class_declaration import class_t
from pygccxml.declarations.free_calldef import free_function_t
from pygccxml.declarations.calldef_members import constructor_t, member_function_t
from pygccxml.declarations.calldef import calldef_t
## we need the smart pointer type transformation to be active even
## during castxml scanning.
import ns3modulegen_core_customizations
## silence castxmlparser errors; we only want error handling in the
## generated python script, not while scanning.
class ErrorHandler(pybindgen.settings.ErrorHandler):
def handle_error(self, dummy_wrapper, dummy_exception, dummy_traceback_):
return True
pybindgen.settings.error_handler = ErrorHandler()
import warnings
warnings.filterwarnings(category=WrapperWarning, action='ignore')
import ns3modulescan
type_annotations = ns3modulescan.type_annotations
def get_ns3_relative_path(path):
l = []
head = path
if not path:
return
while head:
new_head, tail = os.path.split(head)
if new_head == head:
#! /usr/bin/env python
import sys
import pybindgen
from pybindgen import ReturnValue, Parameter, Module, Function, FileCodeSink
from pybindgen import CppMethod, CppConstructor, CppClass, Enum
import pybindgen.settings
pybindgen.settings.deprecated_virtuals = False
def my_module_gen(out_file):
mod = Module('f')
mod.add_include('"f.h"')
FBase = mod.add_class('FBase', allow_subclassing=True)
FBase.add_constructor([])
FBase.add_method('DoA', None, [], is_virtual=True, is_pure_virtual=True)
FBase.add_method('PrivDoB', None, [], is_virtual=True, is_pure_virtual=True, visibility='private')
FBase.add_method('DoB', None, [])
mod.generate(FileCodeSink(out_file) )
if __name__ == '__main__':
## backward compatibility check
if isinstance(return_value, str) and isinstance(method_name, ReturnValue):
warnings.warn("CppMethod has changed API; see the API documentation (but trying to correct...)",
DeprecationWarning, stacklevel=2)
method_name, return_value = return_value, method_name
# bug 399870
if is_virtual is None:
is_virtual = is_pure_virtual
if return_value is None:
return_value = ReturnValue.new('void')
if unblock_threads is None:
unblock_threads = settings.unblock_threads
assert visibility in ['public', 'protected', 'private']
self.visibility = visibility
self.method_name = method_name
self.is_static = is_static
self.is_virtual = is_virtual
self.is_pure_virtual = is_pure_virtual
self.is_const = is_const
self.template_parameters = template_parameters
self.custom_name = (custom_name or custom_template_method_name)
#self.static_decl = True
self._class = None
self._helper_class = None
self.docstring = docstring
from pygccxml.declarations.free_calldef import free_function_t
from pygccxml.declarations.calldef_members import constructor_t, member_function_t
from pygccxml.declarations.calldef import calldef_t
## we need the smart pointer type transformation to be active even
## during gccxml scanning.
import ns3modulegen_core_customizations
## silence gccxmlparser errors; we only want error handling in the
## generated python script, not while scanning.
class ErrorHandler(pybindgen.settings.ErrorHandler):
def handle_error(self, dummy_wrapper, dummy_exception, dummy_traceback_):
return True
pybindgen.settings.error_handler = ErrorHandler()
import warnings
warnings.filterwarnings(category=WrapperWarning, action='ignore')
type_annotations = {
'::ns3::AttributeChecker': {
'automatic_type_narrowing': 'true',
'allow_subclassing': 'false',
},
'::ns3::AttributeValue': {
'automatic_type_narrowing': 'true',
'allow_subclassing': 'false',
},
'::ns3::CommandLine': {
'allow_subclassing': 'true', # needed so that AddValue is able to set attributes on the object
},
import pybindgen.settings
from pybindgen.gccxmlparser import ModuleParser, PygenClassifier, PygenSection, WrapperWarning
from pybindgen.typehandlers.codesink import FileCodeSink
from pygccxml.declarations import templates
from pygccxml.declarations.class_declaration import class_t
from pygccxml.declarations.calldef import free_function_t, member_function_t, constructor_t, calldef_t
## we need the smart pointer type transformation to be active even
## during gccxml scanning.
import ns3modulegen_core_customizations
## silence gccxmlparser errors; we only want error handling in the
## generated python script, not while scanning.
class ErrorHandler(pybindgen.settings.ErrorHandler):
def handle_error(self, dummy_wrapper, dummy_exception, dummy_traceback_):
return True
pybindgen.settings.error_handler = ErrorHandler()
import warnings
warnings.filterwarnings(category=WrapperWarning, action='ignore')
type_annotations = {
'::ns3::AttributeChecker': {
'automatic_type_narrowing': 'true',
'allow_subclassing': 'false',
},
'::ns3::AttributeValue': {
'automatic_type_narrowing': 'true',
'allow_subclassing': 'false',
},
## backward compatibility check
if isinstance(return_value, str) and isinstance(method_name, ReturnValue):
warnings.warn("CppMethod has changed API; see the API documentation (but trying to correct...)",
DeprecationWarning, stacklevel=2)
method_name, return_value = return_value, method_name
# bug 399870
if is_virtual is None:
is_virtual = is_pure_virtual
if return_value is None:
return_value = ReturnValue.new('void')
if unblock_threads is None:
unblock_threads = settings.unblock_threads
assert visibility in ['public', 'protected', 'private']
self.visibility = visibility
self.method_name = method_name
self.is_static = is_static
self.is_virtual = is_virtual
self.is_pure_virtual = is_pure_virtual
self.is_const = is_const
self.template_parameters = template_parameters
self.custom_name = (custom_name or custom_template_method_name)
#self.static_decl = True
self._class = None
self._helper_class = None
self.docstring = docstring