Пример #1
0
def generate(module_builder, local_ns, global_ns):
    """
    local_ns: is the namespace that corresponds to the given namespace
    global_ns: is the module builder for the entire library
    """

    local_ns.exclude()
    classes = []

    module_builder.class_('::ram::core::Subsystem').already_exposed = True

    # NetworkPublisher
    NetworkPublisher = local_ns.class_('NetworkPublisher')
    NetworkPublisher.include()
    classes.append(NetworkPublisher)

    events = wrap.expose_events(local_ns)

    if events:
        wrap.make_already_exposed(global_ns, 'ram::core', ['Event'])
        classes += events

    wrap.registerSubsystemConverter(NetworkPublisher)

    wrap.add_needed_includes(classes)

    include_files = set([cls.location.file_name for cls in classes])
    for cls in classes:
        include_files.update(cls.include_files)
    return ['wrappers/network/include/RegisterFunctions.h'] + list(include_files)
Пример #2
0
def generate(module_builder, local_ns, global_ns):
    """
    local_ns: is the namespace that coresponds to the given namespace
    global_ns: is the module builder for the entire library
    """
    global_ns.exclude()
    classes = []

    # Mark class from other modules as already exposed
    module_builder.class_('::ram::core::Subsystem').already_exposed = True

    # EventPlayer
    EventPlayer = local_ns.class_('EventPlayer')
    EventPlayer.include()
    classes.append(EventPlayer)

    events = wrap.expose_events(local_ns)

    if events:
        wrap.make_already_exposed(global_ns, 'ram::core', ['Event'])
        classes += events

    # Do class wide items
    wrap.add_needed_includes(classes)

    # Add registrations functions for hand wrapped classes
    module_builder.add_registration_code("registerLoggingPtrs();")

    include_files = set([cls.location.file_name for cls in classes])
    for cls in classes:
        include_files.update(cls.include_files)
    return ['wrappers/logging/include/RegisterFunctions.h'
            ] + list(include_files)
Пример #3
0
def generate(module_builder, local_ns, global_ns):
    """
    local_ns: is the namespace that coresponds to the given namespace
    global_ns: is the module builder for the entire library
    """
    global_ns.exclude()
    classes = []

    # Mark class from other modules as already exposed
    module_builder.class_('::ram::core::Subsystem').already_exposed = True

    # EventPlayer
    EventPlayer = local_ns.class_('EventPlayer')
    EventPlayer.include()
    classes.append(EventPlayer)

    events = wrap.expose_events(local_ns)

    if events:
        wrap.make_already_exposed(global_ns, 'ram::core', ['Event'])
        classes += events

    # Do class wide items
    wrap.add_needed_includes(classes)

    # Add registrations functions for hand wrapped classes
    module_builder.add_registration_code("registerLoggingPtrs();")

    include_files = set([cls.location.file_name for cls in classes])
    for cls in classes:
        include_files.update(cls.include_files)
    return ['wrappers/logging/include/RegisterFunctions.h'] + list(include_files)
Пример #4
0
def generate(module_builder, local_ns, global_ns):
    """
    local_ns: is the namespace that corresponds to the given namespace
    global_ns: is the module builder for the entire library
    """

    local_ns.exclude()
    classes = []

    module_builder.class_('::ram::core::Subsystem').already_exposed = True

    # NetworkPublisher
    NetworkPublisher = local_ns.class_('NetworkPublisher')
    NetworkPublisher.include()
    classes.append(NetworkPublisher)

    events = wrap.expose_events(local_ns)

    if events:
        wrap.make_already_exposed(global_ns, 'ram::core', ['Event'])
        classes += events

    wrap.registerSubsystemConverter(NetworkPublisher)

    wrap.add_needed_includes(classes)

    include_files = set([cls.location.file_name for cls in classes])
    for cls in classes:
        include_files.update(cls.include_files)
    return ['wrappers/network/include/RegisterFunctions.h'
            ] + list(include_files)
