Use ada_value_subscript in valpy_getitem

Ada has a few complexities when it comes to array handling.  Currently
these are all handled in Ada-specific code -- but unfortunately that
means they aren't really accessible to Python.

This patch changes the Python code to defer to Ada when given an Ada
array.  In order to make this work, one spot in ada-lang.c had to be
updated to set the "GNAT-specific" flag on an array type.

The test case for this will come in a later patch.
This commit is contained in:
Tom Tromey
2023-08-17 10:37:06 -06:00
parent dec28322cf
commit cf1eca3cbb
2 changed files with 4 additions and 0 deletions

View File

@ -28,6 +28,7 @@
#include "expression.h"
#include "cp-abi.h"
#include "python.h"
#include "ada-lang.h"
#include "python-internal.h"
@ -1096,6 +1097,8 @@ valpy_getitem (PyObject *self, PyObject *key)
if (type->code () != TYPE_CODE_ARRAY
&& type->code () != TYPE_CODE_PTR)
error (_("Cannot subscript requested type."));
else if (ADA_TYPE_P (type))
res_val = ada_value_subscript (tmp, 1, &idx);
else
res_val = value_subscript (tmp, value_as_long (idx));
}