Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "const correctness in public API" #728

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
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
203 changes: 106 additions & 97 deletions nuklear.h

Large diffs are not rendered by default.

92 changes: 46 additions & 46 deletions src/nuklear.h

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/nuklear_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ nk_buffer_free(struct nk_buffer *b)
b->pool.free(b->pool.userdata, b->memory.ptr);
}
NK_API void
nk_buffer_info(struct nk_memory_status *s, const struct nk_buffer *b)
nk_buffer_info(struct nk_memory_status *s, struct nk_buffer *b)
{
NK_ASSERT(b);
NK_ASSERT(s);
Expand All @@ -268,9 +268,10 @@ nk_buffer_memory_const(const struct nk_buffer *buffer)
return buffer->memory.ptr;
}
NK_API nk_size
nk_buffer_total(const struct nk_buffer *buffer)
nk_buffer_total(struct nk_buffer *buffer)
{
NK_ASSERT(buffer);
if (!buffer) return 0;
return buffer->memory.size;
}

5 changes: 3 additions & 2 deletions src/nuklear_color.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ nk_parse_hex(const char *p, int length)
return i;
}
NK_API struct nk_color
nk_rgb_factor(struct nk_color col, float factor)
nk_rgb_factor(struct nk_color col, const float factor)
{
if (factor == 1.0f)
return col;
Expand Down Expand Up @@ -246,7 +246,7 @@ nk_hsva_colorf(float h, float s, float v, float a)
return out;
}
NK_API struct nk_colorf
nk_hsva_colorfv(const float *c)
nk_hsva_colorfv(float *c)
{
return nk_hsva_colorf(c[0], c[1], c[2], c[3]);
}
Expand Down Expand Up @@ -421,3 +421,4 @@ nk_color_hsv_bv(nk_byte *out, struct nk_color in)
out[1] = (nk_byte)tmp[1];
out[2] = (nk_byte)tmp[2];
}