Пример #5
0
def generate(module_builder, local_ns, global_ns):
    classes = []

    # Mark class from other modules as already exposed
    module_builder.class_('::ram::core::Subsystem').already_exposed = True
    module_builder.class_('::ram::math::Vector3').already_exposed = True
    Quaternion = module_builder.class_('::ram::math::Quaternion')
    Quaternion.already_exposed = True
    Quaternion.constructors().allow_implicit_conversion = False

    # Include controller classes
    IController = local_ns.class_('IController')
    IController.include()

    IController.include_files.append(os.environ['RAM_SVN_DIR'] +
                                     '/packages/control/include/IController.h')
    classes.append(IController)

    # Include desired state class
    DesiredState = global_ns.class_('DesiredState')
    DesiredState.include()
    DesiredState.include_files.append(
        os.environ['RAM_SVN_DIR'] + '/packages/control/include/DesiredState.h')
    classes.append(DesiredState)

    yawVehicleHelper = local_ns.free_function('yawVehicleHelper')
    pitchVehicleHelper = local_ns.free_function('pitchVehicleHelper')
    rollVehicleHelper = local_ns.free_function('rollVehicleHelper')
    holdCurrentHeadingHelper = local_ns.free_function(
        'holdCurrentHeadingHelper')

    yawVehicleHelper.include()
    pitchVehicleHelper.include()
    rollVehicleHelper.include()
    holdCurrentHeadingHelper.include()

    # Wrap Events
    events = wrap.expose_events(local_ns)

    if events:
        wrap.make_already_exposed(global_ns, 'ram::core', ['Event'])
        classes += events

    # Add a castTo
    wrap.registerSubsystemConverter(IController)

    wrap.add_needed_includes(classes)
    module_builder.add_registration_code("registerIControllerPtrs();")

    include_files = set([cls.location.file_name for cls in classes])
    include_files.add('packages/control/include/Helpers.h')
    for cls in classes:
        include_files.update(cls.include_files)
    return ['wrappers/control/include/RegisterFunctions.h'
            ] + list(include_files)
Пример #6
0
def generate(module_builder, local_ns, global_ns):
    classes = []

    # Mark class from other modules as already exposed
    module_builder.class_('::ram::core::Subsystem').already_exposed = True
    module_builder.class_('::ram::math::Vector3').already_exposed = True
    Quaternion = module_builder.class_('::ram::math::Quaternion')
    Quaternion.already_exposed = True
    Quaternion.constructors().allow_implicit_conversion = False

    # Include controller classes
    IController = local_ns.class_('IController')
    IController.include()
    
    IController.include_files.append(os.environ['RAM_SVN_DIR'] +
                                     '/packages/control/include/IController.h')
    classes.append(IController)

    # Include desired state class
    DesiredState = global_ns.class_('DesiredState')
    DesiredState.include()
    DesiredState.include_files.append(os.environ['RAM_SVN_DIR'] +
                                     '/packages/control/include/DesiredState.h')
    classes.append(DesiredState)

    yawVehicleHelper = local_ns.free_function('yawVehicleHelper')
    pitchVehicleHelper = local_ns.free_function('pitchVehicleHelper')
    rollVehicleHelper = local_ns.free_function('rollVehicleHelper')
    holdCurrentHeadingHelper = local_ns.free_function('holdCurrentHeadingHelper')

    yawVehicleHelper.include()
    pitchVehicleHelper.include()
    rollVehicleHelper.include()
    holdCurrentHeadingHelper.include()

    # Wrap Events
    events = wrap.expose_events(local_ns)

    if events:
        wrap.make_already_exposed(global_ns, 'ram::core', ['Event'])
        classes += events

    # Add a castTo
    wrap.registerSubsystemConverter(IController)

    wrap.add_needed_includes(classes)
#    wrap.make_already_exposed(global_ns, 'ram::pattern', 'Subject')
    module_builder.add_registration_code("registerIControllerPtrs();")

    include_files = set([cls.location.file_name for cls in classes])
    include_files.add('packages/control/include/Helpers.h')
    for cls in classes:
        include_files.update(cls.include_files)
    return ['wrappers/control/include/RegisterFunctions.h'] + list(include_files)
Пример #7
0
def generate(module_builder, local_ns, global_ns):
    """
    global_ns: is the module builder for the entire library
    local_ns: is the namespace that coresponds to the given namespace
    """
    local_ns.include()

    # Free function which deals with a std::vector<boost::shared_ptr<T> >
    f = local_ns.free_fun( 'funcVectorShared' )
    AList = declarations.remove_declarated(f.return_type)
    wrap.fix_shared_ptr_vector(AList)
    AList.alias = 'AList'

    # CodeInject Class
    CodeInject = local_ns.class_('CodeInject')

    # Return type only function
    CodeInject.add_declaration_code("""
  int injectedFunc( samples::CodeInject& code ){
      return code.getValue();
  }
    """);
    CodeInject.add_registration_code(
        'def( "injectedFunc", &::injectedFunc )', works_on_instance = True)
                                     
    # Return and set type function
    CodeInject.add_declaration_code("""
    int otherInjectedFunc(samples::CodeInject& code, int value) {
        return code.setValue(value);
    }
    """);
    CodeInject.add_registration_code(
        'def("otherInjectedFunc", (int (*)(samples::CodeInject&, int))(&::otherInjectedFunc))',
        works_on_instance = True)


    # This does not work, because its append with a ".bp..."
    # if it wasn't this would work perfectly
    #CodeInject.add_registration_code(
    #    'bp::implicitly_convertible< int, samples::CodeInject >()')

    wrap.add_needed_includes([CodeInject])
    wrap.set_implicit_conversions([CodeInject], False)

    return ['include/SharedPtrVector.h']
