From ca279b80e686e2e590f1cf08ef22dabdead4d66f Mon Sep 17 00:00:00 2001 From: Brian <brian@yutani.localnet.net> Date: Mon, 26 Feb 2007 14:33:52 -0700 Subject: Remove old error logging code. New slang_log.[ch] files. --- src/mesa/shader/slang/slang_error.c | 78 ---------------------- src/mesa/shader/slang/slang_error.h | 44 ------------- src/mesa/shader/slang/slang_log.c | 128 ++++++++++++++++++++++++++++++++++++ src/mesa/shader/slang/slang_log.h | 56 ++++++++++++++++ 4 files changed, 184 insertions(+), 122 deletions(-) delete mode 100644 src/mesa/shader/slang/slang_error.c delete mode 100644 src/mesa/shader/slang/slang_error.h create mode 100644 src/mesa/shader/slang/slang_log.c create mode 100644 src/mesa/shader/slang/slang_log.h (limited to 'src/mesa/shader/slang') diff --git a/src/mesa/shader/slang/slang_error.c b/src/mesa/shader/slang/slang_error.c deleted file mode 100644 index bfa8e80a05c..00000000000 --- a/src/mesa/shader/slang/slang_error.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 2005-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "imports.h" -#include "slang_error.h" - - -static char ErrorText[10000]; -static char FormattedErrorText[10000]; -static int ErrorPos; - - -void -_slang_reset_error(void) -{ - ErrorText[0] = 0; - ErrorPos = -1; -} - - -/** - * Record an error message, if one hasn't been recorded already. - */ -void -_slang_record_error(const char *msg1, const char *msg2, - GLint pos, const char *file, int line) -{ - /* don't overwrite a previously recorded error */ - if (!ErrorText[0]) { - _mesa_sprintf(ErrorText, "%s %s", msg1, msg2); - ErrorPos = -1; -#ifdef DEBUG - fprintf(stderr, "Mesa shader compile error: %s %s at %d (%s line %d)\n", - msg1, msg2, pos, file, line); -#endif - } - abort(); -} - - -/** - * Return formatted error text. - */ -const char * -_slang_error_text(void) -{ - /* - * NVIDIA formats errors like this: - * (LINE_NUMBER) : error ERROR_CODE: ERROR_TEXT - * Example: - * (7) : error C1048: invalid character 'P' in swizzle "P" - */ - _mesa_sprintf(FormattedErrorText, - "(%d) : error: %s", ErrorPos, ErrorText); - return FormattedErrorText; -} - diff --git a/src/mesa/shader/slang/slang_error.h b/src/mesa/shader/slang/slang_error.h deleted file mode 100644 index 064b11b498d..00000000000 --- a/src/mesa/shader/slang/slang_error.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 2005-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef SLANG_ERROR_H -#define SLANG_ERROR_H - -#if 0 -extern void -_slang_reset_error(void); - - -extern void -_slang_record_error(const char *msg1, const char *msg2, - GLint pos, const char *file, int line); - - -extern const char * -_slang_error_text(void); -#endif -foo! - - -#endif /* SLANG_ERROR_H */ diff --git a/src/mesa/shader/slang/slang_log.c b/src/mesa/shader/slang/slang_log.c new file mode 100644 index 00000000000..b6545b2c2e9 --- /dev/null +++ b/src/mesa/shader/slang/slang_log.c @@ -0,0 +1,128 @@ +/* + * Mesa 3-D graphics library + * Version: 6.5.3 + * + * Copyright (C) 2005-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "imports.h" +#include "slang_log.h" +#include "slang_utility.h" + + + +static char *out_of_memory = "Error: Out of memory.\n"; + +void +slang_info_log_construct(slang_info_log * log) +{ + log->text = NULL; + log->dont_free_text = 0; +} + +void +slang_info_log_destruct(slang_info_log * log) +{ + if (!log->dont_free_text) + slang_alloc_free(log->text); +} + +static int +slang_info_log_message(slang_info_log * log, const char *prefix, + const char *msg) +{ + GLuint size; + + if (log->dont_free_text) + return 0; + size = slang_string_length(msg) + 2; + if (prefix != NULL) + size += slang_string_length(prefix) + 2; + if (log->text != NULL) { + GLuint old_len = slang_string_length(log->text); + log->text = (char *) + slang_alloc_realloc(log->text, old_len + 1, old_len + size); + } + else { + log->text = (char *) (slang_alloc_malloc(size)); + if (log->text != NULL) + log->text[0] = '\0'; + } + if (log->text == NULL) + return 0; + if (prefix != NULL) { + slang_string_concat(log->text, prefix); + slang_string_concat(log->text, ": "); + } + slang_string_concat(log->text, msg); + slang_string_concat(log->text, "\n"); + return 1; +} + +int +slang_info_log_print(slang_info_log * log, const char *msg, ...) +{ + va_list va; + char buf[1024]; + + va_start(va, msg); + _mesa_vsprintf(buf, msg, va); + va_end(va); + return slang_info_log_message(log, NULL, buf); +} + +int +slang_info_log_error(slang_info_log * log, const char *msg, ...) +{ + va_list va; + char buf[1024]; + + va_start(va, msg); + _mesa_vsprintf(buf, msg, va); + va_end(va); + if (slang_info_log_message(log, "Error", buf)) + return 1; + slang_info_log_memory(log); + return 0; +} + +int +slang_info_log_warning(slang_info_log * log, const char *msg, ...) +{ + va_list va; + char buf[1024]; + + va_start(va, msg); + _mesa_vsprintf(buf, msg, va); + va_end(va); + if (slang_info_log_message(log, "Warning", buf)) + return 1; + slang_info_log_memory(log); + return 0; +} + +void +slang_info_log_memory(slang_info_log * log) +{ + if (!slang_info_log_message(log, "Error", "Out of memory.")) { + log->dont_free_text = 1; + log->text = out_of_memory; + } +} diff --git a/src/mesa/shader/slang/slang_log.h b/src/mesa/shader/slang/slang_log.h new file mode 100644 index 00000000000..e4ca3a22f11 --- /dev/null +++ b/src/mesa/shader/slang/slang_log.h @@ -0,0 +1,56 @@ +/* + * Mesa 3-D graphics library + * Version: 6.5.3 + * + * Copyright (C) 2005-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef SLANG_LOG_H +#define SLANG_LOG_H + + +typedef struct slang_info_log_ +{ + char *text; + int dont_free_text; +} slang_info_log; + + +extern void +slang_info_log_construct(slang_info_log *); + +extern void +slang_info_log_destruct(slang_info_log *); + +extern int +slang_info_log_print(slang_info_log *, const char *, ...); + +extern int +slang_info_log_error(slang_info_log *, const char *, ...); + +extern int +slang_info_log_warning(slang_info_log *, const char *, ...); + +extern void +slang_info_log_memory(slang_info_log *); + + +#endif /* SLANG_LOG_H */ -- cgit v1.2.3