Skip to content

Commit 09d4db4

Browse files
committed
Apparently the python loaderer was broken although I commited the changes.
1 parent 7567336 commit 09d4db4

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

source/loaders/py_loader/source/py_loader_impl.c

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,13 @@ int py_object_interface_create(object obj, object_impl impl)
365365
}
366366

367367
/* TODO: get and set is actually the same as static_get and static_set but applied to an object instead of a class */
368-
value py_object_interface_get(object obj, object_impl impl, attribute attr)
368+
value py_object_interface_get(object obj, object_impl impl, struct accessor_type *accessor)
369369
{
370370
(void)obj;
371371

372372
loader_impl_py_object py_object = (loader_impl_py_object)impl;
373-
374373
PyObject *pyobject_object = py_object->obj;
375-
376-
PyObject *key_py_str = PyUnicode_FromString(attribute_name(attr));
374+
PyObject *key_py_str = PyUnicode_FromString(attribute_name(accessor->data.attr));
377375
PyObject *generic_attr = PyObject_GenericGetAttr(pyobject_object, key_py_str);
378376
Py_XDECREF(key_py_str);
379377

@@ -383,18 +381,14 @@ value py_object_interface_get(object obj, object_impl impl, attribute attr)
383381
return v;
384382
}
385383

386-
int py_object_interface_set(object obj, object_impl impl, attribute attr, value v)
384+
int py_object_interface_set(object obj, object_impl impl, struct accessor_type *accessor, value v)
387385
{
388386
(void)obj;
389387

390388
loader_impl_py_object py_object = (loader_impl_py_object)impl;
391-
392389
PyObject *pyobject_object = py_object->obj;
393-
394-
PyObject *key_py_str = PyUnicode_FromString(attribute_name(attr));
395-
390+
PyObject *key_py_str = PyUnicode_FromString(attribute_name(accessor->data.attr));
396391
PyObject *pyvalue = py_loader_impl_value_to_capi(py_object->impl, value_type_id(v), v);
397-
398392
int retval = PyObject_GenericSetAttr(pyobject_object, key_py_str, pyvalue);
399393

400394
Py_DECREF(key_py_str);
@@ -521,7 +515,7 @@ object py_class_interface_constructor(klass cls, class_impl impl, const char *na
521515

522516
loader_impl_py_object py_obj = malloc(sizeof(struct loader_impl_py_object_type));
523517

524-
object obj = object_create(name, py_obj, &py_object_interface_singleton, cls);
518+
object obj = object_create(name, ACCESSOR_TYPE_STATIC, py_obj, &py_object_interface_singleton, cls);
525519

526520
if (obj == NULL)
527521
{
@@ -559,15 +553,14 @@ object py_class_interface_constructor(klass cls, class_impl impl, const char *na
559553
return obj;
560554
}
561555

562-
value py_class_interface_static_get(klass cls, class_impl impl, attribute attr)
556+
value py_class_interface_static_get(klass cls, class_impl impl, struct accessor_type *accessor)
563557
{
564558
(void)cls;
565559

566560
loader_impl_py_class py_class = (loader_impl_py_class)impl;
567-
568561
PyObject *pyobject_class = py_class->cls;
562+
char *attr_name = attribute_name(accessor->data.attr);
569563

570-
char *attr_name = attribute_name(attr);
571564
if (attr_name == NULL)
572565
{
573566
return NULL;
@@ -583,24 +576,21 @@ value py_class_interface_static_get(klass cls, class_impl impl, attribute attr)
583576
return v;
584577
}
585578

586-
int py_class_interface_static_set(klass cls, class_impl impl, attribute attr, value v)
579+
int py_class_interface_static_set(klass cls, class_impl impl, struct accessor_type *accessor, value v)
587580
{
588581
(void)cls;
589582

590583
loader_impl_py_class py_class = (loader_impl_py_class)impl;
591-
592584
PyObject *pyobject_class = py_class->cls;
593-
594585
PyObject *pyvalue = py_loader_impl_value_to_capi(py_class->impl, value_type_id(v), v);
586+
char *attr_name = attribute_name(accessor->data.attr);
595587

596-
char *attr_name = attribute_name(attr);
597588
if (attr_name == NULL)
598589
{
599590
return 1;
600591
}
601592

602593
PyObject *key_py_str = PyUnicode_FromString(attr_name);
603-
604594
int retval = PyObject_GenericSetAttr(pyobject_class, key_py_str, pyvalue);
605595

606596
Py_DECREF(key_py_str);
@@ -1078,7 +1068,7 @@ value py_loader_impl_capi_to_value(loader_impl impl, PyObject *obj, type_id id)
10781068
Py_INCREF(obj);
10791069

10801070
PyObject *qualname = PyObject_GetAttrString(obj, "__qualname__");
1081-
klass c = class_create(PyUnicode_AsUTF8(qualname), py_cls, &py_class_interface_singleton);
1071+
klass c = class_create(PyUnicode_AsUTF8(qualname), ACCESSOR_TYPE_STATIC, py_cls, &py_class_interface_singleton);
10821072
Py_XDECREF(qualname);
10831073

10841074
py_cls->impl = impl;
@@ -1108,7 +1098,7 @@ value py_loader_impl_capi_to_value(loader_impl impl, PyObject *obj, type_id id)
11081098
/* Not using class_new() here because the object is already instantiated in the runtime */
11091099
/* So we must avoid calling it's constructor again */
11101100
PyObject *repr = PyObject_Repr(obj);
1111-
object o = object_create(PyUnicode_AsUTF8(repr), py_obj, &py_object_interface_singleton, value_to_class(obj_cls));
1101+
object o = object_create(PyUnicode_AsUTF8(repr), ACCESSOR_TYPE_STATIC, py_obj, &py_object_interface_singleton, value_to_class(obj_cls));
11121102
Py_XDECREF(repr);
11131103

11141104
py_obj->impl = impl;
@@ -3571,7 +3561,7 @@ int py_loader_impl_discover_module(loader_impl impl, PyObject *module, context c
35713561

35723562
Py_INCREF(module_dict_val);
35733563

3574-
klass c = class_create(cls_name, py_cls, &py_class_interface_singleton);
3564+
klass c = class_create(cls_name, ACCESSOR_TYPE_STATIC, py_cls, &py_class_interface_singleton);
35753565

35763566
py_cls->impl = impl;
35773567
py_cls->cls = module_dict_val;
@@ -3823,4 +3813,3 @@ int py_loader_impl_destroy(loader_impl impl)
38233813

38243814
return result;
38253815
}
3826-

0 commit comments

Comments
 (0)