Пример #8
0
def generate(module_builder, local_ns, global_ns):
    """
    global_ns: is the module builder for the entire library
    local_ns: is the namespace that coresponds to the given namespace
    """
    local_ns.include()

    # Free function which deals with a std::vector<boost::shared_ptr<T> >
    f = local_ns.free_fun('funcVectorShared')
    AList = declarations.remove_declarated(f.return_type)
    wrap.fix_shared_ptr_vector(AList)
    AList.alias = 'AList'

    # CodeInject Class
    CodeInject = local_ns.class_('CodeInject')

    # Return type only function
    CodeInject.add_declaration_code("""
  int injectedFunc( samples::CodeInject& code ){
      return code.getValue();
  }
    """)
    CodeInject.add_registration_code('def( "injectedFunc", &::injectedFunc )',
                                     works_on_instance=True)

    # Return and set type function
    CodeInject.add_declaration_code("""
    int otherInjectedFunc(samples::CodeInject& code, int value) {
        return code.setValue(value);
    }
    """)
    CodeInject.add_registration_code(
        'def("otherInjectedFunc", (int (*)(samples::CodeInject&, int))(&::otherInjectedFunc))',
        works_on_instance=True)

    # This does not work, because its append with a ".bp..."
    # if it wasn't this would work perfectly
    #CodeInject.add_registration_code(
    #    'bp::implicitly_convertible< int, samples::CodeInject >()')

    wrap.add_needed_includes([CodeInject])
    wrap.set_implicit_conversions([CodeInject], False)

    return ['include/SharedPtrVector.h']
Пример #9
0
def generate(module_builder, local_ns, global_ns):
    """
    global_ns: is the module builder for the entire library
    local_ns: is the namespace that coresponds to the given namespace
    """
    global_ns.exclude()
    classes = []

    # Wrap Events
    EventType = local_ns.class_('EventType')
    EventType.include()
    classes.append(EventType)

    # Append the approaite include files
#    for cls in classes:
#        cls.include()
    wrap.add_needed_includes(classes)

    include_files = set([cls.location.file_name for cls in classes])
    for cls in classes:
        include_files.update(cls.include_files)
    return list(include_files)
Пример #10
0
def generate(module_builder, local_ns, global_ns):
    """
    global_ns: is the module builder for the entire library
    local_ns: is the namespace that coresponds to the given namespace
    """
    global_ns.exclude()
    classes = []

    # Wrap Events
    EventType = local_ns.class_('EventType')
    EventType.include()
    classes.append(EventType)

    # Append the approaite include files
    #    for cls in classes:
    #        cls.include()
    wrap.add_needed_includes(classes)

    include_files = set([cls.location.file_name for cls in classes])
    for cls in classes:
        include_files.update(cls.include_files)
    return list(include_files)
Пример #11
0
def generate(module_builder, local_ns, global_ns):
    """
    global_ns: is the module builder for the entire library
    local_ns: is the namespace that coresponds to the given namespace
    """
    classes = []

    # Find all the classes to wrap
    Radian = local_ns.class_('Radian')
    Degree = local_ns.class_('Degree')
    Vector2 = local_ns.class_('Vector2')
    Vector3 = local_ns.class_('Vector3')
    Quaternion = local_ns.class_('Quaternion')
    Matrix2 = local_ns.class_('Matrix2')
    Matrix3 = local_ns.class_('Matrix3')

    # Include them
    Radian.include()
    Degree.include()
    Vector2.include()
    Vector3.include()
    Quaternion.include()
    Matrix2.include()
    Matrix3.include()

    classes.extend(
        [Radian, Degree, Vector2, Vector3, Quaternion, Matrix2, Matrix3])

    # Map operator<< to __str__
    wrap.str_from_ostream(local_ns)

    # Fix '[]' operators on matrices
    c = Matrix2.operators('[]')
    c.call_policies= call_policies.convert_array_to_tuple(2, \
        call_policies.memory_managers.none)
    c.include()
    c.documentation = wrap.docit("Return Type Change", "None",
                                 "Tuple with 2 floats's (the matrix 'line')")

    c = Matrix3.operators('[]')
    c.call_policies= call_policies.convert_array_to_tuple(3, \
        call_policies.memory_managers.none)
    c.include()
    c.documentation = wrap.docit("Return Type Change", "None",
                                 "Tuple with 3 floats's (the matrix 'line')")

    # Handle the 'ptr' functions
    wrap.fix_pointer_returns([Vector2, Vector3, Quaternion, Matrix2, Matrix3],
                             ignore_names=['ptr'])
    wrap.fix_pointer_args([Vector2, Vector3, Quaternion, Matrix2, Matrix3])

    # Remove float -> Radian/Degree implicit conversions
    Degree.constructor(arg_types=['double']).allow_implicit_conversion = False
    Radian.constructor(arg_types=['double']).allow_implicit_conversion = False

    # Wrap Events
    events = wrap.expose_events(local_ns)

    if events:
        module_builder.class_('::ram::core::Event').already_exposed = True
        classes += events

    # Append the approaite include files
    wrap.add_needed_includes(classes)
    Quaternion.include_files.append(Matrix3.location.file_name)

    # Remove implicit conversions
    wrap.set_implicit_conversions(
        [Vector2, Vector3, Quaternion, Matrix2, Matrix3], False)

    include_files = set([cls.location.file_name for cls in classes])
    for cls in classes:
        include_files.update(cls.include_files)
    return ['math/include/Math.h'] + list(include_files)
