Skip to content

Commit

Permalink
address windows-related compilation errors/warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wjakob committed Oct 27, 2022
1 parent de942cd commit bd328d4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/python/vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ auto register_vector_type(nb::module_ &m, const char *name) {
.def(nb::init<const Array &>())
.def("__init__", [](Array &a, const std::array<Value, Size> &arr) {
new (&a) Array();
for (size_t i = 0; i < Size; ++i)
for (size_t i = 0; i < Array::Size; ++i)
a[i] = arr[i];
})
.def(nb::self == nb::self)
Expand All @@ -40,13 +40,13 @@ auto register_vector_type(nb::module_ &m, const char *name) {
.def(nb::self -= nb::self)
.def(nb::self *= nb::self)
.def(nb::self /= nb::self)
.def("__getitem__", [Size](const Array &a, size_t index) -> Value {
if (index >= Size)
.def("__getitem__", [](const Array &a, size_t index) -> Value {
if (index >= Array::Size)
throw nb::index_error();
return a[index];
}, "index"_a)
.def("__setitem__", [Size](Array &a, size_t index, Value value) {
if (index >= Size)
.def("__setitem__", [](Array &a, size_t index, Value value) {
if (index >= Array::Size)
throw nb::index_error();
a[index] = value;
}, "index"_a, "value"_a)
Expand All @@ -56,7 +56,7 @@ auto register_vector_type(nb::module_ &m, const char *name) {
[](Array &a, const Value &v) { a.y() = v; })
.def("__dlpack__", [](nb::handle_t<Array> self) {
const Array &a = nb::cast<const Array &>(self);
const size_t shape[1] = { Size };
const size_t shape[1] = { Array::Size };
return nb::tensor<float>((void *) a.data(), 1, shape, self);
})
.def("__repr__", [](const Array &a) {
Expand Down
12 changes: 6 additions & 6 deletions src/python/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ int widget_tp_traverse_base(PyObject *self, visitproc visit, void *arg, PyTypeOb
continue;

PyObject *args[] = { self };
PyObject *value = PyObject_VectorcallMethod(
PyObject *result = PyObject_VectorcallMethod(
key, args, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, nullptr);

if (!value) {
if (!result) {
PyErr_Clear();
continue;
}

Py_VISIT(value);
Py_DECREF(value);
Py_VISIT(result);
Py_DECREF(result);
}

if (strcmp(tp->tp_name, "nanogui.Widget") != 0) {
Expand Down Expand Up @@ -73,8 +73,8 @@ int widget_tp_traverse(PyObject *self, visitproc visit, void *arg) {
int widget_tp_clear(PyObject *self) {
Widget *w = nb::inst_ptr<Widget>(self);

size_t count = w->child_count();
for (size_t i = 0; i < count; ++i)
int count = w->child_count();
for (int i = 0; i < count; ++i)
w->remove_child_at(count - 1 - i);

return 0;
Expand Down

0 comments on commit bd328d4

Please sign in to comment.