How to use the build.helper.metadata_find.find_size_parameter function in build

To help you get started, we’ve selected a few build 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 ni / nimi-python / build / helper / codegen_helper.py View on Github external
else:
        assert parameter['direction'] == 'out'
        if parameter['size']['mechanism'] == 'ivi-dance':
            if ivi_dance_step == IviDanceStep.QUERY_SIZE:
                definition = 'None  # case C050'
            elif ivi_dance_step == IviDanceStep.GET_DATA:
                size_parameter = find_size_parameter(parameter, parameters)
                definition = '({0}.ViChar * {1}.value)()  # case C060'.format(module_name, size_parameter['ctypes_variable_name'])
            else:
                assert False, "ivi_dance_step {0} not valid for parameter {1} with ['size']['mechanism'] == 'ivi-dance'".format(ivi_dance_step, parameter['name'])

        elif parameter['size']['mechanism'] == 'ivi-dance-with-a-twist':
            if ivi_dance_step == IviDanceStep.QUERY_SIZE:
                definition = 'None  # case C090'
            elif ivi_dance_step == IviDanceStep.GET_DATA:
                size_parameter = find_size_parameter(parameter, parameters, key='value_twist')
                definition = '({0}.ViChar * {1}.value)()  # case C100'.format(module_name, size_parameter['ctypes_variable_name'])
            else:
                assert False, "ivi_dance_step {0} not valid for parameter {1} with ['size']['mechanism'] == 'ivi-dance-with-a-twist'".format(ivi_dance_step, parameter['name'])

        elif parameter['size']['mechanism'] == 'fixed':
            assert parameter['size']['value'] != 1, "Parameter {0} has 'direction':'out' and 'size':{1}... seems wrong. Check your metadata, maybe you forgot to specify?".format(parameter['name'], parameter['size'])
            definition = '({0}.ViChar * {1})()  # case C070'.format(module_name, parameter['size']['value'])

        elif parameter['size']['mechanism'] == 'python-code':
            assert parameter['size']['value'] != 1, "Parameter {0} has 'direction':'out' and 'size':{1}... seems wrong. Check your metadata, maybe you forgot to specify?".format(parameter['name'], parameter['size'])
            definition = '({0}.ViChar * {1})()  # case C080'.format(module_name, parameter['size']['value'])

        else:
            assert False, "Invalid mechanism for parameters with 'direction':'out': " + str(parameter)

    if definition is not None:
github ni / nimi-python / build / helper / metadata_add_all.py View on Github external
def _add_numpy_info(parameter, parameters, config):
    '''Adds the following numpy-related information:

             numpy: Default to False unless already set. True for buffers that allow being passed as a numpy.ndarray.
        numpy_type: The name of the element type to use in the numpy.ndarray.
    '''

    if 'numpy' not in parameter:
        parameter['numpy'] = False

    if parameter['numpy']:
        parameter['numpy_type'] = get_numpy_type_for_api_type(parameter['type'], config)

        if parameter['size']['mechanism'] == 'passed-in':
            size_param = find_size_parameter(parameter, parameters)
            if size_param:
                size_param['use_in_python_api'] = False

    return parameter
github ni / nimi-python / build / helper / metadata_add_all.py View on Github external
def _add_use_in_python_api(p, parameters):
    '''Add 'use_in_python_api' if not there with value of True'''
    if 'use_in_python_api' not in p:
        p['use_in_python_api'] = True

    if p['size']['mechanism'] == 'len' or p['size']['mechanism'] == 'ivi-dance':
        size_param = find_size_parameter(p, parameters)
        size_param['use_in_python_api'] = False
github ni / nimi-python / build / helper / metadata_filters.py View on Github external
options_to_use = _ParameterUsageOptionsFiltering[parameter_usage_options]

    parameters_to_use = []

    # Filter based on options
    size_parameter = None
    size_twist_parameter = None
    # If we are being called looking for the ivi-dance, len or code param, we do not care about the size param so we do
    #  not call back into ourselves, to avoid infinite recursion
    if parameter_usage_options not in [ParameterUsageOptions.IVI_DANCE_PARAMETER, ParameterUsageOptions.LEN_PARAMETER]:
        # Find the size parameter - we are assuming there can only be one type, either from ivi-dance or len
        size_parameter = find_size_parameter(filter_ivi_dance_parameters(function), function['parameters'])
        if size_parameter is None:
            size_parameter = find_size_parameter(filter_len_parameters(function), function['parameters'])
        size_twist_parameter = find_size_parameter(filter_ivi_dance_twist_parameters(function), function['parameters'], key='value_twist')
    for x in function['parameters']:
        skip = False
        if x['direction'] == 'out' and options_to_use['skip_output_parameters']:
            skip = True
        if x['direction'] == 'in' and options_to_use['skip_input_parameters']:
            skip = True
        if x == size_parameter and options_to_use['skip_size_parameter']:
            skip = True
        if size_twist_parameter is not None and x == size_twist_parameter and options_to_use['skip_size_parameter']:
            skip = True
        if x['is_session_handle'] is True and options_to_use['skip_session_handle']:
            skip = True
        if x['is_repeated_capability'] is True and options_to_use['skip_repeated_capability_parameter']:
            skip = True
        if x['enum'] is None and options_to_use['skip_non_enum_parameter']:
            skip = True
