| 1860 | } |
| 1861 | |
| 1862 | s32 parse_conditional_states(RenderState &rs, const char *json) |
| 1863 | { |
| 1864 | // gui = { |
| 1865 | // states = { <-- You are here. |
| 1866 | // } |
| 1867 | // ... |
| 1868 | // } |
| 1869 | // |
| 1870 | // Possible cases: |
| 1871 | // a) "some_expr" = { state_a = b, state_b = c, ... } |
| 1872 | // b) state_x = y |
| 1873 | // Ignore, this is handled by parse_states(). |
| 1874 | |
| 1875 | TempAllocator4096 ta; |
| 1876 | JsonObject obj(ta); |
| 1877 | RETURN_IF_ERROR(sjson::parse_object(obj, json)); |
| 1878 | |
| 1879 | // Read conditional states. |
| 1880 | auto cur = json_object::begin(obj); |
| 1881 | auto end = json_object::end(obj); |
| 1882 | for (; cur != end; ++cur) { |
| 1883 | JSON_OBJECT_SKIP_HOLE(obj, cur); |
| 1884 | |
| 1885 | if (sjson::type(cur->second) == JsonValueType::OBJECT) { |
| 1886 | // It must be a conditional expression: "expr()" = { ... } |
| 1887 | RenderState::State states; |
| 1888 | s32 err = parse_states(states, cur->second); |
| 1889 | ENSURE_OR_RETURN(SHADER_RESOURCE, err == 0, _opts); |
| 1890 | |
| 1891 | DynamicString expr(default_allocator()); |
| 1892 | expr = cur->first; |
| 1893 | // Use cur->first.data() as sort key so we can sort states |
| 1894 | // by the order they appear in the source file. |
| 1895 | rs.push_back_states(expr |
| 1896 | , states |
| 1897 | , (uintptr_t)(void *)cur->first.data() |
| 1898 | ); |
| 1899 | } |
| 1900 | } |
| 1901 | |
| 1902 | return 0; |
| 1903 | } |
| 1904 | |
| 1905 | s32 parse_render_state(RenderState &rs, const char *json) |
| 1906 | { |
nothing calls this directly
no test coverage detected