Skip to content
This repository has been archived by the owner on Dec 2, 2019. It is now read-only.

Remove additional definitions of UNUSED/MIN/MAX/LEN #816

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 0 additions & 5 deletions demo/allegro5/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
#include "nuklear_allegro5.h"


#define UNUSED(a) (void)a
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a)/sizeof(a)[0])

/* ===============================================================
*
* EXAMPLE
Expand Down
4 changes: 2 additions & 2 deletions demo/allegro5/nuklear_allegro5.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,15 @@ nk_allegro5_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
{
char *text = al_get_clipboard_text(allegro5.dsp);
if (text) nk_textedit_paste(edit, text, nk_strlen(text));
(void)usr;
NK_UNUSED(usr);
al_free(text);
}

NK_INTERN void
nk_allegro5_clipboard_copy(nk_handle usr, const char *text, int len)
{
char *str = 0;
(void)usr;
NK_UNUSED(usr);
if (!len) return;
str = (char*)malloc((size_t)len+1);
if (!str) return;
Expand Down
4 changes: 2 additions & 2 deletions demo/d3d11/nuklear_d3d11.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ nk_d3d11_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
static void
nk_d3d11_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
{
(void)usr;
NK_UNUSED(usr);
if (IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(NULL))
{
HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
Expand Down Expand Up @@ -394,7 +394,7 @@ nk_d3d11_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
static void
nk_d3d11_clipboard_copy(nk_handle usr, const char *text, int len)
{
(void)usr;
NK_UNUSED(usr);
if (OpenClipboard(NULL))
{
int wsize = MultiByteToWideChar(CP_UTF8, 0, text, len, NULL, 0);
Expand Down
4 changes: 2 additions & 2 deletions demo/d3d9/nuklear_d3d9.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ nk_d3d9_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
static void
nk_d3d9_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
{
(void)usr;
NK_UNUSED(usr);
if (!IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(NULL)) {
return;
}
Expand Down Expand Up @@ -465,7 +465,7 @@ nk_d3d9_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
static void
nk_d3d9_clipboard_copy(nk_handle usr, const char *text, int len)
{
(void)usr;
NK_UNUSED(usr);
if (!OpenClipboard(NULL)) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion demo/gdi/nuklear_gdi.h
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ nk_gdifont_del(GdiFont *font)
static void
nk_gdi_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
{
(void)usr;
NK_UNUSED(usr);
if (IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(NULL))
{
HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
Expand Down
6 changes: 3 additions & 3 deletions demo/gdip/nuklear_gdip.h
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ nk_gdipfont_get_text_width(nk_handle handle, float height, const char *text, int
if (!font || !text)
return 0;

(void)height;
NK_UNUSED(height);
wsize = MultiByteToWideChar(CP_UTF8, 0, text, len, NULL, 0);
wstr = (WCHAR*)_alloca(wsize * sizeof(wchar_t));
MultiByteToWideChar(CP_UTF8, 0, text, len, wstr, wsize);
Expand All @@ -747,7 +747,7 @@ nk_gdip_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
LPCWSTR wstr;
int utf8size;
char* utf8;
(void)usr;
NK_UNUSED(usr);

if (!IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(NULL))
return;
Expand Down Expand Up @@ -797,7 +797,7 @@ nk_gdip_clipboard_copy(nk_handle usr, const char *text, int len)
HGLOBAL mem;
wchar_t* wstr;
int wsize;
(void)usr;
NK_UNUSED(usr);

if (!OpenClipboard(NULL))
return;
Expand Down
9 changes: 5 additions & 4 deletions demo/glfw_opengl2/nuklear_glfw_gl2.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,16 @@ nk_glfw3_render(enum nk_anti_aliasing AA)
NK_API void
nk_glfw3_char_callback(GLFWwindow *win, unsigned int codepoint)
{
(void)win;
NK_UNUSED(win);
if (glfw.text_len < NK_GLFW_TEXT_MAX)
glfw.text[glfw.text_len++] = codepoint;
}

NK_API void
nk_gflw3_scroll_callback(GLFWwindow *win, double xoff, double yoff)
{
(void)win; (void)xoff;
NK_UNUSED(win);
NK_UNUSED(xoff);
glfw.scroll.x += (float)xoff;
glfw.scroll.y += (float)yoff;
}
Expand All @@ -234,14 +235,14 @@ nk_glfw3_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
{
const char *text = glfwGetClipboardString(glfw.win);
if (text) nk_textedit_paste(edit, text, nk_strlen(text));
(void)usr;
NK_UNUSED(usr);
}

NK_INTERN void
nk_glfw3_clipboard_copy(nk_handle usr, const char *text, int len)
{
char *str = 0;
(void)usr;
NK_UNUSED(usr);
if (!len) return;
str = (char*)malloc((size_t)len+1);
if (!str) return;
Expand Down
9 changes: 5 additions & 4 deletions demo/glfw_opengl3/nuklear_glfw_gl3.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,16 @@ nk_glfw3_render(enum nk_anti_aliasing AA, int max_vertex_buffer, int max_element
NK_API void
nk_glfw3_char_callback(GLFWwindow *win, unsigned int codepoint)
{
(void)win;
NK_UNUSED(win);
if (glfw.text_len < NK_GLFW_TEXT_MAX)
glfw.text[glfw.text_len++] = codepoint;
}

NK_API void
nk_gflw3_scroll_callback(GLFWwindow *win, double xoff, double yoff)
{
(void)win; (void)xoff;
NK_UNUSED(win);
NK_UNUSED(xoff);
glfw.scroll.x += (float)xoff;
glfw.scroll.y += (float)yoff;
}
Expand All @@ -343,14 +344,14 @@ nk_glfw3_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
{
const char *text = glfwGetClipboardString(glfw.win);
if (text) nk_textedit_paste(edit, text, nk_strlen(text));
(void)usr;
NK_UNUSED(usr);
}

NK_INTERN void
nk_glfw3_clipboard_copy(nk_handle usr, const char *text, int len)
{
char *str = 0;
(void)usr;
NK_UNUSED(usr);
if (!len) return;
str = (char*)malloc((size_t)len+1);
if (!str) return;
Expand Down
9 changes: 5 additions & 4 deletions demo/glfw_opengl4/nuklear_glfw_gl4.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,15 +459,16 @@ nk_glfw3_render(enum nk_anti_aliasing AA)
NK_API void
nk_glfw3_char_callback(GLFWwindow *win, unsigned int codepoint)
{
(void)win;
NK_UNUSED(win);
if (glfw.text_len < NK_GLFW_TEXT_MAX)
glfw.text[glfw.text_len++] = codepoint;
}

NK_API void
nk_gflw3_scroll_callback(GLFWwindow *win, double xoff, double yoff)
{
(void)win; (void)xoff;
NK_UNUSED(win);
NK_UNUSED(xoff);
glfw.scroll.x += (float)xoff;
glfw.scroll.y += (float)yoff;
}
Expand All @@ -493,14 +494,14 @@ nk_glfw3_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
{
const char *text = glfwGetClipboardString(glfw.win);
if (text) nk_textedit_paste(edit, text, nk_strlen(text));
(void)usr;
NK_UNUSED(usr);
}

NK_INTERN void
nk_glfw3_clipboard_copy(nk_handle usr, const char *text, int len)
{
char *str = 0;
(void)usr;
NK_UNUSED(usr);
if (!len) return;
str = (char*)malloc((size_t)len+1);
if (!str) return;
Expand Down
4 changes: 2 additions & 2 deletions demo/sdl_opengl2/nuklear_sdl_gl2.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,14 @@ nk_sdl_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
{
const char *text = SDL_GetClipboardText();
if (text) nk_textedit_paste(edit, text, nk_strlen(text));
(void)usr;
NK_UNUSED(usr);
}

static void
nk_sdl_clipboard_copy(nk_handle usr, const char *text, int len)
{
char *str = 0;
(void)usr;
NK_UNUSED(usr);
if (!len) return;
str = (char*)malloc((size_t)len+1);
if (!str) return;
Expand Down
4 changes: 2 additions & 2 deletions demo/sdl_opengl3/nuklear_sdl_gl3.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,14 @@ nk_sdl_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
{
const char *text = SDL_GetClipboardText();
if (text) nk_textedit_paste(edit, text, nk_strlen(text));
(void)usr;
NK_UNUSED(usr);
}

static void
nk_sdl_clipboard_copy(nk_handle usr, const char *text, int len)
{
char *str = 0;
(void)usr;
NK_UNUSED(usr);
if (!len) return;
str = (char*)malloc((size_t)len+1);
if (!str) return;
Expand Down
5 changes: 0 additions & 5 deletions demo/sdl_opengles2/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
#define MAX_VERTEX_MEMORY 512 * 1024
#define MAX_ELEMENT_MEMORY 128 * 1024

#define UNUSED(a) (void)a
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a)/sizeof(a)[0])

/* ===============================================================
*
* EXAMPLE
Expand Down
4 changes: 2 additions & 2 deletions demo/sdl_opengles2/nuklear_sdl_gles2.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,14 @@ nk_sdl_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
{
const char *text = SDL_GetClipboardText();
if (text) nk_textedit_paste(edit, text, nk_strlen(text));
(void)usr;
NK_UNUSED(usr);
}

static void
nk_sdl_clipboard_copy(nk_handle usr, const char *text, int len)
{
char *str = 0;
(void)usr;
NK_UNUSED(usr);
if (!len) return;
str = (char*)malloc((size_t)len+1);
if (!str) return;
Expand Down
5 changes: 3 additions & 2 deletions demo/sfml_opengl2/nuklear_sfml_gl2.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ nk_sfml_clipboard_paste(nk_handle usr, struct nk_text_edit* edit)

if(text)
nk_textedit_paste(edit, text, nk_strlen(text));
(void)usr;

NK_UNUSED(usr);
#endif
}

Expand All @@ -196,7 +197,7 @@ nk_sfml_clipboard_copy(nk_handle usr, const char* text, int len)
{
#if 0
char* str = 0;
(void)usr;
NK_UNUSED(usr);
if(!len) return;
str = (char*)malloc((size_t)len+1);
if(!str) return;
Expand Down
4 changes: 2 additions & 2 deletions demo/sfml_opengl3/nuklear_sfml_gl3.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ nk_sfml_clipboard_paste(nk_handle usr, struct nk_text_edit* edit)
{
#if 0
/* Not Implemented in SFML */
(void)usr;
NK_UNUSED(usr);
sf::Clipboard clipboard(sfml.window);
const char* text = clipboard.getText();
if(text) nk_textedit_paste(edit, text, nk_strlen(text));
Expand All @@ -304,7 +304,7 @@ nk_sfml_clipboard_copy(nk_handle usr, const char* text, int len)
{
#if 0
char* str = 0;
(void)usr;
NK_UNUSED(usr);
if(!len) return;
str = (char*)malloc((size_t)len+1);
if(!str) return;
Expand Down
5 changes: 0 additions & 5 deletions demo/x11_rawfb/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@
#define WINDOW_WIDTH 800
#define WINDOW_HEIGHT 600

#define UNUSED(a) (void)a
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a)/sizeof(a)[0])