github ni / nimi-python / build / helper / metadata_filters.py View on Github external
'''
    if type(parameter_usage_options) is not ParameterUsageOptions:
        raise TypeError('parameter_usage_options must be of type ' + str(ParameterUsageOptions))

    options_to_use = _ParameterUsageOptionsFiltering[parameter_usage_options]

    parameters_to_use = []

    # Filter based on options
    size_parameter = None
    size_twist_parameter = None
    # If we are being called looking for the ivi-dance, len or code param, we do not care about the size param so we do
    #  not call back into ourselves, to avoid infinite recursion
    if parameter_usage_options not in [ParameterUsageOptions.IVI_DANCE_PARAMETER, ParameterUsageOptions.LEN_PARAMETER]:
        # Find the size parameter - we are assuming there can only be one type, either from ivi-dance or len
        size_parameter = find_size_parameter(filter_ivi_dance_parameters(function), function['parameters'])
        if size_parameter is None:
            size_parameter = find_size_parameter(filter_len_parameters(function), function['parameters'])
        size_twist_parameter = find_size_parameter(filter_ivi_dance_twist_parameters(function), function['parameters'], key='value_twist')
    for x in function['parameters']:
        skip = False
        if x['direction'] == 'out' and options_to_use['skip_output_parameters']:
            skip = True
        if x['direction'] == 'in' and options_to_use['skip_input_parameters']:
            skip = True
        if x == size_parameter and options_to_use['skip_size_parameter']:
            skip = True
        if size_twist_parameter is not None and x == size_twist_parameter and options_to_use['skip_size_parameter']:
            skip = True
        if x['is_session_handle'] is True and options_to_use['skip_session_handle']:
            skip = True
        if x['is_repeated_capability'] is True and options_to_use['skip_repeated_capability_parameter']:
github ni / nimi-python / build / helper / metadata_add_all.py View on Github external
def _add_use_in_python_api(p, parameters):
    '''Add 'use_in_python_api' if not there with value of True'''
    if 'use_in_python_api' not in p:
        p['use_in_python_api'] = True

    if p['size']['mechanism'] == 'len' or p['size']['mechanism'] == 'ivi-dance':
        size_param = find_size_parameter(p, parameters)
        size_param['use_in_python_api'] = False

    if p['size']['mechanism'] == 'ivi-dance-with-a-twist':
        # We have two parameters to remove from the API
        size_param = find_size_parameter(p, parameters)
        size_param['use_in_python_api'] = False
        size_param = find_size_parameter(p, parameters, key='value_twist')
        size_param['use_in_python_api'] = False
github ni / nimi-python / build / helper / metadata_filters.py View on Github external
raise TypeError('parameter_usage_options must be of type ' + str(ParameterUsageOptions))

    options_to_use = _ParameterUsageOptionsFiltering[parameter_usage_options]

    parameters_to_use = []

    # Filter based on options
    size_parameter = None
    size_twist_parameter = None
    # If we are being called looking for the ivi-dance, len or code param, we do not care about the size param so we do
    #  not call back into ourselves, to avoid infinite recursion
    if parameter_usage_options not in [ParameterUsageOptions.IVI_DANCE_PARAMETER, ParameterUsageOptions.LEN_PARAMETER]:
        # Find the size parameter - we are assuming there can only be one type, either from ivi-dance or len
        size_parameter = find_size_parameter(filter_ivi_dance_parameters(function), function['parameters'])
        if size_parameter is None:
            size_parameter = find_size_parameter(filter_len_parameters(function), function['parameters'])
        size_twist_parameter = find_size_parameter(filter_ivi_dance_twist_parameters(function), function['parameters'], key='value_twist')
    for x in function['parameters']:
        skip = False
        if x['direction'] == 'out' and options_to_use['skip_output_parameters']:
            skip = True
        if x['direction'] == 'in' and options_to_use['skip_input_parameters']:
            skip = True
        if x == size_parameter and options_to_use['skip_size_parameter']:
            skip = True
        if size_twist_parameter is not None and x == size_twist_parameter and options_to_use['skip_size_parameter']:
            skip = True
        if x['is_session_handle'] is True and options_to_use['skip_session_handle']:
            skip = True
        if x['is_repeated_capability'] is True and options_to_use['skip_repeated_capability_parameter']:
            skip = True
        if x['enum'] is None and options_to_use['skip_non_enum_parameter']: