gambas-source-code/main/gbx/gb_error.c

744 lines
15 KiB
C
Raw Normal View History

/***************************************************************************
gb_error.c
(c) 2000-2013 Benoît Minisini <gambas@users.sourceforge.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
***************************************************************************/
#define __GB_ERROR_C
#include "gb_common.h"
#include <stdarg.h>
#include <ctype.h>
#include "gb_buffer.h"
#include "gbx_debug.h"
#include "gbx_exec.h"
#include "gbx_api.h"
#include "gbx_stack.h"
#include "gbx_project.h"
#include "gb_error.h"
//#define DEBUG_ERROR 1
ERROR_CONTEXT *ERROR_current = NULL;
ERROR_INFO ERROR_last = { 0 };
void *ERROR_backtrace = NULL;
ERROR_HANDLER *ERROR_handler = NULL;
#if DEBUG_ERROR
int ERROR_depth = 0;
#endif
static int _lock = 0;
static const char *const _message[72] =
{
/* 0 E_UNKNOWN */ "Unknown error",
/* 1 E_MEMORY */ "Out of memory",
/* 2 E_CLASS */ ".3Cannot load class '&1': &2&3",
/* 3 E_STACK */ "Stack overflow",
/* 4 E_NEPARAM */ "Not enough arguments",
/* 5 E_TMPARAM */ "Too many arguments",
/* 6 E_TYPE */ ".2Type mismatch: wanted &1, got &2 instead",
/* 7 E_OVERFLOW */ "Overflow",
/* 8 E_ILLEGAL */ "Illegal instruction",
/* 9 E_NFUNC */ "Not a function",
/* 10 E_CSTATIC */ ".1Class '&1' is not creatable",
/* 11 E_NSYMBOL */ ".2Unknown symbol '&2' in class '&1'",
/* 12 E_NOBJECT */ "Not an object",
/* 13 E_NULL */ "Null object",
/* 14 E_STATIC */ ".2'&1.&2' is static",
/* 15 E_NREAD */ ".2'&1.&2' is write only",
/* 16 E_NWRITE */ ".2'&1.&2' is read only",
/* 17 E_NPROPERTY */ ".2'&1.&2' is not a property",
/* 18 E_NRETURN */ "No return value",
/* 19 E_MATH*/ "Mathematic error",
/* 20 E_ARG */ "Bad argument",
/* 21 E_BOUND */ "Out of bounds",
/* 22 E_NDIM */ "Bad number of dimensions",
/* 23 E_NARRAY */ "Not an array",
/* 24 E_MAIN */ "No startup method",
/* 25 E_NNEW */ "No instantiation method",
/* 26 E_ZERO */ "Division by zero",
/* 27 E_LIBRARY */ ".2Cannot load component '&1': &2",
/* 28 E_EVENT */ ".3Bad event handler in &1.&2(): &3",
/* 29 E_IOBJECT */ "Invalid object",
/* 30 E_ENUM */ "Not an enumeration",
/* 31 E_UCONV */ "Unsupported string conversion",
/* 32 E_CONV */ "Bad string conversion",
/* 33 E_DATE */ "Invalid date",
/* 34 E_BADPATH */ "Invalid path",
/* 35 E_OPEN */ ".2Cannot open file '&1': &2",
/* 36 E_PROJECT */ ".2Bad project file: line &1: &2",
/* 37 E_FULL */ "Device is full",
/* 38 E_EXIST */ "File already exists", /* &1 */
/* 39 E_EOF */ "End of file",
/* 40 E_FORMAT */ "Bad format string",
/* 41 E_DYNAMIC */ ".2'&1.&2' is not static",
/* 42 E_SYSTEM */ ".2System error #&1: &2",
/* 43 E_ACCESS */ "Access forbidden",
/* 44 E_TOOLONG */ "File name is too long",
/* 45 E_NEXIST */ "File or directory does not exist", /* &1 */
/* 46 E_DIR */ "File is a directory", /* &1 */
/* 47 E_READ */ "Read error",
/* 48 E_WRITE */ "Write error",
/* 49 E_NDIR */ ".1Not a directory: &1",
/* 50 E_REGEXP */ ".1Bad regular expression: &1",
/* 51 E_ARCH */ ".2Bad archive: &1: &2",
/* 52 E_REGISTER */ ".1Cannot register class '&1'",
/* 53 E_CLOSED */ "Stream is closed",
/* 54 E_VIRTUAL */ "Bad use of virtual class",
/* 55 E_STOP */ "STOP instruction encountered",
/* 56 E_STRING */ "Too many simultaneous new strings",
/* 57 E_EVAL */ ".1Bad expression: &1",
/* 58 E_LOCK */ "File is locked",
/* 59 E_PARENT */ "No parent class",
/* 60 E_EXTLIB */ ".2Cannot find dynamic library '&1': &2",
/* 61 E_EXTSYM */ ".2Cannot find symbol '&2' in dynamic library '&1'",
/* 62 E_BYREF */ "Argument cannot be passed by reference",
/* 63 E_OVERRIDE */ ".3'&1.&2' is incorrectly overridden in class '&3'",
/* 64 E_NKEY */ "Void key",
/* 65 E_SARRAY */ "Embedded array",
/* 66 E_EXTCB */ ".1Cannot create callback: &1",
/* 67 E_SERIAL */ "Serialization error",
/* 68 E_CHILD */ ".2Cannot run child process: &1&2",
/* 69 E_USER */ "Unknown user or group",
/* 70 E_NEMPTY */ "Directory is not empty",
/* 71 E_UTYPE */ "Unsupported datatype"
};
#if DEBUG_ERROR
void ERROR_debug(const char *msg, ...)
{
int i;
va_list args;
ERROR_CONTEXT *err;
va_start(args, msg);
for (i = 0; i < ERROR_depth; i++)
fprintf(stderr, "- ");
vfprintf(stderr, msg, args);
fprintf(stderr, "\t\t\t\t\t\t\t\t\t");
DEBUG_where();
err = ERROR_current;
while (err)
{
fprintf(stderr, "[%p] -> ", err);
err = err->prev;
}
fprintf(stderr, "NULL\n");
va_end(args);
}
#endif
******** Merged /branches/64bits r918:1003 into /trunk [CONFIGURATION] * NEW: 64 bits port. [EXAMPLES] * BUG: Fixed the AnalogWatch example. [WIKI CGI SCRIPT] * NEW: Some little cosmetic changes. [INTERPRETER] * NEW: The extern function implementation has been redesigned and is now based on libffi, so that it works on 64 bits system. Because of a flaw in the compiler design, projects that use the Pointer datatype must be recompiled to be used on a 64 bits system. This flaw will be fixed in Gambas 3. * OPT: Put some tables into read-only memory. About 1000 bytes are saved for each running interpreter, except the first one. * BUG: Does not crash anymore if a component cannot be loaded. * NEW: Spanish translation updated. * NEW: A new interpreter API for returning a pointer. [COMPILER] * BUG: Correctly compiles LONG constants inside code. [GB.DEBUG] * BUG: Compiles and links the gb.debug components with the thread libraries. [GB.DB.SQLITE3] * BUG: Getting the primary index of a table without primary index is safe now. [GB.GTK] * BUG: Modified the GLib priority of watched descriptors, as the main loop could enter in a loop in which user interface events were not managed. * BUG: Message boxes use application title without crashing now. [GB.OPENGL] * BUG: Disable dead code. [GB.QT.EXT] * BUG: TextEdit.TextWidth and TextEdit.TextHeight were not declared as read-only properties. [GB.XML.XSLT] * BUG: XSLT class is now declared as being not creatable. git-svn-id: svn://localhost/gambas/trunk@1006 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-01-17 22:39:26 +01:00
void ERROR_lock()
{
_lock++;
}
******** Merged /branches/64bits r918:1003 into /trunk [CONFIGURATION] * NEW: 64 bits port. [EXAMPLES] * BUG: Fixed the AnalogWatch example. [WIKI CGI SCRIPT] * NEW: Some little cosmetic changes. [INTERPRETER] * NEW: The extern function implementation has been redesigned and is now based on libffi, so that it works on 64 bits system. Because of a flaw in the compiler design, projects that use the Pointer datatype must be recompiled to be used on a 64 bits system. This flaw will be fixed in Gambas 3. * OPT: Put some tables into read-only memory. About 1000 bytes are saved for each running interpreter, except the first one. * BUG: Does not crash anymore if a component cannot be loaded. * NEW: Spanish translation updated. * NEW: A new interpreter API for returning a pointer. [COMPILER] * BUG: Correctly compiles LONG constants inside code. [GB.DEBUG] * BUG: Compiles and links the gb.debug components with the thread libraries. [GB.DB.SQLITE3] * BUG: Getting the primary index of a table without primary index is safe now. [GB.GTK] * BUG: Modified the GLib priority of watched descriptors, as the main loop could enter in a loop in which user interface events were not managed. * BUG: Message boxes use application title without crashing now. [GB.OPENGL] * BUG: Disable dead code. [GB.QT.EXT] * BUG: TextEdit.TextWidth and TextEdit.TextHeight were not declared as read-only properties. [GB.XML.XSLT] * BUG: XSLT class is now declared as being not creatable. git-svn-id: svn://localhost/gambas/trunk@1006 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-01-17 22:39:26 +01:00
void ERROR_unlock()
{
_lock--;
}
void ERROR_reset(ERROR_INFO *info)
{
if (!info->code)
return;
info->code = 0;
if (info->free)
{
STRING_unref(&info->msg);
info->free = FALSE;
}
info->msg = NULL;
}
******** Merged /branches/64bits r918:1003 into /trunk [CONFIGURATION] * NEW: 64 bits port. [EXAMPLES] * BUG: Fixed the AnalogWatch example. [WIKI CGI SCRIPT] * NEW: Some little cosmetic changes. [INTERPRETER] * NEW: The extern function implementation has been redesigned and is now based on libffi, so that it works on 64 bits system. Because of a flaw in the compiler design, projects that use the Pointer datatype must be recompiled to be used on a 64 bits system. This flaw will be fixed in Gambas 3. * OPT: Put some tables into read-only memory. About 1000 bytes are saved for each running interpreter, except the first one. * BUG: Does not crash anymore if a component cannot be loaded. * NEW: Spanish translation updated. * NEW: A new interpreter API for returning a pointer. [COMPILER] * BUG: Correctly compiles LONG constants inside code. [GB.DEBUG] * BUG: Compiles and links the gb.debug components with the thread libraries. [GB.DB.SQLITE3] * BUG: Getting the primary index of a table without primary index is safe now. [GB.GTK] * BUG: Modified the GLib priority of watched descriptors, as the main loop could enter in a loop in which user interface events were not managed. * BUG: Message boxes use application title without crashing now. [GB.OPENGL] * BUG: Disable dead code. [GB.QT.EXT] * BUG: TextEdit.TextWidth and TextEdit.TextHeight were not declared as read-only properties. [GB.XML.XSLT] * BUG: XSLT class is now declared as being not creatable. git-svn-id: svn://localhost/gambas/trunk@1006 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-01-17 22:39:26 +01:00
void ERROR_clear()
{
if (_lock)
{
#if DEBUG_ERROR
ERROR_debug("ERROR_clear: (%p) *LOCKED*\n", ERROR_current);
#endif
return;
}
#if DEBUG_ERROR
fprintf(stderr, "ERROR_clear: (%p)\n", ERROR_current);
#endif
ERROR_reset(&ERROR_current->info);
}
#if 0
******** Merged /branches/64bits r918:1003 into /trunk [CONFIGURATION] * NEW: 64 bits port. [EXAMPLES] * BUG: Fixed the AnalogWatch example. [WIKI CGI SCRIPT] * NEW: Some little cosmetic changes. [INTERPRETER] * NEW: The extern function implementation has been redesigned and is now based on libffi, so that it works on 64 bits system. Because of a flaw in the compiler design, projects that use the Pointer datatype must be recompiled to be used on a 64 bits system. This flaw will be fixed in Gambas 3. * OPT: Put some tables into read-only memory. About 1000 bytes are saved for each running interpreter, except the first one. * BUG: Does not crash anymore if a component cannot be loaded. * NEW: Spanish translation updated. * NEW: A new interpreter API for returning a pointer. [COMPILER] * BUG: Correctly compiles LONG constants inside code. [GB.DEBUG] * BUG: Compiles and links the gb.debug components with the thread libraries. [GB.DB.SQLITE3] * BUG: Getting the primary index of a table without primary index is safe now. [GB.GTK] * BUG: Modified the GLib priority of watched descriptors, as the main loop could enter in a loop in which user interface events were not managed. * BUG: Message boxes use application title without crashing now. [GB.OPENGL] * BUG: Disable dead code. [GB.QT.EXT] * BUG: TextEdit.TextWidth and TextEdit.TextHeight were not declared as read-only properties. [GB.XML.XSLT] * BUG: XSLT class is now declared as being not creatable. git-svn-id: svn://localhost/gambas/trunk@1006 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-01-17 22:39:26 +01:00
void ERROR_enter(ERROR_CONTEXT *err)
{
err->prev = ERROR_current;
err->info.code = 0;
//err->info.free = FALSE;
//err->info.msg = NULL;
//err->info.backtrace = NULL;
ERROR_current = err;
#if DEBUG_ERROR
fprintf(stderr, "ERROR_enter: (%p)\n", ERROR_current);
fprintf(stderr, ">> ERROR_enter");
{
ERROR_CONTEXT *e = err;
while (e)
{
fprintf(stderr, " -> %p", e);
e = e->prev;
}
fprintf(stderr, "\n");
}
#endif
}
#endif
#if 0
******** Merged /branches/64bits r918:1003 into /trunk [CONFIGURATION] * NEW: 64 bits port. [EXAMPLES] * BUG: Fixed the AnalogWatch example. [WIKI CGI SCRIPT] * NEW: Some little cosmetic changes. [INTERPRETER] * NEW: The extern function implementation has been redesigned and is now based on libffi, so that it works on 64 bits system. Because of a flaw in the compiler design, projects that use the Pointer datatype must be recompiled to be used on a 64 bits system. This flaw will be fixed in Gambas 3. * OPT: Put some tables into read-only memory. About 1000 bytes are saved for each running interpreter, except the first one. * BUG: Does not crash anymore if a component cannot be loaded. * NEW: Spanish translation updated. * NEW: A new interpreter API for returning a pointer. [COMPILER] * BUG: Correctly compiles LONG constants inside code. [GB.DEBUG] * BUG: Compiles and links the gb.debug components with the thread libraries. [GB.DB.SQLITE3] * BUG: Getting the primary index of a table without primary index is safe now. [GB.GTK] * BUG: Modified the GLib priority of watched descriptors, as the main loop could enter in a loop in which user interface events were not managed. * BUG: Message boxes use application title without crashing now. [GB.OPENGL] * BUG: Disable dead code. [GB.QT.EXT] * BUG: TextEdit.TextWidth and TextEdit.TextHeight were not declared as read-only properties. [GB.XML.XSLT] * BUG: XSLT class is now declared as being not creatable. git-svn-id: svn://localhost/gambas/trunk@1006 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-01-17 22:39:26 +01:00
void ERROR_leave(ERROR_CONTEXT *err)
{
if (err->prev == ERROR_LEAVE_DONE)
return;
#if DEBUG_ERROR
fprintf(stderr, "<< ERROR_leave");
{
ERROR_CONTEXT *e = err;
while (e)
{
fprintf(stderr, " -> %p", e);
e = e->prev;
}
fprintf(stderr, " : %d %s\n", err->info.code, err->info.msg);
}
#endif
//if (!err->prev)
// BREAKPOINT();
ERROR_current = err->prev;
if (ERROR_current)
{
#if DEBUG_ERROR
fprintf(stderr, "ERROR_leave: (%p)\n", ERROR_current);
#endif
if (err->info.code)
{
ERROR_reset(&ERROR_current->info);
ERROR_current->info = err->info;
}
}
else
ERROR_reset(&err->info);
err->prev = ERROR_LEAVE_DONE;
//ERROR_reset(err);
}
#endif
void ERROR_propagate()
{
ERROR_HANDLER *ph, *prev;
#if DEBUG_ERROR
ERROR_debug("ERROR_propagate: %p %d %s (ret = %d)\n", ERROR_current, ERROR_current->info.code, ERROR_current->info.msg, ERROR_current->ret);
#endif
//fprintf(stderr, "ERROR_propagate: %p\n", ERROR_handler);
if (ERROR_in_catch(ERROR_current))
ERROR_leave(ERROR_current);
while (ERROR_handler)
{
ph = ERROR_handler;
if (ERROR_current && ERROR_current->handler == ph)
break;
//fprintf(stderr, "ERROR_propagate: %p @ %p (%p)\n", ERROR_handler, ERROR_handler->context, ERROR_current);
prev = ph->prev;
(*ph->handler)(ph->arg1, ph->arg2);
ERROR_handler = prev;
}
longjmp(ERROR_current->env, 1);
}
******** Merged /branches/64bits r918:1003 into /trunk [CONFIGURATION] * NEW: 64 bits port. [EXAMPLES] * BUG: Fixed the AnalogWatch example. [WIKI CGI SCRIPT] * NEW: Some little cosmetic changes. [INTERPRETER] * NEW: The extern function implementation has been redesigned and is now based on libffi, so that it works on 64 bits system. Because of a flaw in the compiler design, projects that use the Pointer datatype must be recompiled to be used on a 64 bits system. This flaw will be fixed in Gambas 3. * OPT: Put some tables into read-only memory. About 1000 bytes are saved for each running interpreter, except the first one. * BUG: Does not crash anymore if a component cannot be loaded. * NEW: Spanish translation updated. * NEW: A new interpreter API for returning a pointer. [COMPILER] * BUG: Correctly compiles LONG constants inside code. [GB.DEBUG] * BUG: Compiles and links the gb.debug components with the thread libraries. [GB.DB.SQLITE3] * BUG: Getting the primary index of a table without primary index is safe now. [GB.GTK] * BUG: Modified the GLib priority of watched descriptors, as the main loop could enter in a loop in which user interface events were not managed. * BUG: Message boxes use application title without crashing now. [GB.OPENGL] * BUG: Disable dead code. [GB.QT.EXT] * BUG: TextEdit.TextWidth and TextEdit.TextHeight were not declared as read-only properties. [GB.XML.XSLT] * BUG: XSLT class is now declared as being not creatable. git-svn-id: svn://localhost/gambas/trunk@1006 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-01-17 22:39:26 +01:00
const char *ERROR_get(void)
{
/*
if (code > 0 && code < 256)
return strerror(code);
else
return ERROR_Message[code - 256];
*/
return strerror(errno);
}
static int get_message_length(const char *pattern, char *arg[], int narg)
[DEVELOPMENT ENVIRONMENT] * NEW: English and french tips were updated. A new tip was added. * NEW: Files that were opened at project close are automatically reopened   when the project is loaded again. * NEW: A warning message is displayed when the GNU translation tools are not installed. * BUG: The code editor method combo-box is correctly updated now. * BUG: Some fixes in the automatic completion. * BUG: Replace points by dash in the name of packages generated by the IDE packager. * NEW: Updated russian translation * NEW: Updated french translation [DATABASE MANAGER] * NEW: Updated russian translation [EXAMPLES] * BUG: Fixed the Gravity and the GameOfLife examples so that they do not   use public form controls anymore. [INTERPRETER] * OPT: Many optimizations in the string substitution routines, the internal datatype conversions, the INPUT and LINE INPUT instructions, the error messages generation, the object and string reference counting, and the memory allocation routines. * NEW: Opening a device file in direct mode (FOR READ/WRITE) is now automatically non blocking. * OPT: Lof() now only tries its different methods (ioctl and lseek) once. * BUG: Val() now ignores thousand separators characters at the end of the number. * NEW: A new flag for enabling the stack trace generation at each error. [GB.DEBUG] * BUG: The gb.debug component interface declaration was not 64-bits aware. [GB.EVAL] * BUG: The Highlight.Purge() method now correctly deals with non-ASCII characters. [GB.FORM] * BUG: TableView.Edit() does not raise a "read-only combo-box" error anymore. [GB.FORM.DIALOG] * BUG: Dialog buttons now are never cut. [GB.GTK] * BUG: Cached drawing areas are correctly redrawn now. * BUG: Loading big images now works correctly. There is apparently a bug in the GTK+ image loader, and I found a workaround. * BUG: Message boxes correctly display the text of their buttons now. [GB.QT] * BUG: The Open, and initial Move and Resize event of embedded forms are now always raised when you call the Show method or if you set the Visible property. Before, it was raised when the embedded form was actually shown. [GB.SETTINGS] * NEW: Settings are now stored in ~/.config/gambasX, where X is the gambas version number. * BUG: Strings are correctly quoted inside the settings file now. [GB.WEB] * NEW: Application.Protocol is a new property that allows to tell the   component that the protocol is not necessarily "http". git-svn-id: svn://localhost/gambas/trunk@1153 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-03-11 14:29:47 +01:00
{
int len;
int i;
[DEVELOPMENT ENVIRONMENT] * NEW: English and french tips were updated. A new tip was added. * NEW: Files that were opened at project close are automatically reopened   when the project is loaded again. * NEW: A warning message is displayed when the GNU translation tools are not installed. * BUG: The code editor method combo-box is correctly updated now. * BUG: Some fixes in the automatic completion. * BUG: Replace points by dash in the name of packages generated by the IDE packager. * NEW: Updated russian translation * NEW: Updated french translation [DATABASE MANAGER] * NEW: Updated russian translation [EXAMPLES] * BUG: Fixed the Gravity and the GameOfLife examples so that they do not   use public form controls anymore. [INTERPRETER] * OPT: Many optimizations in the string substitution routines, the internal datatype conversions, the INPUT and LINE INPUT instructions, the error messages generation, the object and string reference counting, and the memory allocation routines. * NEW: Opening a device file in direct mode (FOR READ/WRITE) is now automatically non blocking. * OPT: Lof() now only tries its different methods (ioctl and lseek) once. * BUG: Val() now ignores thousand separators characters at the end of the number. * NEW: A new flag for enabling the stack trace generation at each error. [GB.DEBUG] * BUG: The gb.debug component interface declaration was not 64-bits aware. [GB.EVAL] * BUG: The Highlight.Purge() method now correctly deals with non-ASCII characters. [GB.FORM] * BUG: TableView.Edit() does not raise a "read-only combo-box" error anymore. [GB.FORM.DIALOG] * BUG: Dialog buttons now are never cut. [GB.GTK] * BUG: Cached drawing areas are correctly redrawn now. * BUG: Loading big images now works correctly. There is apparently a bug in the GTK+ image loader, and I found a workaround. * BUG: Message boxes correctly display the text of their buttons now. [GB.QT] * BUG: The Open, and initial Move and Resize event of embedded forms are now always raised when you call the Show method or if you set the Visible property. Before, it was raised when the embedded form was actually shown. [GB.SETTINGS] * NEW: Settings are now stored in ~/.config/gambasX, where X is the gambas version number. * BUG: Strings are correctly quoted inside the settings file now. [GB.WEB] * NEW: Application.Protocol is a new property that allows to tell the   component that the protocol is not necessarily "http". git-svn-id: svn://localhost/gambas/trunk@1153 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-03-11 14:29:47 +01:00
len = strlen(pattern) + narg;
for (i = 0; i < narg; i++)
len += strlen(arg[i]);
[DEVELOPMENT ENVIRONMENT] * NEW: English and french tips were updated. A new tip was added. * NEW: Files that were opened at project close are automatically reopened   when the project is loaded again. * NEW: A warning message is displayed when the GNU translation tools are not installed. * BUG: The code editor method combo-box is correctly updated now. * BUG: Some fixes in the automatic completion. * BUG: Replace points by dash in the name of packages generated by the IDE packager. * NEW: Updated russian translation * NEW: Updated french translation [DATABASE MANAGER] * NEW: Updated russian translation [EXAMPLES] * BUG: Fixed the Gravity and the GameOfLife examples so that they do not   use public form controls anymore. [INTERPRETER] * OPT: Many optimizations in the string substitution routines, the internal datatype conversions, the INPUT and LINE INPUT instructions, the error messages generation, the object and string reference counting, and the memory allocation routines. * NEW: Opening a device file in direct mode (FOR READ/WRITE) is now automatically non blocking. * OPT: Lof() now only tries its different methods (ioctl and lseek) once. * BUG: Val() now ignores thousand separators characters at the end of the number. * NEW: A new flag for enabling the stack trace generation at each error. [GB.DEBUG] * BUG: The gb.debug component interface declaration was not 64-bits aware. [GB.EVAL] * BUG: The Highlight.Purge() method now correctly deals with non-ASCII characters. [GB.FORM] * BUG: TableView.Edit() does not raise a "read-only combo-box" error anymore. [GB.FORM.DIALOG] * BUG: Dialog buttons now are never cut. [GB.GTK] * BUG: Cached drawing areas are correctly redrawn now. * BUG: Loading big images now works correctly. There is apparently a bug in the GTK+ image loader, and I found a workaround. * BUG: Message boxes correctly display the text of their buttons now. [GB.QT] * BUG: The Open, and initial Move and Resize event of embedded forms are now always raised when you call the Show method or if you set the Visible property. Before, it was raised when the embedded form was actually shown. [GB.SETTINGS] * NEW: Settings are now stored in ~/.config/gambasX, where X is the gambas version number. * BUG: Strings are correctly quoted inside the settings file now. [GB.WEB] * NEW: Application.Protocol is a new property that allows to tell the   component that the protocol is not necessarily "http". git-svn-id: svn://localhost/gambas/trunk@1153 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-03-11 14:29:47 +01:00
if (!EXEC_debug)
len -= narg * 3;
[DEVELOPMENT ENVIRONMENT] * NEW: English and french tips were updated. A new tip was added. * NEW: Files that were opened at project close are automatically reopened   when the project is loaded again. * NEW: A warning message is displayed when the GNU translation tools are not installed. * BUG: The code editor method combo-box is correctly updated now. * BUG: Some fixes in the automatic completion. * BUG: Replace points by dash in the name of packages generated by the IDE packager. * NEW: Updated russian translation * NEW: Updated french translation [DATABASE MANAGER] * NEW: Updated russian translation [EXAMPLES] * BUG: Fixed the Gravity and the GameOfLife examples so that they do not   use public form controls anymore. [INTERPRETER] * OPT: Many optimizations in the string substitution routines, the internal datatype conversions, the INPUT and LINE INPUT instructions, the error messages generation, the object and string reference counting, and the memory allocation routines. * NEW: Opening a device file in direct mode (FOR READ/WRITE) is now automatically non blocking. * OPT: Lof() now only tries its different methods (ioctl and lseek) once. * BUG: Val() now ignores thousand separators characters at the end of the number. * NEW: A new flag for enabling the stack trace generation at each error. [GB.DEBUG] * BUG: The gb.debug component interface declaration was not 64-bits aware. [GB.EVAL] * BUG: The Highlight.Purge() method now correctly deals with non-ASCII characters. [GB.FORM] * BUG: TableView.Edit() does not raise a "read-only combo-box" error anymore. [GB.FORM.DIALOG] * BUG: Dialog buttons now are never cut. [GB.GTK] * BUG: Cached drawing areas are correctly redrawn now. * BUG: Loading big images now works correctly. There is apparently a bug in the GTK+ image loader, and I found a workaround. * BUG: Message boxes correctly display the text of their buttons now. [GB.QT] * BUG: The Open, and initial Move and Resize event of embedded forms are now always raised when you call the Show method or if you set the Visible property. Before, it was raised when the embedded form was actually shown. [GB.SETTINGS] * NEW: Settings are now stored in ~/.config/gambasX, where X is the gambas version number. * BUG: Strings are correctly quoted inside the settings file now. [GB.WEB] * NEW: Application.Protocol is a new property that allows to tell the   component that the protocol is not necessarily "http". git-svn-id: svn://localhost/gambas/trunk@1153 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-03-11 14:29:47 +01:00
return len;
}
******** Merged /branches/64bits r918:1003 into /trunk [CONFIGURATION] * NEW: 64 bits port. [EXAMPLES] * BUG: Fixed the AnalogWatch example. [WIKI CGI SCRIPT] * NEW: Some little cosmetic changes. [INTERPRETER] * NEW: The extern function implementation has been redesigned and is now based on libffi, so that it works on 64 bits system. Because of a flaw in the compiler design, projects that use the Pointer datatype must be recompiled to be used on a 64 bits system. This flaw will be fixed in Gambas 3. * OPT: Put some tables into read-only memory. About 1000 bytes are saved for each running interpreter, except the first one. * BUG: Does not crash anymore if a component cannot be loaded. * NEW: Spanish translation updated. * NEW: A new interpreter API for returning a pointer. [COMPILER] * BUG: Correctly compiles LONG constants inside code. [GB.DEBUG] * BUG: Compiles and links the gb.debug components with the thread libraries. [GB.DB.SQLITE3] * BUG: Getting the primary index of a table without primary index is safe now. [GB.GTK] * BUG: Modified the GLib priority of watched descriptors, as the main loop could enter in a loop in which user interface events were not managed. * BUG: Message boxes use application title without crashing now. [GB.OPENGL] * BUG: Disable dead code. [GB.QT.EXT] * BUG: TextEdit.TextWidth and TextEdit.TextHeight were not declared as read-only properties. [GB.XML.XSLT] * BUG: XSLT class is now declared as being not creatable. git-svn-id: svn://localhost/gambas/trunk@1006 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-01-17 22:39:26 +01:00
void ERROR_define(const char *pattern, char *arg[])
{
uchar c;
char *msg = NULL;
int len;
int narg = 0;
ERROR_clear();
if ((intptr_t)pattern >= 0 && (intptr_t)pattern < 256)
{
ERROR_current->info.code = (int)(intptr_t)pattern;
pattern = _message[(int)(intptr_t)pattern];
if (*pattern == '.')
{
narg = pattern[1] - '0';
pattern += 2;
}
}
else if ((intptr_t)pattern == E_ABORT)
{
ERROR_current->info.code = E_ABORT;
pattern = "";
}
else
{
ERROR_current->info.code = E_CUSTOM;
if (arg)
{
msg = (char *)pattern;
for (;;)
{
c = *msg++;
if (c == 0)
break;
if (c == '&')
{
c = *msg++;
if (c >= '1' && c <= '4')
{
c -= '0';
if (c > narg)
narg = c;
}
}
}
}
}
if (narg)
{
len = get_message_length(pattern, arg, narg);
if (len)
{
msg = STRING_new(NULL, len);
ERROR_current->info.msg = msg;
ERROR_current->info.free = TRUE;
if (EXEC_debug)
{
int i;
strcpy(msg, pattern);
msg += strlen(pattern);
for (i = 0; i < narg; i++)
{
*msg++ = '|';
if (arg[i])
{
strcpy(msg, arg[i]);
msg += strlen(arg[i]);
}
}
}
else
{
for (;;)
{
c = *pattern++;
if (c == 0)
break;
if (c == '&')
{
c = *pattern++;
if (c >= '1' && c <= '4')
[DEVELOPMENT ENVIRONMENT] * NEW: Work continues on integrating the database manager. * NEW: Some cosmetic changes in the way controls are drawing on the form editor. * NEW: Panels with Border property set to None are now drawn with a light border. * BUG: Fix the "Show tab" button and menu. [INTERPRETER] * NEW: _attach is a new dynamic special method that is called when an object is attached to or detached from its event observer. The first argument of this method is the event observer, and the second argument the event handler prefix. [COMPILER] * NEW: An expression can be a NEW instruction now. Beware that it does not work inside braces. [GB.DB] * BUG: Fix an error message in the sqlite handler. [GB.DB.FORM] * NEW: DataSource.Table can now be any SQL query. The Filter property is ignored in that case. * BUG: Setting DataSource.Table to NULL correctly resets the DataSource and its children. * NEW: DataView automatically adjusts the height of its rows to the contents. * NEW: DataSource.CacheSize is a new property to set the number of rows stored in the internal DataSource cache. When this property is set to zero, the cache size takes its default value (64 rows). [GB.DB.SQLITE2] * BUG: Fix a crash in datatype mapping. [GB.DB.SQLITE3] * BUG: Fix a crash in datatype mapping. [GB.QT4] * BUG: Window.AutoResize property works as expected now. * OPT: Some optimizations in GridView. * NEW: GridView.Rows[].Visible returns if a specific row is visible. * NEW: GridView.Rows[].EnsureVisible ensures that a specific row is visible. * BUG: Draw.Style.Panel draws the same thing as a panel border now. * BUG: Window.Closed always returns the accurate value now. git-svn-id: svn://localhost/gambas/trunk@2108 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2009-07-12 23:49:13 +02:00
{
c -= '1';
if (arg[c])
{
len = strlen(arg[c]);
memcpy(msg, arg[c], len);
msg += len;
}
[DEVELOPMENT ENVIRONMENT] * NEW: Work continues on integrating the database manager. * NEW: Some cosmetic changes in the way controls are drawing on the form editor. * NEW: Panels with Border property set to None are now drawn with a light border. * BUG: Fix the "Show tab" button and menu. [INTERPRETER] * NEW: _attach is a new dynamic special method that is called when an object is attached to or detached from its event observer. The first argument of this method is the event observer, and the second argument the event handler prefix. [COMPILER] * NEW: An expression can be a NEW instruction now. Beware that it does not work inside braces. [GB.DB] * BUG: Fix an error message in the sqlite handler. [GB.DB.FORM] * NEW: DataSource.Table can now be any SQL query. The Filter property is ignored in that case. * BUG: Setting DataSource.Table to NULL correctly resets the DataSource and its children. * NEW: DataView automatically adjusts the height of its rows to the contents. * NEW: DataSource.CacheSize is a new property to set the number of rows stored in the internal DataSource cache. When this property is set to zero, the cache size takes its default value (64 rows). [GB.DB.SQLITE2] * BUG: Fix a crash in datatype mapping. [GB.DB.SQLITE3] * BUG: Fix a crash in datatype mapping. [GB.QT4] * BUG: Window.AutoResize property works as expected now. * OPT: Some optimizations in GridView. * NEW: GridView.Rows[].Visible returns if a specific row is visible. * NEW: GridView.Rows[].EnsureVisible ensures that a specific row is visible. * BUG: Draw.Style.Panel draws the same thing as a panel border now. * BUG: Window.Closed always returns the accurate value now. git-svn-id: svn://localhost/gambas/trunk@2108 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2009-07-12 23:49:13 +02:00
}
}
else
*msg++ = c;
}
*msg = 0;
}
/*fprintf(stderr, "msg: %s\n", ERROR_current->info.msg);
if (strcmp(ERROR_current->info.msg, "Type mismatch: wanted WebView, got Function instead") == 0)
{
BREAKPOINT();
STRING_watch = ERROR_current->info.msg;
}*/
}
}
else if (ERROR_current->info.code == E_CUSTOM)
{
if (pattern && *pattern)
{
ERROR_current->info.msg = STRING_new_zero(pattern);
ERROR_current->info.free = TRUE;
}
else
{
ERROR_current->info.msg = (char *)_message[E_UNKNOWN];
ERROR_current->info.free = FALSE;
}
}
else
{
ERROR_current->info.msg = (char *)pattern;
ERROR_current->info.free = FALSE;
}
//fprintf(stderr, "ERROR_define: %p %d '%s'\n", ERROR_current, ERROR_current->info.code, ERROR_current->info.msg);
//STRING_add_char(&ERROR_current->info.msg, 0);
ERROR_current->info.cp = CP;
ERROR_current->info.fp = FP;
ERROR_current->info.pc = PC;
#if DEBUG_ERROR
ERROR_debug("ERROR_define: %s\n", ERROR_current->info.msg);
#endif
}
******** Merged /branches/64bits r918:1003 into /trunk [CONFIGURATION] * NEW: 64 bits port. [EXAMPLES] * BUG: Fixed the AnalogWatch example. [WIKI CGI SCRIPT] * NEW: Some little cosmetic changes. [INTERPRETER] * NEW: The extern function implementation has been redesigned and is now based on libffi, so that it works on 64 bits system. Because of a flaw in the compiler design, projects that use the Pointer datatype must be recompiled to be used on a 64 bits system. This flaw will be fixed in Gambas 3. * OPT: Put some tables into read-only memory. About 1000 bytes are saved for each running interpreter, except the first one. * BUG: Does not crash anymore if a component cannot be loaded. * NEW: Spanish translation updated. * NEW: A new interpreter API for returning a pointer. [COMPILER] * BUG: Correctly compiles LONG constants inside code. [GB.DEBUG] * BUG: Compiles and links the gb.debug components with the thread libraries. [GB.DB.SQLITE3] * BUG: Getting the primary index of a table without primary index is safe now. [GB.GTK] * BUG: Modified the GLib priority of watched descriptors, as the main loop could enter in a loop in which user interface events were not managed. * BUG: Message boxes use application title without crashing now. [GB.OPENGL] * BUG: Disable dead code. [GB.QT.EXT] * BUG: TextEdit.TextWidth and TextEdit.TextHeight were not declared as read-only properties. [GB.XML.XSLT] * BUG: XSLT class is now declared as being not creatable. git-svn-id: svn://localhost/gambas/trunk@1006 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-01-17 22:39:26 +01:00
void THROW(int code, ...)
{
va_list args;
int i;
char *arg[4];
va_start(args, code);
for (i = 0; i < 4; i++)
arg[i] = va_arg(args, char *);
ERROR_define((char *)(intptr_t)code, arg);
va_end(args);
PROPAGATE();
}
void THROW_CLASS(void *class, char *arg1, char *arg2)
{
THROW(E_CLASS, CLASS_get_name((CLASS *)class), arg1, arg2);
}
void THROW_ILLEGAL()
{
THROW(E_ILLEGAL);
}
void THROW_STACK()
{
#if DEBUG_STACK
fprintf(stderr, "THROW STACK!\n");
#endif
THROW(E_STACK);
}
******** Merged /branches/64bits r918:1003 into /trunk [CONFIGURATION] * NEW: 64 bits port. [EXAMPLES] * BUG: Fixed the AnalogWatch example. [WIKI CGI SCRIPT] * NEW: Some little cosmetic changes. [INTERPRETER] * NEW: The extern function implementation has been redesigned and is now based on libffi, so that it works on 64 bits system. Because of a flaw in the compiler design, projects that use the Pointer datatype must be recompiled to be used on a 64 bits system. This flaw will be fixed in Gambas 3. * OPT: Put some tables into read-only memory. About 1000 bytes are saved for each running interpreter, except the first one. * BUG: Does not crash anymore if a component cannot be loaded. * NEW: Spanish translation updated. * NEW: A new interpreter API for returning a pointer. [COMPILER] * BUG: Correctly compiles LONG constants inside code. [GB.DEBUG] * BUG: Compiles and links the gb.debug components with the thread libraries. [GB.DB.SQLITE3] * BUG: Getting the primary index of a table without primary index is safe now. [GB.GTK] * BUG: Modified the GLib priority of watched descriptors, as the main loop could enter in a loop in which user interface events were not managed. * BUG: Message boxes use application title without crashing now. [GB.OPENGL] * BUG: Disable dead code. [GB.QT.EXT] * BUG: TextEdit.TextWidth and TextEdit.TextHeight were not declared as read-only properties. [GB.XML.XSLT] * BUG: XSLT class is now declared as being not creatable. git-svn-id: svn://localhost/gambas/trunk@1006 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-01-17 22:39:26 +01:00
void THROW_SYSTEM(int err, const char *path)
{
char buf[6];
switch(err)
{
case ENOENT:
THROW(E_NEXIST, path);
case EISDIR:
THROW(E_DIR, path);
case ENOTDIR:
THROW(E_NDIR, path);
case ENOMEM:
THROW(E_MEMORY);
case EACCES:
THROW(E_ACCESS);
case ENAMETOOLONG:
THROW(E_TOOLONG);
case ENOSPC:
THROW(E_FULL);
case EEXIST:
THROW(E_EXIST, path);
default:
sprintf(buf, "%d", err);
THROW(E_SYSTEM, buf, strerror(err));
}
}
void ERROR_fatal(const char *error, ...)
{
va_list args;
va_start(args, error);
fputs(EXEC_arch ? "gbr" GAMBAS_VERSION_STRING : "gbx" GAMBAS_VERSION_STRING, stderr);
fputs(": ", stderr);
vfprintf(stderr, error, args);
va_end(args);
putc('\n', stderr);
_exit(1);
}
******** Merged /branches/64bits r918:1003 into /trunk [CONFIGURATION] * NEW: 64 bits port. [EXAMPLES] * BUG: Fixed the AnalogWatch example. [WIKI CGI SCRIPT] * NEW: Some little cosmetic changes. [INTERPRETER] * NEW: The extern function implementation has been redesigned and is now based on libffi, so that it works on 64 bits system. Because of a flaw in the compiler design, projects that use the Pointer datatype must be recompiled to be used on a 64 bits system. This flaw will be fixed in Gambas 3. * OPT: Put some tables into read-only memory. About 1000 bytes are saved for each running interpreter, except the first one. * BUG: Does not crash anymore if a component cannot be loaded. * NEW: Spanish translation updated. * NEW: A new interpreter API for returning a pointer. [COMPILER] * BUG: Correctly compiles LONG constants inside code. [GB.DEBUG] * BUG: Compiles and links the gb.debug components with the thread libraries. [GB.DB.SQLITE3] * BUG: Getting the primary index of a table without primary index is safe now. [GB.GTK] * BUG: Modified the GLib priority of watched descriptors, as the main loop could enter in a loop in which user interface events were not managed. * BUG: Message boxes use application title without crashing now. [GB.OPENGL] * BUG: Disable dead code. [GB.QT.EXT] * BUG: TextEdit.TextWidth and TextEdit.TextHeight were not declared as read-only properties. [GB.XML.XSLT] * BUG: XSLT class is now declared as being not creatable. git-svn-id: svn://localhost/gambas/trunk@1006 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-01-17 22:39:26 +01:00
void ERROR_panic(const char *error, ...)
{
va_list args;
va_start(args, error);
fflush(NULL);
fprintf(stderr, "\n** Oops! Internal error! **\n** ");
vfprintf(stderr, error, args);
va_end(args);
putc('\n', stderr);
if (ERROR_current->info.code)
{
ERROR_print();
}
fprintf(stderr, "** Program aborting. Sorry! :-(\n** Please send a bug report at gambas@users.sourceforge.net\n");
_exit(1);
}
******** Merged /branches/64bits r918:1003 into /trunk [CONFIGURATION] * NEW: 64 bits port. [EXAMPLES] * BUG: Fixed the AnalogWatch example. [WIKI CGI SCRIPT] * NEW: Some little cosmetic changes. [INTERPRETER] * NEW: The extern function implementation has been redesigned and is now based on libffi, so that it works on 64 bits system. Because of a flaw in the compiler design, projects that use the Pointer datatype must be recompiled to be used on a 64 bits system. This flaw will be fixed in Gambas 3. * OPT: Put some tables into read-only memory. About 1000 bytes are saved for each running interpreter, except the first one. * BUG: Does not crash anymore if a component cannot be loaded. * NEW: Spanish translation updated. * NEW: A new interpreter API for returning a pointer. [COMPILER] * BUG: Correctly compiles LONG constants inside code. [GB.DEBUG] * BUG: Compiles and links the gb.debug components with the thread libraries. [GB.DB.SQLITE3] * BUG: Getting the primary index of a table without primary index is safe now. [GB.GTK] * BUG: Modified the GLib priority of watched descriptors, as the main loop could enter in a loop in which user interface events were not managed. * BUG: Message boxes use application title without crashing now. [GB.OPENGL] * BUG: Disable dead code. [GB.QT.EXT] * BUG: TextEdit.TextWidth and TextEdit.TextHeight were not declared as read-only properties. [GB.XML.XSLT] * BUG: XSLT class is now declared as being not creatable. git-svn-id: svn://localhost/gambas/trunk@1006 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-01-17 22:39:26 +01:00
void ERROR_print_at(FILE *where, bool msgonly, bool newline)
{
if (!ERROR_current->info.code)
return;
if (!msgonly)
{
if (ERROR_current->info.cp && ERROR_current->info.fp && ERROR_current->info.pc)
fprintf(where, "%s: ", DEBUG_get_position(ERROR_current->info.cp, ERROR_current->info.fp, ERROR_current->info.pc));
else
fprintf(where, "ERROR: ");
/*if (ERROR_current->info.code > 0 && ERROR_current->info.code < 256)
fprintf(where, "%ld:", ERROR_current->info.code);*/
if (ERROR_current->info.code > 0)
fprintf(where, "#%d: ", ERROR_current->info.code);
if (ERROR_current->info.msg)
fprintf(where, "%s", ERROR_current->info.msg);
}
else
{
char *p = ERROR_current->info.msg;
unsigned char c;
if (p)
{
while ((c = *p++))
{
if (c < ' ') c = ' ';
fputc(c, where);
}
}
}
if (newline)
fputc('\n', where);
}
******** Merged /branches/64bits r918:1003 into /trunk [CONFIGURATION] * NEW: 64 bits port. [EXAMPLES] * BUG: Fixed the AnalogWatch example. [WIKI CGI SCRIPT] * NEW: Some little cosmetic changes. [INTERPRETER] * NEW: The extern function implementation has been redesigned and is now based on libffi, so that it works on 64 bits system. Because of a flaw in the compiler design, projects that use the Pointer datatype must be recompiled to be used on a 64 bits system. This flaw will be fixed in Gambas 3. * OPT: Put some tables into read-only memory. About 1000 bytes are saved for each running interpreter, except the first one. * BUG: Does not crash anymore if a component cannot be loaded. * NEW: Spanish translation updated. * NEW: A new interpreter API for returning a pointer. [COMPILER] * BUG: Correctly compiles LONG constants inside code. [GB.DEBUG] * BUG: Compiles and links the gb.debug components with the thread libraries. [GB.DB.SQLITE3] * BUG: Getting the primary index of a table without primary index is safe now. [GB.GTK] * BUG: Modified the GLib priority of watched descriptors, as the main loop could enter in a loop in which user interface events were not managed. * BUG: Message boxes use application title without crashing now. [GB.OPENGL] * BUG: Disable dead code. [GB.QT.EXT] * BUG: TextEdit.TextWidth and TextEdit.TextHeight were not declared as read-only properties. [GB.XML.XSLT] * BUG: XSLT class is now declared as being not creatable. git-svn-id: svn://localhost/gambas/trunk@1006 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-01-17 22:39:26 +01:00
void ERROR_print(void)
{
static bool lock = FALSE;
if (EXEC_main_hook_done && !EXEC_debug && EXEC_Hook.error && !lock)
{
lock = TRUE;
GAMBAS_DoNotRaiseEvent = TRUE;
HOOK(error)(ERROR_current->info.code, ERROR_current->info.msg, DEBUG_get_position(ERROR_current->info.cp, ERROR_current->info.fp, ERROR_current->info.pc));
lock = FALSE;
}
ERROR_print_at(stderr, FALSE, TRUE);
if (ERROR_backtrace)
DEBUG_print_backtrace(ERROR_backtrace);
}
static void ERROR_copy(ERROR_INFO *save, ERROR_INFO *last)
{
ERROR_reset(save);
*save = ERROR_current->info;
if (last)
{
ERROR_reset(last);
*last = ERROR_last;
}
}
void ERROR_save(ERROR_INFO *save, ERROR_INFO *last)
{
ERROR_copy(save, last);
CLEAR(&ERROR_current->info);
if (last)
CLEAR(&ERROR_last);
}
void ERROR_restore(ERROR_INFO *save, ERROR_INFO *last)
{
ERROR_reset(&ERROR_current->info);
ERROR_current->info = *save;
CLEAR(save);
if (last)
{
ERROR_reset(&ERROR_last);
ERROR_last = *last;
CLEAR(last);
}
}
void ERROR_set_last(bool bt)
{
ERROR_reset(&ERROR_last);
ERROR_last = ERROR_current->info;
if (ERROR_last.free)
STRING_ref(ERROR_last.msg);
STACK_free_backtrace(&ERROR_backtrace);
if (bt)
ERROR_backtrace = STACK_get_backtrace();
[DEVELOPMENT ENVIRONMENT] * NEW: English and french tips were updated. A new tip was added. * NEW: Files that were opened at project close are automatically reopened   when the project is loaded again. * NEW: A warning message is displayed when the GNU translation tools are not installed. * BUG: The code editor method combo-box is correctly updated now. * BUG: Some fixes in the automatic completion. * BUG: Replace points by dash in the name of packages generated by the IDE packager. * NEW: Updated russian translation * NEW: Updated french translation [DATABASE MANAGER] * NEW: Updated russian translation [EXAMPLES] * BUG: Fixed the Gravity and the GameOfLife examples so that they do not   use public form controls anymore. [INTERPRETER] * OPT: Many optimizations in the string substitution routines, the internal datatype conversions, the INPUT and LINE INPUT instructions, the error messages generation, the object and string reference counting, and the memory allocation routines. * NEW: Opening a device file in direct mode (FOR READ/WRITE) is now automatically non blocking. * OPT: Lof() now only tries its different methods (ioctl and lseek) once. * BUG: Val() now ignores thousand separators characters at the end of the number. * NEW: A new flag for enabling the stack trace generation at each error. [GB.DEBUG] * BUG: The gb.debug component interface declaration was not 64-bits aware. [GB.EVAL] * BUG: The Highlight.Purge() method now correctly deals with non-ASCII characters. [GB.FORM] * BUG: TableView.Edit() does not raise a "read-only combo-box" error anymore. [GB.FORM.DIALOG] * BUG: Dialog buttons now are never cut. [GB.GTK] * BUG: Cached drawing areas are correctly redrawn now. * BUG: Loading big images now works correctly. There is apparently a bug in the GTK+ image loader, and I found a workaround. * BUG: Message boxes correctly display the text of their buttons now. [GB.QT] * BUG: The Open, and initial Move and Resize event of embedded forms are now always raised when you call the Show method or if you set the Visible property. Before, it was raised when the embedded form was actually shown. [GB.SETTINGS] * NEW: Settings are now stored in ~/.config/gambasX, where X is the gambas version number. * BUG: Strings are correctly quoted inside the settings file now. [GB.WEB] * NEW: Application.Protocol is a new property that allows to tell the   component that the protocol is not necessarily "http". git-svn-id: svn://localhost/gambas/trunk@1153 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-03-11 14:29:47 +01:00
}
void ERROR_define_last(void)
{
ERROR_reset(&ERROR_current->info);
ERROR_current->info = ERROR_last;
if (ERROR_last.free)
STRING_ref(ERROR_last.msg);
}
void ERROR_warning(const char *warning, ...)
{
va_list args;
va_start(args, warning);
fflush(NULL);
fprintf(stderr, "gbx" GAMBAS_VERSION_STRING ": warning: ");
vfprintf(stderr, warning, args);
va_end(args);
putc('\n', stderr);
}
/*void ERROR_deprecated(const char *msg)
{
ERROR_warning("%s: %s is deprecated.", DEBUG_get_current_position(), msg);
}*/
void ERROR_exit(void)
{
ERROR_reset(&ERROR_last);
STACK_free_backtrace(&ERROR_backtrace);
}
void ERROR_hook(void)
{
static bool no_rec = FALSE;
ERROR_INFO save = { 0 };
ERROR_INFO last = { 0 };
CLASS_DESC_METHOD *handle_error;
if (no_rec)
return;
if (PROJECT_class && PROJECT_class->state)
{
handle_error = (CLASS_DESC_METHOD *)CLASS_get_symbol_desc_kind(PROJECT_class, "Application_Error", CD_STATIC_METHOD, 0);
if (handle_error)
{
no_rec = TRUE;
ERROR_save(&save, &last);
TRY
{
EXEC_public_desc(PROJECT_class, NULL, handle_error, 0);
}
CATCH
{
ERROR_save(&save, &last);
}
END_TRY
ERROR_restore(&save, &last);
no_rec = FALSE;
}
}
}