diff --git a/PyGLM/internal_functions/ctypes_pointers.h b/PyGLM/internal_functions/ctypes_pointers.h index a75495a..c44c4f0 100644 --- a/PyGLM/internal_functions/ctypes_pointers.h +++ b/PyGLM/internal_functions/ctypes_pointers.h @@ -137,8 +137,10 @@ static PyObject* PyGLM_ToCtypesP(bool* ptr) { Py_DECREF(ptr_as_c_void_p); return out; } +/* static PyObject* PyGLM_ToCtypesP(void* ptr) { PyObject* ptr_as_c_void_p = PyGLM_CtypesVoidP_FromVoidP(ptr); return ptr_as_c_void_p; } +*/ #endif \ No newline at end of file diff --git a/PyGLM/internal_functions/number_functions.h b/PyGLM/internal_functions/number_functions.h index 31d85b7..1d53e0a 100644 --- a/PyGLM/internal_functions/number_functions.h +++ b/PyGLM/internal_functions/number_functions.h @@ -39,6 +39,7 @@ static unsigned long PyLong_AsUnsignedLongAndOverflow(PyObject* arg, int* overfl return out; } +/* static unsigned long long PyLong_AsUnsignedLongLongAndOverflow(PyObject* arg, int* overflow) { unsigned long long out = PyLong_AsUnsignedLongLong(arg); if (PyErr_Occurred()) { @@ -50,6 +51,7 @@ static unsigned long long PyLong_AsUnsignedLongLongAndOverflow(PyObject* arg, in } return out; } +*/ static int PyLong_Sign(PyObject* arg) { int overflow; diff --git a/PyGLM/internal_functions/type_checkers.h b/PyGLM/internal_functions/type_checkers.h index e288ae9..2e675bd 100644 --- a/PyGLM/internal_functions/type_checkers.h +++ b/PyGLM/internal_functions/type_checkers.h @@ -52,7 +52,7 @@ static bool get_py_buffer(PyObject* arg, Py_buffer* out) { bool buffer_found = false; - for (int i = 0; i < sizeof(accepted_buffer_flags) / sizeof(int); i++) { + for (size_t i = 0; i < sizeof(accepted_buffer_flags) / sizeof(int); i++) { if (PyObject_GetBuffer(arg, out, accepted_buffer_flags[i]) == -1) { PyErr_Clear(); } else { @@ -147,7 +147,7 @@ static _FormatType getFormatType(char* format) { if (format == NULL) { return _FormatType::UINT8; } - if (format[0] == '=' || is_big_endian() && format[0] == '>' || !is_big_endian() && format[0] == '<' || is_big_endian() && format[0] == '!') { + if (format[0] == '=' || (is_big_endian() && format[0] == '>') || (!is_big_endian() && format[0] == '<') || (is_big_endian() && format[0] == '!')) { switch(format[1]) { case 'b': return _FormatType::INT8; @@ -183,7 +183,7 @@ static _FormatType getFormatType(char* format) { } } - if (!is_big_endian() && format[0] == '>' || is_big_endian() && format[0] == '<' || !is_big_endian() && format[0] == '!') { + if ((!is_big_endian() && format[0] == '>') || (is_big_endian() && format[0] == '<') || (!is_big_endian() && format[0] == '!')) { return _FormatType::NONE; } diff --git a/PyGLM/type_methods/glmArray.h b/PyGLM/type_methods/glmArray.h index bc785a4..75a2c76 100644 --- a/PyGLM/type_methods/glmArray.h +++ b/PyGLM/type_methods/glmArray.h @@ -5072,6 +5072,15 @@ static PyObject* glmArray_sub(PyObject* obj1, PyObject* obj2) { return NULL; } +template +static inline T glmArray_simple_mul(T a, T b) { + return a * b; +} + +static inline bool glmArray_simple_mul(bool a, bool b) { + return a && b; +} + template static PyObject* glmArray_mul_T_SEQ(glmArray* arr1, glmArray* arr2) { glmArray* outArray = (glmArray*)glmArray_new(&glmArrayType, NULL, NULL); @@ -5118,7 +5127,7 @@ static PyObject* glmArray_mul_T_SEQ(glmArray* arr1, glmArray* arr2) { Py_ssize_t arr2Ratio = arr2->itemSize / outArray->dtSize; for (Py_ssize_t j = 0; j < outArrayRatio; j++) { - outArrayDataPtr[outArrayIndex++] = arr1DataPtr[i * arr1Ratio + (j % arr1Ratio)] * arr2DataPtr[i * arr2Ratio + (j % arr2Ratio)]; + outArrayDataPtr[outArrayIndex++] = glmArray_simple_mul(arr1DataPtr[i * arr1Ratio + (j % arr1Ratio)], arr2DataPtr[i * arr2Ratio + (j % arr2Ratio)]); } } @@ -5241,7 +5250,7 @@ static PyObject* glmArray_mulO_T(glmArray* arr, T* o, Py_ssize_t o_size, PyGLMTy for (Py_ssize_t i = 0; i < outArray->itemCount; i++) { for (Py_ssize_t j = 0; j < outArrayRatio; j++) { - outArrayDataPtr[outArrayIndex++] = arrDataPtr[i * arrRatio + (j % arrRatio)] * o[j % o_size]; + outArrayDataPtr[outArrayIndex++] = glmArray_simple_mul(arrDataPtr[i * arrRatio + (j % arrRatio)], o[j % o_size]); } } @@ -5273,7 +5282,7 @@ static PyObject* glmArray_mulO_T(glmArray* arr, T* o, Py_ssize_t o_size, PyGLMTy for (Py_ssize_t i = 0; i < outArray->itemCount; i++) { for (Py_ssize_t j = 0; j < outArrayRatio; j++) { - outArrayDataPtr[outArrayIndex++] = arrDataPtr[i * arrRatio + (j % arrRatio)] * o[j % o_size]; + outArrayDataPtr[outArrayIndex++] = glmArray_simple_mul(arrDataPtr[i * arrRatio + (j % arrRatio)], o[j % o_size]); } }