| 2024 | } |
| 2025 | |
| 2026 | void ImGui::DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, const void* arg1, const void* arg2) |
| 2027 | { |
| 2028 | IM_ASSERT(op == '+' || op == '-'); |
| 2029 | switch (data_type) |
| 2030 | { |
| 2031 | case ImGuiDataType_S8: |
| 2032 | if (op == '+') { *(ImS8*)output = ImAddClampOverflow(*(const ImS8*)arg1, *(const ImS8*)arg2, IM_S8_MIN, IM_S8_MAX); } |
| 2033 | if (op == '-') { *(ImS8*)output = ImSubClampOverflow(*(const ImS8*)arg1, *(const ImS8*)arg2, IM_S8_MIN, IM_S8_MAX); } |
| 2034 | return; |
| 2035 | case ImGuiDataType_U8: |
| 2036 | if (op == '+') { *(ImU8*)output = ImAddClampOverflow(*(const ImU8*)arg1, *(const ImU8*)arg2, IM_U8_MIN, IM_U8_MAX); } |
| 2037 | if (op == '-') { *(ImU8*)output = ImSubClampOverflow(*(const ImU8*)arg1, *(const ImU8*)arg2, IM_U8_MIN, IM_U8_MAX); } |
| 2038 | return; |
| 2039 | case ImGuiDataType_S16: |
| 2040 | if (op == '+') { *(ImS16*)output = ImAddClampOverflow(*(const ImS16*)arg1, *(const ImS16*)arg2, IM_S16_MIN, IM_S16_MAX); } |
| 2041 | if (op == '-') { *(ImS16*)output = ImSubClampOverflow(*(const ImS16*)arg1, *(const ImS16*)arg2, IM_S16_MIN, IM_S16_MAX); } |
| 2042 | return; |
| 2043 | case ImGuiDataType_U16: |
| 2044 | if (op == '+') { *(ImU16*)output = ImAddClampOverflow(*(const ImU16*)arg1, *(const ImU16*)arg2, IM_U16_MIN, IM_U16_MAX); } |
| 2045 | if (op == '-') { *(ImU16*)output = ImSubClampOverflow(*(const ImU16*)arg1, *(const ImU16*)arg2, IM_U16_MIN, IM_U16_MAX); } |
| 2046 | return; |
| 2047 | case ImGuiDataType_S32: |
| 2048 | if (op == '+') { *(ImS32*)output = ImAddClampOverflow(*(const ImS32*)arg1, *(const ImS32*)arg2, IM_S32_MIN, IM_S32_MAX); } |
| 2049 | if (op == '-') { *(ImS32*)output = ImSubClampOverflow(*(const ImS32*)arg1, *(const ImS32*)arg2, IM_S32_MIN, IM_S32_MAX); } |
| 2050 | return; |
| 2051 | case ImGuiDataType_U32: |
| 2052 | if (op == '+') { *(ImU32*)output = ImAddClampOverflow(*(const ImU32*)arg1, *(const ImU32*)arg2, IM_U32_MIN, IM_U32_MAX); } |
| 2053 | if (op == '-') { *(ImU32*)output = ImSubClampOverflow(*(const ImU32*)arg1, *(const ImU32*)arg2, IM_U32_MIN, IM_U32_MAX); } |
| 2054 | return; |
| 2055 | case ImGuiDataType_S64: |
| 2056 | if (op == '+') { *(ImS64*)output = ImAddClampOverflow(*(const ImS64*)arg1, *(const ImS64*)arg2, IM_S64_MIN, IM_S64_MAX); } |
| 2057 | if (op == '-') { *(ImS64*)output = ImSubClampOverflow(*(const ImS64*)arg1, *(const ImS64*)arg2, IM_S64_MIN, IM_S64_MAX); } |
| 2058 | return; |
| 2059 | case ImGuiDataType_U64: |
| 2060 | if (op == '+') { *(ImU64*)output = ImAddClampOverflow(*(const ImU64*)arg1, *(const ImU64*)arg2, IM_U64_MIN, IM_U64_MAX); } |
| 2061 | if (op == '-') { *(ImU64*)output = ImSubClampOverflow(*(const ImU64*)arg1, *(const ImU64*)arg2, IM_U64_MIN, IM_U64_MAX); } |
| 2062 | return; |
| 2063 | case ImGuiDataType_Float: |
| 2064 | if (op == '+') { *(float*)output = *(const float*)arg1 + *(const float*)arg2; } |
| 2065 | if (op == '-') { *(float*)output = *(const float*)arg1 - *(const float*)arg2; } |
| 2066 | return; |
| 2067 | case ImGuiDataType_Double: |
| 2068 | if (op == '+') { *(double*)output = *(const double*)arg1 + *(const double*)arg2; } |
| 2069 | if (op == '-') { *(double*)output = *(const double*)arg1 - *(const double*)arg2; } |
| 2070 | return; |
| 2071 | case ImGuiDataType_COUNT: break; |
| 2072 | } |
| 2073 | IM_ASSERT(0); |
| 2074 | } |
| 2075 | |
| 2076 | // User can input math operators (e.g. +100) to edit a numerical values. |
| 2077 | // NB: This is _not_ a full expression evaluator. We should probably add one and replace this dumb mess.. |
nothing calls this directly
no test coverage detected