Skip to content

Commit bb87415

Browse files
committed
Refactor 'modsupport.c'.
1 parent 0d83127 commit bb87415

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

graalpython/com.oracle.graal.python.cext/src/modsupport.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,15 @@ typedef struct _positional_argstack {
4949
PyObject* PyTruffle_GetArg(positional_argstack* p, PyObject* kwds, char** kwdnames, unsigned char keywords_only) {
5050
void* out = NULL;
5151
if (!keywords_only) {
52-
int l = truffle_invoke_i(PY_TRUFFLE_CEXT, "PyObject_LEN", to_java(p->argv));
52+
int l = UPCALL_CEXT_I("PyObject_LEN", native_to_java(p->argv));
5353
if (p->argnum < l) {
5454
out = PyTuple_GetItem(p->argv, p->argnum);
5555
}
5656
}
5757
if (out == NULL && p->prev == NULL && kwdnames != NULL) { // only the bottom argstack can have keyword names
5858
const char* kwdname = kwdnames[p->argnum];
5959
if (kwdname != NULL) {
60-
PyObject *nameobj = to_sulong(truffle_read_string(kwdname));
61-
out = PyDict_GetItem(kwds, nameobj);
60+
out = PyDict_GetItemString(kwds, kwdname);
6261
}
6362
}
6463
(p->argnum)++;
@@ -328,7 +327,7 @@ int PyTruffle_Arg_ParseTupleAndKeywords(PyObject *argv, PyObject *kwds, const ch
328327
case 'p':
329328
arg = PyTruffle_GetArg(v, kwds, kwdnames, rest_keywords_only);
330329
PyTruffle_SkipOptionalArg(output_idx, arg, rest_optional);
331-
PyTruffle_WriteOut(output_idx, int, as_int(truffle_invoke(to_java(arg), "__bool__")));
330+
PyTruffle_WriteOut(output_idx, int, (UPCALL_I(native_to_java(arg), "__bool__")));
332331
break;
333332
case '(':
334333
arg = PyTruffle_GetArg(v, kwds, kwdnames, rest_keywords_only);
@@ -389,7 +388,7 @@ typedef struct _build_stack {
389388
} build_stack;
390389

391390
PyObject* _Py_BuildValue_SizeT(const char *format, ...) {
392-
# define ARG truffle_get_arg(value_idx)
391+
# define ARG polyglot_get_arg(value_idx)
393392
# define APPEND_VALUE(list, value) PyList_Append(list, value); value_idx++
394393

395394
PyObject* (*converter)(void*) = NULL;
@@ -409,7 +408,7 @@ PyObject* _Py_BuildValue_SizeT(const char *format, ...) {
409408
case 'z':
410409
case 'U':
411410
if (format[format_idx + 1] == '#') {
412-
int size = (int)truffle_get_arg(value_idx + 1);
411+
int size = (int)polyglot_get_arg(value_idx + 1);
413412
if (ARG == NULL) {
414413
APPEND_VALUE(list, Py_None);
415414
} else {
@@ -427,7 +426,7 @@ PyObject* _Py_BuildValue_SizeT(const char *format, ...) {
427426
break;
428427
case 'y':
429428
if (format[format_idx + 1] == '#') {
430-
int size = (int)truffle_get_arg(value_idx + 1);
429+
int size = (int)polyglot_get_arg(value_idx + 1);
431430
if (ARG == NULL) {
432431
APPEND_VALUE(list, Py_None);
433432
} else {
@@ -488,7 +487,7 @@ PyObject* _Py_BuildValue_SizeT(const char *format, ...) {
488487
break;
489488
case 'O':
490489
if (format[format_idx + 1] == '&') {
491-
converter = truffle_get_arg(value_idx + 1);
490+
converter = polyglot_get_arg(value_idx + 1);
492491
}
493492
case 'S':
494493
case 'N':

0 commit comments

Comments
 (0)