typedef struct XWindow XWindow;
struct XWindow {
Display *dpy;
Expand Down
25 changes: 9 additions & 16 deletions demo/x11_rawfb/nuklear_rawfb.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@ struct rawfb_context {
struct nk_font_atlas atlas;
};

#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a,b) ((a) < (b) ? (b) : (a))
#endif

static unsigned int
nk_color_from_byte(const nk_byte *c)
{
Expand Down Expand Up @@ -190,10 +183,10 @@ nk_rawfb_scissor(struct rawfb_context *rawfb,
const float w,
const float h)
{
rawfb->scissors.x = MIN(MAX(x, 0), rawfb->fb.w);
rawfb->scissors.y = MIN(MAX(y, 0), rawfb->fb.h);
rawfb->scissors.w = MIN(MAX(w + x, 0), rawfb->fb.w);
rawfb->scissors.h = MIN(MAX(h + y, 0), rawfb->fb.h);
rawfb->scissors.x = NK_CLAMP(0, x, rawfb->fb.w);
rawfb->scissors.y = NK_CLAMP(0, y, rawfb->fb.h);
rawfb->scissors.w = NK_CLAMP(0, w + x, rawfb->fb.w);
rawfb->scissors.h = NK_CLAMP(0, h + y, rawfb->fb.h);
}

static void
Expand All @@ -218,10 +211,10 @@ nk_rawfb_stroke_line(const struct rawfb_context *rawfb,
x1 = x0;
x0 = tmp;
}
x1 = MIN(rawfb->scissors.w - 1, x1);
x0 = MIN(rawfb->scissors.w - 1, x0);
x1 = MAX(rawfb->scissors.x, x1);
x0 = MAX(rawfb->scissors.x, x0);
x1 = NK_MIN(rawfb->scissors.w - 1, x1);
x0 = NK_MIN(rawfb->scissors.w - 1, x0);
x1 = NK_MAX(rawfb->scissors.x, x1);
x0 = NK_MAX(rawfb->scissors.x, x0);
nk_rawfb_line_horizontal(rawfb, x0, y0, x1, col);
return;
}
Expand Down Expand Up @@ -670,7 +663,7 @@ nk_rawfb_stroke_curve(const struct rawfb_context *rawfb,
float t_step;
struct nk_vec2i last = p1;

segments = MAX(num_segments, 1);
segments = NK_MAX(num_segments, 1);
t_step = 1.0f/(float)segments;
for (i_step = 1; i_step <= segments; ++i_step) {
float t = t_step * (float)i_step;
Expand Down
7 changes: 1 addition & 6 deletions example/canvas.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
#define MAX_VERTEX_MEMORY 512 * 1024
#define MAX_ELEMENT_MEMORY 128 * 1024

#define UNUSED(a) (void)a
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a)/sizeof(a)[0])

#define NK_SHADER_VERSION "#version 150\n"

/* ===============================================================
Expand Down Expand Up @@ -307,7 +302,7 @@ static void error_callback(int e, const char *d){printf("Error %d: %s\n", e, d);
static void text_input(GLFWwindow *win, unsigned int codepoint)
{nk_input_unicode((struct nk_context*)glfwGetWindowUserPointer(win), codepoint);}
static void scroll_input(GLFWwindow *win, double _, double yoff)
{UNUSED(_);nk_input_scroll((struct nk_context*)glfwGetWindowUserPointer(win), nk_vec2(0, (float)yoff));}
{NK_UNUSED(_);nk_input_scroll((struct nk_context*)glfwGetWindowUserPointer(win), nk_vec2(0, (float)yoff));}

static void
pump_input(struct nk_context *ctx, GLFWwindow *win)
Expand Down
Loading