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

Strict c++17 now compiles #13

Closed
wants to merge 9 commits into from
Closed
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
29 changes: 28 additions & 1 deletion nuklear.h
Original file line number Diff line number Diff line change
Expand Up @@ -5716,9 +5716,11 @@ template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {

#ifndef NK_MEMSET
#define NK_MEMSET nk_memset
#define NK_MEMSET_BUILTIN
#endif
#ifndef NK_MEMCPY
#define NK_MEMCPY nk_memcopy
#define NK_MEMCPY_BUILTIN
#endif
#ifndef NK_SQRT
#define NK_SQRT nk_sqrt
Expand Down Expand Up @@ -5817,8 +5819,15 @@ NK_LIB int nk_is_lower(int c);
NK_LIB int nk_is_upper(int c);
NK_LIB int nk_to_upper(int c);
NK_LIB int nk_to_lower(int c);

#ifdef NK_MEMCPY_BUILTIN
NK_LIB void* nk_memcopy(void *dst, const void *src, nk_size n);
#endif

#ifdef NK_MEMSET_BUILTIN
NK_LIB void nk_memset(void *ptr, int c0, nk_size size);
#endif

NK_LIB void nk_zero(void *ptr, nk_size size);
NK_LIB char *nk_itoa(char *s, long n);
NK_LIB int nk_string_float_limit(char *string, int prec);
Expand Down Expand Up @@ -6334,6 +6343,8 @@ NK_LIB int nk_is_upper(int c){return (c >= 'A' && c <= 'Z') || (c >= 0xC0 && c <
NK_LIB int nk_to_upper(int c) {return (c >= 'a' && c <= 'z') ? (c - ('a' - 'A')) : c;}
NK_LIB int nk_to_lower(int c) {return (c >= 'A' && c <= 'Z') ? (c - ('a' + 'A')) : c;}

#ifdef NK_MEMCPY_BUILTIN

NK_LIB void*
nk_memcopy(void *dst0, const void *src0, nk_size length)
{
Expand Down Expand Up @@ -6390,6 +6401,11 @@ nk_memcopy(void *dst0, const void *src0, nk_size length)
done:
return (dst0);
}

#endif

#ifdef NK_MEMSET_BUILTIN

NK_LIB void
nk_memset(void *ptr, int c0, nk_size size)
{
Expand Down Expand Up @@ -6441,6 +6457,9 @@ nk_memset(void *ptr, int c0, nk_size size)
#undef nk_wsize
#undef nk_wmask
}

#endif

NK_LIB void
nk_zero(void *ptr, nk_size size)
{
Expand Down Expand Up @@ -9437,6 +9456,8 @@ nk_draw_list_alloc_vertices(struct nk_draw_list *list, nk_size count)
if (!vtx) return 0;
list->vertex_count += (unsigned int)count;

#ifndef NK_UINT_DRAW_INDEX

/* This assert triggers because your are drawing a lot of stuff and nuklear
* defined `nk_draw_index` as `nk_ushort` to safe space be default.
*
Expand All @@ -9446,8 +9467,11 @@ nk_draw_list_alloc_vertices(struct nk_draw_list *list, nk_size count)
* backend (OpenGL, DirectX, ...). For example in OpenGL for `glDrawElements`
* instead of specifing `GL_UNSIGNED_SHORT` you have to define `GL_UNSIGNED_INT`.
* Sorry for the inconvenience. */
if(sizeof(nk_draw_index)==2) NK_ASSERT((list->vertex_count < NK_USHORT_MAX &&
NK_ASSERT((list->vertex_count < NK_USHORT_MAX &&
"To many verticies for 16-bit vertex indicies. Please read comment above on how to solve this problem"));

#endif

return vtx;
}
NK_INTERN nk_draw_index*
Expand Down Expand Up @@ -25476,6 +25500,9 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// - [yy]: Minor version with non-breaking API and library changes
/// - [zz]: Bug fix version with no direct changes to API
///
/// - 2019/12/11 (4.01.6) - Strict c++17 now compiles: only declaring memset, memcpy if they are used.
/// Only asserting index range if ushorts are used for indices.
/// Made paq.sh identical to paq.bat (outputs to nuklear.h).
/// - 2019/12/10 (4.01.5) - Fix off-by-one error in NK_INTERSECT
/// - 2019/10/09 (4.01.4) - Fix bug for autoscrolling in nk_do_edit
/// - 2019/09/20 (4.01.3) - Fixed a bug wherein combobox cannot be closed by clicking the header
Expand Down
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{
"name": "nuklear",
"version": "4.01.5",
"version": "4.01.6",
"repo": "Immediate-Mode-UI/Nuklear",
"description": "A small ANSI C gui toolkit",
"keywords": ["gl", "ui", "toolkit"],
"src": ["nuklear.h"]
"keywords": [
"gl",
"ui",
"toolkit"
],
"src": [
"nuklear.h"
]
}
3 changes: 3 additions & 0 deletions src/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
/// - [yy]: Minor version with non-breaking API and library changes
/// - [zz]: Bug fix version with no direct changes to API
///
/// - 2019/12/11 (4.01.6) - Strict c++17 now compiles: only declaring memset, memcpy if they are used.
/// Only asserting index range if ushorts are used for indices.
/// Made paq.sh identical to paq.bat (outputs to nuklear.h).
/// - 2019/12/10 (4.01.5) - Fix off-by-one error in NK_INTERSECT
/// - 2019/10/09 (4.01.4) - Fix bug for autoscrolling in nk_do_edit
/// - 2019/09/20 (4.01.3) - Fixed a bug wherein combobox cannot be closed by clicking the header
Expand Down
2 changes: 1 addition & 1 deletion src/Readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
File Packer:
------------
- [Click to generate nuklear.h](http://apoorvaj.io/single-header-packer.html?macro=NK&pre=https://raw.githubusercontent.com/vurtun/nuklear/master/src/HEADER&pub=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear.h&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_internal.h&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_math.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_util.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_color.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_utf8.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_buffer.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_string.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_draw.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_vertex.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_font.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_input.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_style.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_context.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_pool.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_page_element.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_table.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_panel.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_window.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_popup.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_contextual.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_menu.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_layout.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_tree.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_group.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_list_view.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_widget.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_text.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_image.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_button.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_toggle.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_selectable.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_slider.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_progress.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_scrollbar.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_text_editor.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_edit.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_property.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_chart.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_color_picker.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_combo.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_tooltip.c&post=https://raw.githubusercontent.com/vurtun/nuklear/master/src/LICENSE&post=https://raw.githubusercontent.com/vurtun/nuklear/master/src/CHANGELOG&post=https://raw.githubusercontent.com/vurtun/nuklear/master/src/CREDITS)
- On Linux/Mac just run ./paq > ../nuklear.h
- On Linux/Mac just run ./paq.sh
- On Windows just run paq.bat
4 changes: 3 additions & 1 deletion src/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

import fnmatch
import os.path
import sys
import sys, io

sys.stdout = io.TextIOWrapper(sys.stdout.buffer, newline='\n' )

def print_help():
print(
Expand Down
9 changes: 9 additions & 0 deletions src/nuklear_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@

#ifndef NK_MEMSET
#define NK_MEMSET nk_memset
#define NK_MEMSET_BUILTIN
#endif
#ifndef NK_MEMCPY
#define NK_MEMCPY nk_memcopy
#define NK_MEMCPY_BUILTIN
#endif
#ifndef NK_SQRT
#define NK_SQRT nk_sqrt
Expand Down Expand Up @@ -131,8 +133,15 @@ NK_LIB int nk_is_lower(int c);
NK_LIB int nk_is_upper(int c);
NK_LIB int nk_to_upper(int c);
NK_LIB int nk_to_lower(int c);

#ifdef NK_MEMCPY_BUILTIN
NK_LIB void* nk_memcopy(void *dst, const void *src, nk_size n);
#endif

#ifdef NK_MEMSET_BUILTIN
NK_LIB void nk_memset(void *ptr, int c0, nk_size size);
#endif

NK_LIB void nk_zero(void *ptr, nk_size size);
NK_LIB char *nk_itoa(char *s, long n);
NK_LIB int nk_string_float_limit(char *string, int prec);
Expand Down
10 changes: 10 additions & 0 deletions src/nuklear_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ NK_LIB int nk_is_upper(int c){return (c >= 'A' && c <= 'Z') || (c >= 0xC0 && c <
NK_LIB int nk_to_upper(int c) {return (c >= 'a' && c <= 'z') ? (c - ('a' - 'A')) : c;}
NK_LIB int nk_to_lower(int c) {return (c >= 'A' && c <= 'Z') ? (c - ('a' + 'A')) : c;}

#ifdef NK_MEMCPY_BUILTIN

NK_LIB void*
nk_memcopy(void *dst0, const void *src0, nk_size length)
{
Expand Down Expand Up @@ -69,6 +71,11 @@ nk_memcopy(void *dst0, const void *src0, nk_size length)
done:
return (dst0);
}

#endif

#ifdef NK_MEMSET_BUILTIN

NK_LIB void
nk_memset(void *ptr, int c0, nk_size size)
{
Expand Down Expand Up @@ -120,6 +127,9 @@ nk_memset(void *ptr, int c0, nk_size size)
#undef nk_wsize
#undef nk_wmask
}

#endif

NK_LIB void
nk_zero(void *ptr, nk_size size)
{
Expand Down
7 changes: 6 additions & 1 deletion src/nuklear_vertex.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ nk_draw_list_alloc_vertices(struct nk_draw_list *list, nk_size count)
if (!vtx) return 0;
list->vertex_count += (unsigned int)count;

#ifndef NK_UINT_DRAW_INDEX

/* This assert triggers because your are drawing a lot of stuff and nuklear
* defined `nk_draw_index` as `nk_ushort` to safe space be default.
*
Expand All @@ -233,8 +235,11 @@ nk_draw_list_alloc_vertices(struct nk_draw_list *list, nk_size count)
* backend (OpenGL, DirectX, ...). For example in OpenGL for `glDrawElements`
* instead of specifing `GL_UNSIGNED_SHORT` you have to define `GL_UNSIGNED_INT`.
* Sorry for the inconvenience. */
if(sizeof(nk_draw_index)==2) NK_ASSERT((list->vertex_count < NK_USHORT_MAX &&
NK_ASSERT((list->vertex_count < NK_USHORT_MAX &&
"To many verticies for 16-bit vertex indicies. Please read comment above on how to solve this problem"));

#endif

return vtx;
}
NK_INTERN nk_draw_index*
Expand Down
3 changes: 1 addition & 2 deletions src/paq.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/bin/sh
python build.py --macro NK --intro HEADER --pub nuklear.h --priv nuklear_internal.h,nuklear_math.c,nuklear_util.c,nuklear_color.c,nuklear_utf8.c,nuklear_buffer.c,nuklear_string.c,nuklear_draw.c,nuklear_vertex.c,nuklear_font.c,nuklear_input.c,nuklear_style.c,nuklear_context.c,nuklear_pool.c,nuklear_page_element.c,nuklear_table.c,nuklear_panel.c,nuklear_window.c,nuklear_popup.c,nuklear_contextual.c,nuklear_menu.c,nuklear_layout.c,nuklear_tree.c,nuklear_group.c,nuklear_list_view.c,nuklear_widget.c,nuklear_text.c,nuklear_image.c,nuklear_button.c,nuklear_toggle.c,nuklear_selectable.c,nuklear_slider.c,nuklear_progress.c,nuklear_scrollbar.c,nuklear_text_editor.c,nuklear_edit.c,nuklear_property.c,nuklear_chart.c,nuklear_color_picker.c,nuklear_combo.c,nuklear_tooltip.c --outro LICENSE,CHANGELOG,CREDITS

python build.py --macro NK --intro HEADER --pub nuklear.h --priv nuklear_internal.h,nuklear_math.c,nuklear_util.c,nuklear_color.c,nuklear_utf8.c,nuklear_buffer.c,nuklear_string.c,nuklear_draw.c,nuklear_vertex.c,nuklear_font.c,nuklear_input.c,nuklear_style.c,nuklear_context.c,nuklear_pool.c,nuklear_page_element.c,nuklear_table.c,nuklear_panel.c,nuklear_window.c,nuklear_popup.c,nuklear_contextual.c,nuklear_menu.c,nuklear_layout.c,nuklear_tree.c,nuklear_group.c,nuklear_list_view.c,nuklear_widget.c,nuklear_text.c,nuklear_image.c,nuklear_button.c,nuklear_toggle.c,nuklear_selectable.c,nuklear_slider.c,nuklear_progress.c,nuklear_scrollbar.c,nuklear_text_editor.c,nuklear_edit.c,nuklear_property.c,nuklear_chart.c,nuklear_color_picker.c,nuklear_combo.c,nuklear_tooltip.c --outro LICENSE,CHANGELOG,CREDITS > ../nuklear.h