How to use the pybindgen.retval function in PyBindGen

To help you get started, we’ve selected a few PyBindGen examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github named-data-ndnSIM / ndnSIM / bindings / modulegen__gcc_LP64.py View on Github external
def reg_strategychoicehelper(cls):
        cls.add_method('Install', retval('void'), [param('ns3::Ptr', 'node'),
                                                   param('const const std::string&', 'name'),
                                                   param('const const std::string&', 'strategy')], is_const=True, is_static=True)
        cls.add_method('Install', retval('void'), [param('const ns3::NodeContainer&', 'c'),
                                                   param('const const std::string&', 'name'),
                                                   param('const const std::string&', 'strategy')], is_const=True, is_static=True)
        cls.add_method('InstallAll', retval('void'), [param('const std::string&', 'name'),
                                                      param('const std::string&', 'strategy')], is_const=True, is_static=True)
    reg_strategychoicehelper(root_module['ns3::ndn::StrategyChoiceHelper'])
github Gabrielcarvfer / NS3 / 3rd-party / dce / bindings / python / ns3_module_dce.py View on Github external
def register_Ns3Ipv4DceRoutingHelper_methods(root_module, cls):
    ## ipv4-dce-routing-helper.h: ns3::Ipv4DceRoutingHelper::Ipv4DceRoutingHelper() [constructor]
    cls.add_constructor([])
    ## ipv4-dce-routing-helper.h: ns3::Ipv4DceRoutingHelper::Ipv4DceRoutingHelper(ns3::Ipv4DceRoutingHelper const & arg0) [copy constructor]
    cls.add_constructor([param('ns3::Ipv4DceRoutingHelper const &', 'arg0')])
    ## ipv4-dce-routing-helper.h: ns3::Ipv4DceRoutingHelper * ns3::Ipv4DceRoutingHelper::Copy() const [member function]
    cls.add_method('Copy', 
                   retval('ns3::Ipv4DceRoutingHelper *', caller_owns_return=False),
                   [], 
                   is_const=True)
    ## ipv4-dce-routing-helper.h: ns3::Ptr ns3::Ipv4DceRoutingHelper::Create(ns3::Ptr node) const [member function]
    cls.add_method('Create', 
                   retval('ns3::Ptr', caller_owns_return=False),
                   [param('ns3::Node *', 'node', transfer_ownership=False)], 
                   is_const=True, is_virtual=True)
    return
github named-data-ndnSIM / ndnSIM / bindings / modulegen__gcc_LP64.py View on Github external
def reg_NfdCs(root_module, cls):
        cls.add_method('size', retval('size_t'), [], is_const=True)
        cls.add_container_traits(retval('const ns3::ndn::nfd::cs::Entry&', caller_manages_return=False),
                                 begin_method='begin', end_method='end', iterator_type='const_iterator')

        def reg_Entry(cls):
            cls.add_method('getName', retval('const ns3::ndn::Name&'), [], is_const=True)
        reg_Entry(root_module['ns3::ndn::nfd::cs::Entry'])
    reg_NfdCs(root_module, root_module['ns3::ndn::nfd::Cs'])
