bindings/python/ns3modulegen_core_customizations.py
changeset 3421 b9424c43753d
parent 3412 518719e905a0
child 3473 6bce86ea4778
equal deleted inserted replaced
3420:390db659644b 3421:b9424c43753d
     3 from pybindgen.typehandlers import base as typehandlers
     3 from pybindgen.typehandlers import base as typehandlers
     4 from pybindgen import (ReturnValue, Parameter)
     4 from pybindgen import (ReturnValue, Parameter)
     5 from pybindgen.cppmethod import CustomCppMethodWrapper, CustomCppConstructorWrapper
     5 from pybindgen.cppmethod import CustomCppMethodWrapper, CustomCppConstructorWrapper
     6 from pybindgen.typehandlers.codesink import MemoryCodeSink
     6 from pybindgen.typehandlers.codesink import MemoryCodeSink
     7 from pybindgen.typehandlers import ctypeparser
     7 from pybindgen.typehandlers import ctypeparser
       
     8 from pybindgen import cppclass
     8 import warnings
     9 import warnings
     9 
    10 
    10 from pybindgen.typehandlers.base import CodeGenerationError
    11 from pybindgen.typehandlers.base import CodeGenerationError
    11 
    12 
    12 import sys
    13 import sys
   491 '''
   492 '''
   492     }
   493     }
   493     return 0;
   494     return 0;
   494 }
   495 }
   495 ''')
   496 ''')
       
   497 
       
   498 
       
   499 def Attribute_customizations(module):
       
   500     # Fix up for the "const AttributeValue &v = EmptyAttribute()"
       
   501     # case, as used extensively by helper classes.
       
   502 
       
   503     # Here's why we need to do this: pybindgen.gccxmlscanner, when
       
   504     # scanning parameter default values, is only provided with the
       
   505     # value as a simple C expression string.  (py)gccxml does not
       
   506     # report the type of the default value.
       
   507 
       
   508     # As a workaround, here we iterate over all parameters of all
       
   509     # methods of all classes and tell pybindgen what is the type of
       
   510     # the default value for attributes.
       
   511 
       
   512     for cls in module.classes:
       
   513         for meth in cls.get_all_methods():
       
   514             for param in meth.parameters:
       
   515                 if isinstance(param, cppclass.CppClassRefParameter):
       
   516                     if param.cpp_class.name == 'AttributeValue' \
       
   517                             and param.default_value is not None \
       
   518                             and param.default_value_type is None:
       
   519                         param.default_value_type = 'ns3::EmptyAttributeValue'
       
   520