Пример #12
0
def generate(module_builder, local_ns, global_ns):
    """
    global_ns: is the module builder for the entire library
    local_ns: is the namespace that coresponds to the given namespace
    """
    classes = []

    # Find all the classes to wrap
    Radian = local_ns.class_('Radian')
    Degree = local_ns.class_('Degree')
    Vector2 = local_ns.class_('Vector2')
    Vector3 = local_ns.class_('Vector3')
    Quaternion = local_ns.class_('Quaternion')
    Matrix2 = local_ns.class_('Matrix2')
    Matrix3 = local_ns.class_('Matrix3')

    # Include them
    Radian.include()
    Degree.include()
    Vector2.include()
    Vector3.include()
    Quaternion.include()
    Matrix2.include()
    Matrix3.include()

    classes.extend([Radian, Degree, Vector2, Vector3, Quaternion, Matrix2,
                    Matrix3])

    # Map operator<< to __str__
    wrap.str_from_ostream(local_ns)

    # Fix '[]' operators on matrices
    c = Matrix2.operators('[]')
    c.call_policies= call_policies.convert_array_to_tuple(2, \
        call_policies.memory_managers.none)
    c.include()
    c.documentation = wrap.docit("Return Type Change", "None",
                                 "Tuple with 2 floats's (the matrix 'line')")
    
    c = Matrix3.operators('[]')
    c.call_policies= call_policies.convert_array_to_tuple(3, \
        call_policies.memory_managers.none)
    c.include()
    c.documentation = wrap.docit("Return Type Change", "None",
                                 "Tuple with 3 floats's (the matrix 'line')")

    # Handle the 'ptr' functions
    wrap.fix_pointer_returns([Vector2, Vector3, Quaternion, Matrix2, Matrix3],
                             ignore_names = ['ptr'])
    wrap.fix_pointer_args([Vector2, Vector3, Quaternion, Matrix2, Matrix3])

    # Remove float -> Radian/Degree implicit conversions
    Degree.constructor(arg_types = ['double']).allow_implicit_conversion = False
    Radian.constructor(arg_types = ['double']).allow_implicit_conversion = False

    # Wrap Events
    events = wrap.expose_events(local_ns)

    if events:
        module_builder.class_('::ram::core::Event').already_exposed = True
        classes += events

    # Append the approaite include files
    wrap.add_needed_includes(classes)
    Quaternion.include_files.append(Matrix3.location.file_name)
    
    # Remove implicit conversions
    wrap.set_implicit_conversions([Vector2, Vector3, Quaternion, Matrix2,
                                   Matrix3], False)

    include_files = set([cls.location.file_name for cls in classes])
    for cls in classes:
        include_files.update(cls.include_files)
    return ['math/include/Math.h'] + list(include_files)
