Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions UnityPyBoost/TypeTreeHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ inline PyObject *read_bool_array(ReaderT *reader, int32_t count)
{
if (reader->ptr + count > reader->end)
{
PyErr_SetString(PyExc_ValueError, "read_bool out of bounds");
PyErr_SetString(PyExc_ValueError, "read_bool_array out of bounds");
return NULL;
}
PyObject *list = PyList_New(count);
Expand All @@ -114,7 +114,7 @@ inline PyObject *read_u8_array(ReaderT *reader, int32_t count)
{
if (reader->ptr + count > reader->end)
{
PyErr_SetString(PyExc_ValueError, "read_u8 out of bounds");
PyErr_SetString(PyExc_ValueError, "read_u8_array out of bounds");
return NULL;
}
PyObject *list = PyList_New(count);
Expand All @@ -139,7 +139,7 @@ inline PyObject *read_s8_array(ReaderT *reader, int32_t count)
{
if (reader->ptr + count > reader->end)
{
PyErr_SetString(PyExc_ValueError, "read_s8 out of bounds");
PyErr_SetString(PyExc_ValueError, "read_s8_array out of bounds");
return NULL;
}
PyObject *list = PyList_New(count);
Expand All @@ -159,7 +159,8 @@ inline PyObject *read_num(ReaderT *reader)

if (reader->ptr + sizeof(T) > reader->end)
{
return PyErr_Format(PyExc_ValueError, "read_%s out of bounds", typeid(T).name());
PyErr_Format(PyExc_ValueError, "read_%s out of bounds", typeid(T).name());
return nullptr;
}
T value = *(T *)reader->ptr;
if constexpr (swap)
Expand Down Expand Up @@ -206,7 +207,8 @@ inline PyObject *read_num_array(ReaderT *reader, int32_t count)

if (reader->ptr + sizeof(T) * count > reader->end)
{
return PyErr_Format(PyExc_ValueError, "read_%s_array out of bounds", typeid(T).name());
PyErr_Format(PyExc_ValueError, "read_%s_array out of bounds", typeid(T).name());
return nullptr;
}
PyObject *list = PyList_New(count);
T *ptr = (T *)reader->ptr;
Expand Down Expand Up @@ -355,6 +357,10 @@ inline PyObject *read_pair_array(ReaderT *reader, TypeTreeNodeObject *node, Type
TypeTreeNodeObject *second_child = (TypeTreeNodeObject *)PyList_GET_ITEM(node->m_Children, 1);

PyObject *list = PyList_New(count);
if (list == NULL)
{
return NULL;
}
for (auto i = 0; i < count; i++)
{
PyObject *first = read_typetree_value<swap>(reader, first_child, config);
Expand Down Expand Up @@ -827,6 +833,10 @@ PyObject *read_typetree_value(ReaderT *reader, TypeTreeNodeObject *node, TypeTre
if (std::find(std::begin(SUPPORTED_VALUE_ARRAY_READ_TYPES), std::end(SUPPORTED_VALUE_ARRAY_READ_TYPES), child->_data_type) == std::end(SUPPORTED_VALUE_ARRAY_READ_TYPES))
{
value = PyList_New(length);
if (value == NULL)
{
return NULL;
}
for (int i = 0; i < length; i++)
{
PyObject *item = read_typetree_value<swap>(reader, child, config);
Expand Down Expand Up @@ -911,7 +921,8 @@ PyObject *read_typetree_value_array(ReaderT *reader, TypeTreeNodeObject *node, T
value = read_pair_array<swap>(reader, node, config, count);
break;
default:
value = PyErr_Format(PyExc_ValueError, "Unsupported type for read_typetree_value_array: %d", node->_data_type);
PyErr_Format(PyExc_ValueError, "Unsupported type for read_typetree_value_array: %d", node->_data_type);
value = nullptr;
}
if (align && value != NULL)
{
Expand Down