5 changes: 3 additions & 2 deletions src/nuklear_combo.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ NK_API void nk_combo_close(struct nk_context *ctx)
nk_contextual_close(ctx);
}
NK_API int
nk_combo(struct nk_context *ctx, const char *const *items, int count,
nk_combo(struct nk_context *ctx, const char **items, int count,
int selected, int item_height, struct nk_vec2 size)
{
int i = 0;
Expand Down Expand Up @@ -820,7 +820,7 @@ nk_combo_callback(struct nk_context *ctx, void(*item_getter)(void*, int, const c
} return selected;
}
NK_API void
nk_combobox(struct nk_context *ctx, const char *const *items, int count,
nk_combobox(struct nk_context *ctx, const char **items, int count,
int *selected, int item_height, struct nk_vec2 size)
{
*selected = nk_combo(ctx, items, count, *selected, item_height, size);
Expand All @@ -845,3 +845,4 @@ nk_combobox_callback(struct nk_context *ctx,
{
*selected = nk_combo_callback(ctx, item_getter, userdata, *selected, count, item_height, size);
}

7 changes: 4 additions & 3 deletions src/nuklear_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ nk_fill_triangle(struct nk_command_buffer *b, float x0, float y0, float x1,
cmd->color = c;
}
NK_API void
nk_stroke_polygon(struct nk_command_buffer *b, const float *points, int point_count,
nk_stroke_polygon(struct nk_command_buffer *b, float *points, int point_count,
float line_thickness, struct nk_color col)
{
int i;
Expand All @@ -350,7 +350,7 @@ nk_stroke_polygon(struct nk_command_buffer *b, const float *points, int point_co
}
}
NK_API void
nk_fill_polygon(struct nk_command_buffer *b, const float *points, int point_count,
nk_fill_polygon(struct nk_command_buffer *b, float *points, int point_count,
struct nk_color col)
{
int i;
Expand All @@ -371,7 +371,7 @@ nk_fill_polygon(struct nk_command_buffer *b, const float *points, int point_coun
}
}
NK_API void
nk_stroke_polyline(struct nk_command_buffer *b, const float *points, int point_count,
nk_stroke_polyline(struct nk_command_buffer *b, float *points, int point_count,
float line_thickness, struct nk_color col)
{
int i;
Expand Down Expand Up @@ -555,3 +555,4 @@ nk_draw_text(struct nk_command_buffer *b, struct nk_rect r,
NK_MEMCPY(cmd->string, string, (nk_size)length);
cmd->string[length] = '\0';
}

3 changes: 2 additions & 1 deletion src/nuklear_font.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ nk_font_query_font_glyph(nk_handle handle, float height,
}
#endif
NK_API const struct nk_font_glyph*
nk_font_find_glyph(const struct nk_font *font, nk_rune unicode)
nk_font_find_glyph(struct nk_font *font, nk_rune unicode)
{
int i = 0;
int count;
Expand Down Expand Up @@ -1370,3 +1370,4 @@ nk_font_atlas_clear(struct nk_font_atlas *atlas)
nk_zero_struct(*atlas);
}
#endif

7 changes: 4 additions & 3 deletions src/nuklear_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ enum nk_window_insert_location {
NK_LIB void *nk_create_window(struct nk_context *ctx);
NK_LIB void nk_remove_window(struct nk_context*, struct nk_window*);
NK_LIB void nk_free_window(struct nk_context *ctx, struct nk_window *win);
NK_LIB struct nk_window *nk_find_window(const struct nk_context *ctx, nk_hash hash, const char *name);
NK_LIB struct nk_window *nk_find_window(struct nk_context *ctx, nk_hash hash, const char *name);
NK_LIB void nk_insert_window(struct nk_context *ctx, struct nk_window *win, enum nk_window_insert_location loc);

/* pool */
Expand All @@ -206,7 +206,7 @@ NK_LIB void nk_remove_table(struct nk_window *win, struct nk_table *tbl);
NK_LIB void nk_free_table(struct nk_context *ctx, struct nk_table *tbl);
NK_LIB void nk_push_table(struct nk_window *win, struct nk_table *tbl);
NK_LIB nk_uint *nk_add_value(struct nk_context *ctx, struct nk_window *win, nk_hash name, nk_uint value);
NK_LIB nk_uint *nk_find_value(const struct nk_window *win, nk_hash name);
NK_LIB nk_uint *nk_find_value(struct nk_window *win, nk_hash name);

/* panel */
NK_LIB void *nk_create_panel(struct nk_context *ctx);
Expand All @@ -227,7 +227,7 @@ NK_LIB void nk_row_layout(struct nk_context *ctx, enum nk_layout_format fmt, flo
NK_LIB void nk_panel_alloc_row(const struct nk_context *ctx, struct nk_window *win);
NK_LIB void nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx, struct nk_window *win, int modify);
NK_LIB void nk_panel_alloc_space(struct nk_rect *bounds, const struct nk_context *ctx);
NK_LIB void nk_layout_peek(struct nk_rect *bounds, const struct nk_context *ctx);
NK_LIB void nk_layout_peek(struct nk_rect *bounds, struct nk_context *ctx);

/* popup */
NK_LIB nk_bool nk_nonblock_begin(struct nk_context *ctx, nk_flags flags, struct nk_rect body, struct nk_rect header, enum nk_panel_type panel_type);
Expand Down Expand Up @@ -375,3 +375,4 @@ nk_stbtt_free(void *ptr, void *user_data) {
#endif /* NK_INCLUDE_FONT_BAKING */

#endif

16 changes: 8 additions & 8 deletions src/nuklear_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ nk_row_layout(struct nk_context *ctx, enum nk_layout_format fmt,
win->layout->row.item_width = (float)width;
}
NK_API float
nk_layout_ratio_from_pixel(const struct nk_context *ctx, float pixel_width)
nk_layout_ratio_from_pixel(struct nk_context *ctx, float pixel_width)
{
struct nk_window *win;
NK_ASSERT(ctx);
Expand Down Expand Up @@ -463,7 +463,7 @@ nk_layout_space_push(struct nk_context *ctx, struct nk_rect rect)
layout->row.item = rect;
}
NK_API struct nk_rect
nk_layout_space_bounds(const struct nk_context *ctx)
nk_layout_space_bounds(struct nk_context *ctx)
{
struct nk_rect ret;
struct nk_window *win;
Expand All @@ -482,7 +482,7 @@ nk_layout_space_bounds(const struct nk_context *ctx)
return ret;
}
NK_API struct nk_rect
nk_layout_widget_bounds(const struct nk_context *ctx)
nk_layout_widget_bounds(struct nk_context *ctx)
{
struct nk_rect ret;
struct nk_window *win;
Expand All @@ -501,7 +501,7 @@ nk_layout_widget_bounds(const struct nk_context *ctx)
return ret;
}
NK_API struct nk_vec2
nk_layout_space_to_screen(const struct nk_context *ctx, struct nk_vec2 ret)
nk_layout_space_to_screen(struct nk_context *ctx, struct nk_vec2 ret)
{
struct nk_window *win;
struct nk_panel *layout;
Expand All @@ -517,7 +517,7 @@ nk_layout_space_to_screen(const struct nk_context *ctx, struct nk_vec2 ret)
return ret;
}
NK_API struct nk_vec2
nk_layout_space_to_local(const struct nk_context *ctx, struct nk_vec2 ret)
nk_layout_space_to_local(struct nk_context *ctx, struct nk_vec2 ret)
{
struct nk_window *win;
struct nk_panel *layout;
Expand All @@ -533,7 +533,7 @@ nk_layout_space_to_local(const struct nk_context *ctx, struct nk_vec2 ret)
return ret;
}
NK_API struct nk_rect
nk_layout_space_rect_to_screen(const struct nk_context *ctx, struct nk_rect ret)
nk_layout_space_rect_to_screen(struct nk_context *ctx, struct nk_rect ret)
{
struct nk_window *win;
struct nk_panel *layout;
Expand All @@ -549,7 +549,7 @@ nk_layout_space_rect_to_screen(const struct nk_context *ctx, struct nk_rect ret)
return ret;
}
NK_API struct nk_rect
nk_layout_space_rect_to_local(const struct nk_context *ctx, struct nk_rect ret)
nk_layout_space_rect_to_local(struct nk_context *ctx, struct nk_rect ret)
{
struct nk_window *win;
struct nk_panel *layout;
Expand Down Expand Up @@ -730,7 +730,7 @@ nk_panel_alloc_space(struct nk_rect *bounds, const struct nk_context *ctx)
layout->row.index++;
}
NK_LIB void
nk_layout_peek(struct nk_rect *bounds, const struct nk_context *ctx)
nk_layout_peek(struct nk_rect *bounds, struct nk_context *ctx)
{
float y;
int index;
Expand Down
2 changes: 1 addition & 1 deletion src/nuklear_popup.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ nk_popup_end(struct nk_context *ctx)
nk_push_scissor(&win->buffer, win->layout->clip);
}
NK_API void
nk_popup_get_scroll(const struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y)
nk_popup_get_scroll(struct nk_context *ctx, nk_uint *offset_x, nk_uint *offset_y)
{
struct nk_window *popup;

Expand Down
5 changes: 3 additions & 2 deletions src/nuklear_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,14 @@ nk_str_get_const(const struct nk_str *s)
return (const char*)s->buffer.memory.ptr;
}
NK_API int
nk_str_len(const struct nk_str *s)
nk_str_len(struct nk_str *s)
{
NK_ASSERT(s);
if (!s || !s->len || !s->buffer.allocated) return 0;
return s->len;
}
NK_API int
nk_str_len_char(const struct nk_str *s)
nk_str_len_char(struct nk_str *s)
{
NK_ASSERT(s);
if (!s || !s->len || !s->buffer.allocated) return 0;
Expand All @@ -446,3 +446,4 @@ nk_str_free(struct nk_str *str)
nk_buffer_free(&str->buffer);
str->len = 0;
}

3 changes: 2 additions & 1 deletion src/nuklear_style.c
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ nk_style_load_cursor(struct nk_context *ctx, enum nk_style_cursor cursor,
style->cursors[cursor] = c;
}
NK_API void
nk_style_load_all_cursors(struct nk_context *ctx, const struct nk_cursor *cursors)
nk_style_load_all_cursors(struct nk_context *ctx, struct nk_cursor *cursors)
{
int i = 0;
struct nk_style *style;
Expand All @@ -861,3 +861,4 @@ nk_style_load_all_cursors(struct nk_context *ctx, const struct nk_cursor *cursor
style->cursors[i] = &cursors[i];
style->cursor_visible = nk_true;
}

3 changes: 2 additions & 1 deletion src/nuklear_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ nk_add_value(struct nk_context *ctx, struct nk_window *win,
return &win->tables->values[win->tables->size++];
}
NK_LIB nk_uint*
nk_find_value(const struct nk_window *win, nk_hash name)
nk_find_value(struct nk_window *win, nk_hash name)
{
struct nk_table *iter = win->tables;
while (iter) {
Expand All @@ -87,3 +87,4 @@ nk_find_value(const struct nk_window *win, nk_hash name)
}
return 0;
}

18 changes: 9 additions & 9 deletions src/nuklear_widget.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* ===============================================================*/
NK_API struct nk_rect
nk_widget_bounds(const struct nk_context *ctx)
nk_widget_bounds(struct nk_context *ctx)
{
struct nk_rect bounds;
NK_ASSERT(ctx);
Expand All @@ -18,7 +18,7 @@ nk_widget_bounds(const struct nk_context *ctx)
return bounds;
}
NK_API struct nk_vec2
nk_widget_position(const struct nk_context *ctx)
nk_widget_position(struct nk_context *ctx)
{
struct nk_rect bounds;
NK_ASSERT(ctx);
Expand All @@ -30,7 +30,7 @@ nk_widget_position(const struct nk_context *ctx)
return nk_vec2(bounds.x, bounds.y);
}
NK_API struct nk_vec2
nk_widget_size(const struct nk_context *ctx)
nk_widget_size(struct nk_context *ctx)
{
struct nk_rect bounds;
NK_ASSERT(ctx);
Expand All @@ -42,7 +42,7 @@ nk_widget_size(const struct nk_context *ctx)
return nk_vec2(bounds.w, bounds.h);
}
NK_API float
nk_widget_width(const struct nk_context *ctx)
nk_widget_width(struct nk_context *ctx)
{
struct nk_rect bounds;
NK_ASSERT(ctx);
Expand All @@ -54,7 +54,7 @@ nk_widget_width(const struct nk_context *ctx)
return bounds.w;
}
NK_API float
nk_widget_height(const struct nk_context *ctx)
nk_widget_height(struct nk_context *ctx)
{
struct nk_rect bounds;
NK_ASSERT(ctx);
Expand All @@ -66,7 +66,7 @@ nk_widget_height(const struct nk_context *ctx)
return bounds.h;
}
NK_API nk_bool
nk_widget_is_hovered(const struct nk_context *ctx)
nk_widget_is_hovered(struct nk_context *ctx)
{
struct nk_rect c, v;
struct nk_rect bounds;
Expand All @@ -88,7 +88,7 @@ nk_widget_is_hovered(const struct nk_context *ctx)
return nk_input_is_mouse_hovering_rect(&ctx->input, bounds);
}
NK_API nk_bool
nk_widget_is_mouse_clicked(const struct nk_context *ctx, enum nk_buttons btn)
nk_widget_is_mouse_clicked(struct nk_context *ctx, enum nk_buttons btn)
{
struct nk_rect c, v;
struct nk_rect bounds;
Expand All @@ -110,7 +110,7 @@ nk_widget_is_mouse_clicked(const struct nk_context *ctx, enum nk_buttons btn)
return nk_input_mouse_clicked(&ctx->input, btn, bounds);
}
NK_API nk_bool
nk_widget_has_mouse_click_down(const struct nk_context *ctx, enum nk_buttons btn, nk_bool down)
nk_widget_has_mouse_click_down(struct nk_context *ctx, enum nk_buttons btn, nk_bool down)
{
struct nk_rect c, v;
struct nk_rect bounds;
Expand Down Expand Up @@ -182,7 +182,7 @@ nk_widget(struct nk_rect *bounds, const struct nk_context *ctx)
return NK_WIDGET_VALID;
}
NK_API enum nk_widget_layout_states
nk_widget_fitting(struct nk_rect *bounds, const struct nk_context *ctx,
nk_widget_fitting(struct nk_rect *bounds, struct nk_context *ctx,
struct nk_vec2 item_padding)
{
/* update the bounds to stand without padding */
Expand Down
Loading