Пример #13
0
def generate(module_builder, local_ns, global_ns):
    """
    name: is the name of the module being wrapped (in name::space::form)
    global_ns: is the module builder for the entire library
    local_ns: is the namespace that coresponds to the given namespace
    """

    # Remove all those pesky warnings about only pointed to types!
    for cls in local_ns.decls(decl_type=decls_package.class_declaration_t):
        cls.include()
        cls.already_exposed = True

    module_builder.class_('::ram::core::Subsystem').already_exposed = True

    classes = []

    # Include IVehicle class and handle special cases
    IVehicle = local_ns.class_('IVehicle')
    IVehicle.include()
    classes.append(IVehicle)

    # Remove default wrapper for getDevice
    IVehicle.member_function('getDevice').exclude()

    # Provide the normal one by hand, so C++ users of python subclasses
    # still get the overridden method
    IVehicle.add_wrapper_code("""
    virtual ::ram::vehicle::device::IDevicePtr getDevice( ::std::string name ){
        bp::override func = this->get_override(\"getDevice\");
        return func( name);
    }
    """)

    # Provide a hand made implementation for Python users of C++ IVehicle
    # subclasses, this uses our custom converter to ensure proper IDevice
    # downcasting
    IVehicle.add_declaration_code("""
    boost::python::object pyGetDevice(
        ram::vehicle::IVehicle& veh,
        std::string deviceName)
    {
        ram::vehicle::device::IDevicePtr device =
            veh.getDevice(deviceName);
        return ram::vehicle::device::IDeviceConverter::convertObject(device);
    }
    """)
    IVehicle.add_registration_code("def(\"getDevice\", &::pyGetDevice)",
                                   works_on_instance = True )
    IVehicle.include_files.append('vehicle/include/device/IDeviceConverter.h')

    global_ns.typedef('TempNameList').type.declaration.already_exposed = True
    global_ns.typedef('TempList').include()

    # Fix TempNameList (the include does stick)
    t = global_ns.class_(function =
                         lambda x: x.name.startswith('vector<std::string'))
    t.already_exposed = True

    # Fix overley long std::container names
    #wrap.mangle_container_names(local_ns)

    # Wrap Events
    events = wrap.expose_events(local_ns)
    if events:
        module_builder.class_('::ram::core::Event').already_exposed = True
        classes += events
    
    # Added the needed includes
    wrap.add_needed_includes(classes)
    IVehicle.include_files.append(os.environ['RAM_SVN_DIR'] +
                                  '/packages/vehicle/include/device/IDevice.h')

    # Add a castTo
    wrap.registerSubsystemConverter(IVehicle)

    module_builder.add_registration_code("registerIVehiclePtrs();")

    include_files = set([cls.location.file_name for cls in classes])
    for cls in classes:
        include_files.update(cls.include_files)
    return ['wrappers/vehicle/include/RegisterFunctions.h'] + list(include_files)
Пример #14
0
def generate(module_builder, local_ns, global_ns):
    """
    global_ns: is the module builder for the entire library
    local_ns: is the namespace that coresponds to the given namespace
    """
    
    # Remove all those pesky warnings about only pointed to types!
    for cls in local_ns.decls(decl_type=decls_package.class_declaration_t):
        cls.include()
        cls.already_exposed = True

    module_builder.class_('::ram::core::EventPublisher').already_exposed = True
    module_builder.class_('::ram::core::IUpdatable').already_exposed = True

    wrappedClasses = []

    # Wrap IDevice Class
    IDevice = expose_device(local_ns, 'IDevice', register = False);
    wrappedClasses.append(IDevice)

    # Wrap the thruster class
    IThruster = expose_device(local_ns, 'IThruster')
    wrappedClasses.append(IThruster)

    # Wrap the IDepthSensor class
    IDepthSensor = expose_device(local_ns, 'IDepthSensor')
    wrappedClasses.append(IDepthSensor)

    # Wrap marker interfaces (slightly abuse expose device)
    IVoltageProvider = expose_device(local_ns, 'IVoltageProvider',
                                     register = False)
    wrappedClasses.append(IVoltageProvider)
    ICurrentProvider = expose_device(local_ns, 'ICurrentProvider',
                                     register = False)
    wrappedClasses.append(ICurrentProvider)

    # Wrap the IPowerSource class
    IPowerSource = expose_device(local_ns, 'IPowerSource')
    wrappedClasses.append(IPowerSource)

    # Wrap the ITempSensor class
    ITempSensor = expose_device(local_ns, 'ITempSensor')
    wrappedClasses.append(ITempSensor)

    # Wrap the IIMU class
    IIMU = expose_device(local_ns, 'IIMU')
    wrappedClasses.append(IIMU)

    # Wrap the ISonar class
    ISonar = expose_device(local_ns, 'ISonar')
    wrappedClasses.append(ISonar)

    # Wrap the IPayloadSet class
    IPayloadSet = expose_device(local_ns, 'IPayloadSet')
    wrappedClasses.append(IPayloadSet)

    # Wrap the IVelocitySensor class
    IVelocitySensor = expose_device(local_ns, 'IVelocitySensor')
    wrappedClasses.append(IVelocitySensor)

    # Wrap the IPositionSensor class
    IPositionSensor = expose_device(local_ns, 'IPositionSensor')
    wrappedClasses.append(IPositionSensor)

    # Wrap Events
    events = wrap.expose_events(local_ns)
    if events:
        module_builder.class_('::ram::core::Event').already_exposed = True
        classes += events

    module_builder.add_registration_code("registerIDeviceMakerClass();")
    module_builder.add_registration_code("registerIDevicePtrs();")
    wrap.add_needed_includes(wrappedClasses)

    include_files = set([cls.location.file_name for cls in wrappedClasses])
    for cls in wrappedClasses:
        include_files.update(cls.include_files)
    return ['wrappers/vehicle/include/RegisterFunctions.h',
            'core/include/Event.h'] + list(include_files)