github gergo- / pylibjit / libjit-python / modulegen.py View on Github external
'unsigned int',
                               is_const=True,
                               getter='num_fields')

    cls.add_instance_attribute('num_params', 
                               'unsigned int',
                               is_const=True,
                               getter='num_params')

    cls.add_instance_attribute('abi',
                               'jit_abi_t',
                               is_const=True,
                               getter='get_abi')

    cls.add_instance_attribute('tagged_data', 
                               retval('PyObject *', caller_owns_return=True),
                               is_const=True,
                               getter='get_tagged_data')

    cls.add_instance_attribute('return_via_pointer',
                               'bool',
                               is_const=True,
                               getter='return_via_pointer')

    cls.add_instance_attribute('is_primitive',
                               'bool',
                               is_const=True,
                               getter='is_primitive')

    cls.add_instance_attribute('is_struct',
                               'bool',
                               is_const=True,
github named-data-ndnSIM / ndnSIM / bindings / modulegen__gcc_ILP32.py View on Github external
def reg_NextHopList(cls):
            cls.add_method('size', retval('size_t'), [], is_const=True)
            cls.add_container_traits(retval('const ns3::ndn::nfd::fib::NextHop&', caller_manages_return=False),
                                     begin_method='begin', end_method='end', iterator_type='const_iterator')
        reg_NextHopList(root_module['ns3::ndn::nfd::fib::NextHopList'])
github gjcarneiro / pybindgen / examples / boost_shared_ptr / modulegen.py View on Github external
mod = Module('bsp')

    mod.add_include ('"bsp.h"')

    Foo = mod.add_class('Foo', memory_policy=BoostSharedPtr('::Foo'))

    Foo.add_constructor([param('std::string', 'datum')])
    Foo.add_constructor([])
    Foo.add_method('get_datum', retval('const std::string'), [])
    Foo.add_method('set_datum', None, [param('const std::string', 'datum')])


    mod.add_function('function_that_takes_foo', None,
                     [param('boost::shared_ptr', 'foo')])

    mod.add_function('function_that_returns_foo', retval('boost::shared_ptr'), [])
    
    ## ---- finally, generate the whole thing ----
    mod.generate(FileCodeSink(out_file))
github gergo- / pylibjit / libjit-python / modulegen.py View on Github external
def register_Jit_context_methods(root_module, cls):
    cls.add_constructor([])

    cls.add_instance_attribute('debugger', 
                               ReturnValue.new('jit_debugger_t',
                                               reference_existing_object=True), 
                               is_const=True,
                               getter='debugger')

    cls.add_instance_attribute('functions', 
                               retval('jit_function_t *'),
                               is_const=True)

    cls.add_method('build_start', 
                   'void', 
                   [])

    cls.add_method('build_end', 
                   'void', 
                   [])

    cls.add_method('resolve_all', 
                   'bool', 
                   [param('bool', 'print_failures', default_value='0')])

    cls.add_method('register_symbol', 
                   'bool',
github ejlb / pegasos / generate_bindings.py View on Github external
sf_weight_vector = mod.add_class('SfWeightVector')
sf_weight_vector.add_constructor([pg.param('int', 'dimensionality')])

sf_sparse_vector = mod.add_class('SfSparseVector')
sf_sparse_vector.add_constructor([pg.param('std::vector &', 'x'),
                                  pg.param('float', 'y')])
sf_sparse_vector.add_constructor([pg.param('const char *', 'in_string')])

sf_sparse_vector.add_method('GetY', pg.retval('float'), [])

sf_data_set = mod.add_class('SfDataSet')
sf_data_set.add_constructor([pg.param('bool', 'use_bias_term')])
sf_data_set.add_constructor([pg.param('const std::string &', 'file_name'),
                             pg.param('bool', 'use_bias_term')])
sf_data_set.add_method('VectorAt', pg.retval('const SfSparseVector &'),
                                    [pg.param('long int', 'index')])
sf_data_set.add_method('NumExamples', pg.retval('long int'), [])
sf_data_set.add_method('AddLabeledVector', None,
                       [pg.param('const SfSparseVector &', 'x'),
                        pg.param('float', 'y')])

ns.add_enum('LearnerType', ['PEGASOS', 'LOGREG_PEGASOS', 'LOGREG', 'LMS_REGRESSION', 'SGD_SVM'])
ns.add_enum('EtaType', ['BASIC_ETA', 'PEGASOS_ETA', 'CONSTANT'])
ns.add_enum('LoopType', ['STOCHASTIC', 'BALANCED_STOCHASTIC'])
ns.add_enum('PredictionType', ['LINEAR', 'LOGISTIC'])

struct = ns.add_struct('SofiaConfig')
struct.add_instance_attribute('iterations', 'unsigned int')
struct.add_instance_attribute('dimensionality', 'unsigned int')
struct.add_instance_attribute('lambda_param', 'float')
struct.add_instance_attribute('learner_type', 'LearnerType')