Modular bindings: make Scalar operators work again
This commit is contained in:
@@ -5,7 +5,7 @@ from pybindgen import ReturnValue, Parameter
|
||||
from pybindgen.cppmethod import CustomCppMethodWrapper, CustomCppConstructorWrapper
|
||||
from pybindgen.typehandlers.codesink import MemoryCodeSink
|
||||
from pybindgen.typehandlers import ctypeparser
|
||||
from pybindgen import cppclass
|
||||
from pybindgen import cppclass, param, retval
|
||||
import warnings
|
||||
|
||||
from pybindgen.typehandlers.base import CodeGenerationError
|
||||
@@ -440,17 +440,47 @@ _ns3_Ipv4Address_tp_hash (PyObject *obj)
|
||||
module['Ipv4Address'].pytype.slots['tp_hash'] = "_ns3_Ipv4Address_tp_hash"
|
||||
|
||||
|
||||
def add_scalar_operators(root_module):
|
||||
# Scalar implicitly converts to Time, but pybindgen gccxml parser
|
||||
# cannot pick up operators supported through implicit conversions,
|
||||
# so we add them manually here.
|
||||
cls = root_module['ns3::Scalar']
|
||||
|
||||
cls.add_binary_numeric_operator('*', root_module['ns3::Scalar'], root_module['ns3::Scalar'], param('ns3::Scalar const &', 'right'))
|
||||
cls.add_binary_numeric_operator('+', root_module['ns3::Scalar'], root_module['ns3::Scalar'], param('ns3::Scalar const &', 'right'))
|
||||
cls.add_binary_numeric_operator('-', root_module['ns3::Scalar'], root_module['ns3::Scalar'], param('ns3::Scalar const &', 'right'))
|
||||
cls.add_binary_numeric_operator('/', root_module['ns3::Scalar'], root_module['ns3::Scalar'], param('ns3::Scalar const &', 'right'))
|
||||
|
||||
cls.add_binary_numeric_operator('*', root_module['ns3::Time'], root_module['ns3::Scalar'], param('ns3::Time const &', 'right'))
|
||||
cls.add_binary_numeric_operator('-', root_module['ns3::Time'], root_module['ns3::Scalar'], param('ns3::Time const &', 'right'))
|
||||
|
||||
root_module['ns3::Time'].add_binary_numeric_operator(
|
||||
'*', root_module['ns3::Time'], root_module['ns3::Time'], param('ns3::Scalar const &', 'right'))
|
||||
|
||||
root_module['ns3::Time'].add_binary_numeric_operator(
|
||||
'-', root_module['ns3::Time'], root_module['ns3::Time'], param('ns3::Scalar const &', 'right'))
|
||||
|
||||
cls.add_binary_comparison_operator('<')
|
||||
cls.add_binary_comparison_operator('>')
|
||||
cls.add_binary_comparison_operator('!=')
|
||||
cls.add_output_stream_operator()
|
||||
cls.add_binary_comparison_operator('<=')
|
||||
cls.add_binary_comparison_operator('==')
|
||||
cls.add_binary_comparison_operator('>=')
|
||||
|
||||
|
||||
def post_register_types(root_module):
|
||||
Simulator_customizations(root_module)
|
||||
CommandLine_customizations(root_module)
|
||||
TypeId_customizations(root_module)
|
||||
add_std_ofstream(root_module)
|
||||
|
||||
def post_register_functions(root_module):
|
||||
# these are already in the main script, so commented out here
|
||||
#Object_customizations(root_module)
|
||||
#Attribute_customizations(root_module)
|
||||
pass
|
||||
add_scalar_operators(root_module)
|
||||
|
||||
|
||||
# these are already in the main script, so commented out here
|
||||
# Object_customizations(root_module)
|
||||
# Attribute_customizations(root_module)
|
||||
#def post_register_functions(root_module):
|
||||
# pass
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user