Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions build/helper/codegen_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def _get_ctype_variable_definition_snippet_for_scalar(parameter, parameters, ivi
S120. Input is size of buffer with mechanism is python-code: visatype.ViInt32(<custom python code>)
S130. Input enum: visatype.ViInt32(parameter_name.value)
S150. Input scalar: visatype.ViInt32(parameter_name)
S160. Input is size of input buffer: visatype.ViInt32(0 if list is None else len(list))
S160. Input is size of input buffer: visatype.ViInt32(0 if list is None else len(list)) or visatype.ViInt32(0 if array is None else array.size)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ni-jfitzger , should we add a new code for this case?

Copy link
Collaborator

@ni-jfitzger ni-jfitzger Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to this discussion thread.

S170. Input is size of output buffer with mechanism ivi-dance, QUERY_SIZE: visatype.ViInt32()
S180. Input is size of output buffer with mechanism ivi-dance, GET_DATA: visatype.ViInt32(error_code)
S190. Input is size of output buffer with mechanism ivi-dance-with-a-twist, QUERY_SIZE: visatype.ViInt32()
Expand Down Expand Up @@ -371,7 +371,11 @@ def _get_ctype_variable_definition_snippet_for_scalar(parameter, parameters, ivi
if corresponding_buffer_parameters[0].get('complex_array_representation') == 'interleaved_real_number_array':
definitions.append(parameter['ctypes_variable_name'] + ' = {0}.{1}(0 if {2} is None else len({2}) // 2) # case S160'.format(module_name, parameter['ctypes_type'], corresponding_buffer_parameters[0]['python_name']))
else:
definitions.append(parameter['ctypes_variable_name'] + ' = {0}.{1}(0 if {2} is None else len({2})) # case S160'.format(module_name, parameter['ctypes_type'], corresponding_buffer_parameters[0]['python_name']))
array_dimensions = corresponding_buffer_parameters[0].get('array_dimensions')
if isinstance(array_dimensions, int) and array_dimensions > 1:
definitions.append(parameter['ctypes_variable_name'] + ' = {0}.{1}(0 if {2} is None else {2}.size) # case S160'.format(module_name, parameter['ctypes_type'], corresponding_buffer_parameters[0]['python_name']))
else:
definitions.append(parameter['ctypes_variable_name'] + ' = {0}.{1}(0 if {2} is None else len({2})) # case S160'.format(module_name, parameter['ctypes_type'], corresponding_buffer_parameters[0]['python_name']))
else:
if corresponding_buffer_parameters[0]['size']['mechanism'] == 'ivi-dance': # We are only looking at the first one. Assumes all are the same here, assert below if not
# Verify all corresponding_buffer_parameters are 'out' and 'ivi-dance'
Expand Down
8 changes: 8 additions & 0 deletions build/unit_tests/test_codegen_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,14 @@ def test_get_ctype_variable_declaration_snippet_case_s160():
assert actual == ["input_array_size_ctype = _visatype.ViInt32(0 if input_array is None else len(input_array)) # case S160"]


def test_get_ctype_variable_declaration_snippet_case_s160_multidimensional_array():
size_parameter = parameters_for_testing[11]
buffer_parameter = dict(parameters_for_testing[10])
buffer_parameter['array_dimensions'] = 3
snippet = get_ctype_variable_declaration_snippet(size_parameter, [size_parameter, buffer_parameter], IviDanceStep.NOT_APPLICABLE, config_for_testing, use_numpy_array=False)
assert snippet == ["input_array_size_ctype = _visatype.ViInt32(0 if input_array is None else input_array.size) # case S160"]


def test_get_ctype_variable_declaration_snippet_case_s170():
snippet = get_ctype_variable_declaration_snippet(parameters_for_testing[12], parameters_for_testing, IviDanceStep.QUERY_SIZE, config_for_testing, use_numpy_array=False)
assert snippet == ["string_size_ctype = _visatype.ViInt32() # case S170"]
Expand Down