Пример #15
0
def generate(module_builder, local_ns, global_ns):
    """
    global_ns: is the module builder for the entire library
    local_ns: is the namespace that coresponds to the given namespace
    """
    global_ns.exclude()
    classes = []

    # Lets Py++ know to make VisionSystem a subclass of Subsystem
    module_builder.class_('::ram::core::Subsystem').already_exposed = True
    module_builder.class_('::ram::core::Event').already_exposed = True

    # Vision System
    VisionSystem = local_ns.class_('VisionSystem')
    VisionSystem.include()
    VisionSystem.include_files.append('vision/include/Camera.h')
    classes.append(VisionSystem)   

    # Wrap Events
    EventType = local_ns.class_('EventType')
    EventType.include()
    classes.append(EventType)

    Symbol = local_ns.class_('Symbol')
    Symbol.include()
    Symbol.member_function('getSymbolNames').exclude()
    Symbol.member_function('symbolToText').exclude()
    classes.append(Symbol)

    Color = local_ns.class_('Color')
    Color.include()
    Color.member_function('getColorNames').exclude()
    Color.member_function('colorToText').exclude()
    classes.append(Color)
    
    events = wrap.expose_events(local_ns)
    classes += events

    ImageEvent = local_ns.class_('ImageEvent')
    ImageEvent.include_files.append('vision/include/Image.h')
    wrap.set_implicit_conversions([ImageEvent], False)

    BinEvent = local_ns.class_('BinEvent')
    wrap.set_implicit_conversions([BinEvent], False)

    if events:
        wrap.make_already_exposed(global_ns, 'ram::core', ['Event'])
        classes += events

    # Append the approaite include files
#    for cls in classes:
#        cls.include()
    wrap.add_needed_includes(classes)

    module_builder.add_registration_code("registerImageClass();")
    module_builder.add_registration_code("registerCameraClass();")

    include_files = set([cls.location.file_name for cls in classes])
    for cls in classes:
        include_files.update(cls.include_files)
    return ['wrappers/vision/include/RegisterFunctions.h'] + list(include_files)
Пример #16
0
def generate(module_builder, local_ns, global_ns):
    """
    global_ns: is the module builder for the entire library
    local_ns: is the namespace that coresponds to the given namespace
    """

    # Remove all those pesky warnings about only pointed to types!
    for cls in local_ns.decls(decl_type=decls_package.class_declaration_t):
        cls.include()
        cls.already_exposed = True

    module_builder.class_('::ram::core::EventPublisher').already_exposed = True
    module_builder.class_('::ram::core::IUpdatable').already_exposed = True

    wrappedClasses = []

    # Wrap IDevice Class
    IDevice = expose_device(local_ns, 'IDevice', register=False)
    wrappedClasses.append(IDevice)

    # Wrap the thruster class
    IThruster = expose_device(local_ns, 'IThruster')
    wrappedClasses.append(IThruster)

    # Wrap the IDepthSensor class
    IDepthSensor = expose_device(local_ns, 'IDepthSensor')
    wrappedClasses.append(IDepthSensor)

    # Wrap marker interfaces (slightly abuse expose device)
    IVoltageProvider = expose_device(local_ns,
                                     'IVoltageProvider',
                                     register=False)
    wrappedClasses.append(IVoltageProvider)
    ICurrentProvider = expose_device(local_ns,
                                     'ICurrentProvider',
                                     register=False)
    wrappedClasses.append(ICurrentProvider)

    # Wrap the IPowerSource class
    IPowerSource = expose_device(local_ns, 'IPowerSource')
    wrappedClasses.append(IPowerSource)

    # Wrap the ITempSensor class
    ITempSensor = expose_device(local_ns, 'ITempSensor')
    wrappedClasses.append(ITempSensor)

    # Wrap the IIMU class
    IIMU = expose_device(local_ns, 'IIMU')
    wrappedClasses.append(IIMU)

    # Wrap the ISonar class
    ISonar = expose_device(local_ns, 'ISonar')
    wrappedClasses.append(ISonar)

    # Wrap the IPayloadSet class
    IPayloadSet = expose_device(local_ns, 'IPayloadSet')
    wrappedClasses.append(IPayloadSet)

    # Wrap the IVelocitySensor class
    IVelocitySensor = expose_device(local_ns, 'IVelocitySensor')
    wrappedClasses.append(IVelocitySensor)

    # Wrap the IPositionSensor class
    IPositionSensor = expose_device(local_ns, 'IPositionSensor')
    wrappedClasses.append(IPositionSensor)

    # Wrap Events
    events = wrap.expose_events(local_ns)
    if events:
        module_builder.class_('::ram::core::Event').already_exposed = True
        classes += events

    module_builder.add_registration_code("registerIDeviceMakerClass();")
    module_builder.add_registration_code("registerIDevicePtrs();")
    wrap.add_needed_includes(wrappedClasses)

    include_files = set([cls.location.file_name for cls in wrappedClasses])
    for cls in wrappedClasses:
        include_files.update(cls.include_files)
    return [
        'wrappers/vehicle/include/RegisterFunctions.h', 'core/include/Event.h'
    ] + list(include_files)
Пример #17
0
def generate(module_builder, local_ns, global_ns):
    """
    local_ns: is the namespace that coresponds to the given namespace
    global_ns: is the module builder for the entire library
    """

    local_ns.exclude()
    classes = []

    # ConfigNode
    ConfigNode = local_ns.class_('ConfigNode')
    ConfigNode.include()
    ConfigNode.constructors().exclude()
    classes.append(ConfigNode)

    # Event Subsystem
    EventPublisher = expose_publisher(local_ns, 'EventPublisher')    
    EventPublisher.include_files.append('core/include/EventHub.h')

    # Apply return value policy
    lookupByName = EventPublisher.member_function('lookupByName')
    lookupByName.call_policies = \
        mod_builder.call_policies.return_value_policy(
            mod_builder.call_policies.manage_new_object)
    classes.append(EventPublisher)

    QueuedEventPublisher = expose_publisher(local_ns, 'QueuedEventPublisher')
    classes.append(QueuedEventPublisher)

    # EventConnection
    EventConnection = local_ns.class_('EventConnection')
    EventConnection.include()
    EventConnection.include_files.append('core/include/EventConnection.h')
    classes.append(EventConnection)

    # IUpdatable
    IUpdatable = local_ns.class_('IUpdatable')
    IUpdatable.include()
    classes.append(IUpdatable)

    # Application
    Application = local_ns.class_('Application')
    Application.include()

    # Replace getSubsystem with one which uses our converter
    Application.member_function('getSubsystem').exclude()
    Application.add_declaration_code("""
    boost::python::object pyGetSubsystem(ram::core::Application& app,
                                         std::string subsystemName)
    {
        ram::core::SubsystemPtr subsystem = app.getSubsystem(subsystemName);
        return ram::core::SubsystemConverter::convertObject(subsystem);
    }
    """)
    Application.add_registration_code(
        'def("getSubsystem", &::pyGetSubsystem)', works_on_instance = True )
    Application.include_files.append('core/include/SubsystemConverter.h')
    
    classes.append(Application)

    # Wrap Events
    Event = local_ns.class_('Event')
    Event.include()
    classes.append(Event)

    def filterFunc(val):
        return val.name.endswith('Event') and val.name != 'Event'
    events = wrap.expose_events(local_ns, filter_func = filterFunc)
    classes += events

    # Add registrations functions for hand wrapped classes
    module_builder.add_registration_code("registerSubsystemList();")
    module_builder.add_registration_code("registerSubsystemClass();")
    module_builder.add_registration_code("registerSubsystemMakerClass();")
    module_builder.add_registration_code("registerEventHubClass();")
    module_builder.add_registration_code("registerQueuedEventHubClass();")


    # Do class wide items
    wrap.set_implicit_conversions([Application, QueuedEventPublisher,
                                   EventPublisher], False)
    wrap.add_needed_includes(classes)

    include_files = set([cls.location.file_name for cls in classes])
    for cls in classes:
        include_files.update(cls.include_files)
    return ['wrappers/core/include/RegisterFunctions.h'] + list(include_files)
