Skip to content

Commit c5ae129

Browse files
committed
Added comments on nb::object returned sentinel return in try* functions
Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
1 parent 1200f9a commit c5ae129

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

nanovdb/nanovdb/python/PyCreateNanoGrid.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#include <cstring>
1515
#include <string>
16-
#include <vector>
1716

1817
namespace nb = nanobind;
1918
using namespace nb::literals;
@@ -107,6 +106,8 @@ nb::object tryQuantizeFpX(nb::handle py_src,
107106
}
108107
return nb::cast(std::move(handle));
109108
}
109+
// Invalid (not None) object signals "SrcBuildT didn't match"; the caller
110+
// tests is_valid() and falls through to the next SrcBuildT.
110111
return nb::object();
111112
}
112113

@@ -165,6 +166,8 @@ nb::object tryQuantizeFpN(nb::handle py_src,
165166
}
166167
return nb::cast(std::move(handle));
167168
}
169+
// Invalid (not None) object signals "SrcBuildT didn't match"; the caller
170+
// tests is_valid() and falls through to the next SrcBuildT.
168171
return nb::object();
169172
}
170173

@@ -220,6 +223,8 @@ nb::object tryIndexify(nb::handle py_src,
220223
}
221224
return nb::cast(std::move(handle));
222225
}
226+
// Invalid (not None) object signals "SrcBuildT didn't match"; the caller
227+
// tests is_valid() and falls through to the next SrcBuildT.
223228
return nb::object();
224229
}
225230

@@ -362,6 +367,8 @@ class PyCreateNanoGrid
362367
using BuildSrcT = tools::build::Grid<SrcBuildT>;
363368
if (nb::isinstance<NanoSrcT>(mSrc)) return this->bake(nb::cast<const NanoSrcT&>(mSrc));
364369
if (nb::isinstance<BuildSrcT>(mSrc)) return this->bake(nb::cast<const BuildSrcT&>(mSrc));
370+
// Invalid (not None) object signals "SrcBuildT didn't match"; the caller
371+
// tests is_valid() and falls through to the next SrcBuildT.
365372
return nb::object();
366373
}
367374

0 commit comments

Comments
 (0)