Пример #18
0
def generate(module_builder, local_ns, global_ns):
    """
    local_ns: is the namespace that coresponds to the given namespace
    global_ns: is the module builder for the entire library
    """

    local_ns.exclude()
    classes = []

    # ConfigNode
    ConfigNode = local_ns.class_('ConfigNode')
    ConfigNode.include()
    ConfigNode.constructors().exclude()
    classes.append(ConfigNode)

    # Event Subsystem
    EventPublisher = expose_publisher(local_ns, 'EventPublisher')
    EventPublisher.include_files.append('core/include/EventHub.h')

    # Apply return value policy
    lookupByName = EventPublisher.member_function('lookupByName')
    lookupByName.call_policies = \
        mod_builder.call_policies.return_value_policy(
            mod_builder.call_policies.manage_new_object)
    classes.append(EventPublisher)

    QueuedEventPublisher = expose_publisher(local_ns, 'QueuedEventPublisher')
    classes.append(QueuedEventPublisher)

    # EventConnection
    EventConnection = local_ns.class_('EventConnection')
    EventConnection.include()
    EventConnection.include_files.append('core/include/EventConnection.h')
    classes.append(EventConnection)

    # IUpdatable
    IUpdatable = local_ns.class_('IUpdatable')
    IUpdatable.include()
    classes.append(IUpdatable)

    # Application
    Application = local_ns.class_('Application')
    Application.include()

    # Replace getSubsystem with one which uses our converter
    Application.member_function('getSubsystem').exclude()
    Application.add_declaration_code("""
    boost::python::object pyGetSubsystem(ram::core::Application& app,
                                         std::string subsystemName)
    {
        ram::core::SubsystemPtr subsystem = app.getSubsystem(subsystemName);
        return ram::core::SubsystemConverter::convertObject(subsystem);
    }
    """)
    Application.add_registration_code('def("getSubsystem", &::pyGetSubsystem)',
                                      works_on_instance=True)
    Application.include_files.append('core/include/SubsystemConverter.h')

    classes.append(Application)

    # Wrap Events
    Event = local_ns.class_('Event')
    Event.include()
    classes.append(Event)

    def filterFunc(val):
        return val.name.endswith('Event') and val.name != 'Event'

    events = wrap.expose_events(local_ns, filter_func=filterFunc)
    classes += events

    # Add registrations functions for hand wrapped classes
    module_builder.add_registration_code("registerSubsystemList();")
    module_builder.add_registration_code("registerSubsystemClass();")
    module_builder.add_registration_code("registerSubsystemMakerClass();")
    module_builder.add_registration_code("registerEventHubClass();")
    module_builder.add_registration_code("registerQueuedEventHubClass();")

    # Do class wide items
    wrap.set_implicit_conversions(
        [Application, QueuedEventPublisher, EventPublisher], False)
    wrap.add_needed_includes(classes)

    include_files = set([cls.location.file_name for cls in classes])
    for cls in classes:
        include_files.update(cls.include_files)
    return ['wrappers/core/include/RegisterFunctions.h'] + list(include_files)
Пример #19
0
def generate(module_builder, local_ns, global_ns):
    """
    name: is the name of the module being wrapped (in name::space::form)
    global_ns: is the module builder for the entire library
    local_ns: is the namespace that coresponds to the given namespace
    """

    # Remove all those pesky warnings about only pointed to types!
    for cls in local_ns.decls(decl_type=decls_package.class_declaration_t):
        cls.include()
        cls.already_exposed = True

    module_builder.class_('::ram::core::Subsystem').already_exposed = True

    classes = []

    # Include IVehicle class and handle special cases
    IVehicle = local_ns.class_('IVehicle')
    IVehicle.include()
    classes.append(IVehicle)

    # Remove default wrapper for getDevice
    IVehicle.member_function('getDevice').exclude()

    # Provide the normal one by hand, so C++ users of python subclasses
    # still get the overridden method
    IVehicle.add_wrapper_code("""
    virtual ::ram::vehicle::device::IDevicePtr getDevice( ::std::string name ){
        bp::override func = this->get_override(\"getDevice\");
        return func( name);
    }
    """)

    # Provide a hand made implementation for Python users of C++ IVehicle
    # subclasses, this uses our custom converter to ensure proper IDevice
    # downcasting
    IVehicle.add_declaration_code("""
    boost::python::object pyGetDevice(
        ram::vehicle::IVehicle& veh,
        std::string deviceName)
    {
        ram::vehicle::device::IDevicePtr device =
            veh.getDevice(deviceName);
        return ram::vehicle::device::IDeviceConverter::convertObject(device);
    }
    """)
    IVehicle.add_registration_code("def(\"getDevice\", &::pyGetDevice)",
                                   works_on_instance=True)
    IVehicle.include_files.append('vehicle/include/device/IDeviceConverter.h')

    global_ns.typedef('TempNameList').type.declaration.already_exposed = True
    global_ns.typedef('TempList').include()

    # Fix TempNameList (the include does stick)
    t = global_ns.class_(
        function=lambda x: x.name.startswith('vector<std::string'))
    t.already_exposed = True

    # Fix overley long std::container names
    #wrap.mangle_container_names(local_ns)

    # Wrap Events
    events = wrap.expose_events(local_ns)
    if events:
        module_builder.class_('::ram::core::Event').already_exposed = True
        classes += events

    # Added the needed includes
    wrap.add_needed_includes(classes)
    IVehicle.include_files.append(os.environ['RAM_SVN_DIR'] +
                                  '/packages/vehicle/include/device/IDevice.h')

    # Add a castTo
    wrap.registerSubsystemConverter(IVehicle)

    module_builder.add_registration_code("registerIVehiclePtrs();")

    include_files = set([cls.location.file_name for cls in classes])
    for cls in classes:
        include_files.update(cls.include_files)
    return ['wrappers/vehicle/include/RegisterFunctions.h'
            ] + list(include_files)