gambas-source-code/main/gbx/gbx_object.h

235 lines
5.9 KiB
C
Raw Normal View History

/***************************************************************************
gbx_object.h
(c) 2000-2017 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.
***************************************************************************/
#ifndef __OBJECT_H
#define __OBJECT_H
#include "gbx_debug.h"
#include "gbx_value.h"
#include "gbx_class.h"
#ifndef __OBJECT_C
EXTERN void **OBJECT_set_pointer;
#endif
typedef
struct {
CLASS *class;
intptr_t ref;
}
OBJECT;
typedef
struct {
OBJECT *parent;
OBJECT *next;
OBJECT *prev;
void *observer;
short locked;
ushort event[0];
}
PACKED
OBJECT_EVENT;
#define OBJECT_event(_object) ((OBJECT_EVENT *)((intptr_t *)_object + ((OBJECT *)(_object))->class->off_event / sizeof(intptr_t)))
#define OBJECT_is(_object, _class) (OBJECT_class(_object) == _class)
#define OBJECT_is_class(_object) OBJECT_is(_object, CLASS_Class)
#define OBJECT_class(_object) (((OBJECT *)_object)->class)
#define OBJECT_class_null(_object) ((_object) ? ((OBJECT *)_object)->class : NULL)
#define OBJECT_count(_object) (((OBJECT *)_object)->ref)
#define OBJECT_are_null(_o1, _o2) (((intptr_t)(_o1) | (intptr_t)(_o2)) == 0)
#define OBJECT_are_not_null(_o1, _o2) ((_o1) && (_o2))
void *OBJECT_new(CLASS *class, const char *name, OBJECT *parent);
******** 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 OBJECT_attach(OBJECT *ob, OBJECT *parent, const char *name);
void OBJECT_detach(OBJECT *ob);
void OBJECT_release(CLASS *class, OBJECT *ob);
void OBJECT_release_static(CLASS *class, CLASS_VAR *var, int nelt, char *data);
//void OBJECT_free(CLASS *class, OBJECT *ob);
******** 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 OBJECT_lock(OBJECT *ob, bool block);
bool OBJECT_is_locked(OBJECT *ob);
//void *OBJECT_alloc(CLASS *class, size_t size);
******** 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
bool OBJECT_comp_value(VALUE *ob1, VALUE *ob2);
******** 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 OBJECT_exit(void);
void *OBJECT_create(CLASS *class, const char *name, void *parent, int nparam);
void *OBJECT_create_native(CLASS *class, VALUE *param);
#define OBJECT_create_and_set(_ptr, _class, _name, _parent, _nparam) \
((OBJECT_set_pointer = (_ptr)), \
OBJECT_create((_class), (_name), (_parent), (_nparam)))
#define OBJECT_is_valid(_object) ((_object) && !(((OBJECT *)_object)->class->check && (*((OBJECT *)_object)->class->check)(_object)))
#define OBJECT_has_events(_object) (((OBJECT *)_object)->class->n_event != 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
OBJECT *OBJECT_parent(void *object);
OBJECT *OBJECT_active_parent(void *object);
/*
static INLINE CLASS *OBJECT_class(void *object)
{
if (object)
return ((OBJECT *)object)->class;
else
return object;
}
*/
/*#define DEBUG_REF 1*/
#if DEBUG_REF
#if OS_64BITS
#define FREE_MARK ((CLASS *)0x2323232323232323LL)
#else
#define FREE_MARK ((CLASS *)0x23232323)
#endif
EXTERN const char *OBJECT_ref_where;
char *OBJECT_where_am_i(const char *file, int line, const char *func);
#define OBJECT_ref(_object) \
{ \
[WIKI CGI SCRIPT] * NEW: Do not use <pre> markups, they cannot break lines. [DEVELOPMENT ENVIRONMENT] * NEW: Replace anonymous object arrays by template arrays. * NEW: A button that clears the shortcut in the menu editor. * NEW: When evaluating expression in the console, a semi-colon at the end of the expression prevents the end newline to be printed, like in the PRINT instruction. * NEW: CTRL+G in the console makes it flash. * OPT: Remove the CCoolTabs class, that was not used anymore. * NEW: The main selected control is unselectable in the form editor now. * NEW: Selected controls can be resized by pressing CTRL and an arrow key. * NEW: Some form editor shortcuts have been changed to not conflict with the previous feature. * BUG: Fix the horizontal position of the automatic completion. * BUG: Look in project classes before component classes in automatic completion. [INTERPRETER] * BUG: Fix the memory allocation debug routines. * BUG: When instanciating a template array class, search for element class symbol locally first. * BUG: Template arrays now correctly release their elements. * NEW: Update copyright year in gb_common.h header file. [COMPILER] * BUG: Manage .list and .info files incrementally, so that they are up to date even when the project is not fully compiled. * BUG: Float and Single constants are correctly written in the .info file. [GB.QT.EXT] * BUG: Fix some painting artifacts in Editor. * BUG: In Editor, Undo and Redo now should always work correctly when a line is rewritten. * NEW: In Editor, when a line is rewritten, the Change event is always emitted. * NEW: The Editor is cleared now when it prints a CTRL+L character. * NEW: The Editor flashes now when it prints a CTRL+G character. git-svn-id: svn://localhost/gambas/trunk@1576 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-09-22 01:22:07 +02:00
if (_object) \
{ \
if (OBJECT_class(_object) == FREE_MARK) \
[WIKI CGI SCRIPT] * NEW: Do not use <pre> markups, they cannot break lines. [DEVELOPMENT ENVIRONMENT] * NEW: Replace anonymous object arrays by template arrays. * NEW: A button that clears the shortcut in the menu editor. * NEW: When evaluating expression in the console, a semi-colon at the end of the expression prevents the end newline to be printed, like in the PRINT instruction. * NEW: CTRL+G in the console makes it flash. * OPT: Remove the CCoolTabs class, that was not used anymore. * NEW: The main selected control is unselectable in the form editor now. * NEW: Selected controls can be resized by pressing CTRL and an arrow key. * NEW: Some form editor shortcuts have been changed to not conflict with the previous feature. * BUG: Fix the horizontal position of the automatic completion. * BUG: Look in project classes before component classes in automatic completion. [INTERPRETER] * BUG: Fix the memory allocation debug routines. * BUG: When instanciating a template array class, search for element class symbol locally first. * BUG: Template arrays now correctly release their elements. * NEW: Update copyright year in gb_common.h header file. [COMPILER] * BUG: Manage .list and .info files incrementally, so that they are up to date even when the project is not fully compiled. * BUG: Float and Single constants are correctly written in the .info file. [GB.QT.EXT] * BUG: Fix some painting artifacts in Editor. * BUG: In Editor, Undo and Redo now should always work correctly when a line is rewritten. * NEW: In Editor, when a line is rewritten, the Change event is always emitted. * NEW: The Editor is cleared now when it prints a CTRL+L character. * NEW: The Editor flashes now when it prints a CTRL+G character. git-svn-id: svn://localhost/gambas/trunk@1576 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-09-22 01:22:07 +02:00
{ \
fprintf(stderr, "%s: **** ALREADY FREED **** %p\n", OBJECT_ref_where, (_object)); \
[WIKI CGI SCRIPT] * NEW: Do not use <pre> markups, they cannot break lines. [DEVELOPMENT ENVIRONMENT] * NEW: Replace anonymous object arrays by template arrays. * NEW: A button that clears the shortcut in the menu editor. * NEW: When evaluating expression in the console, a semi-colon at the end of the expression prevents the end newline to be printed, like in the PRINT instruction. * NEW: CTRL+G in the console makes it flash. * OPT: Remove the CCoolTabs class, that was not used anymore. * NEW: The main selected control is unselectable in the form editor now. * NEW: Selected controls can be resized by pressing CTRL and an arrow key. * NEW: Some form editor shortcuts have been changed to not conflict with the previous feature. * BUG: Fix the horizontal position of the automatic completion. * BUG: Look in project classes before component classes in automatic completion. [INTERPRETER] * BUG: Fix the memory allocation debug routines. * BUG: When instanciating a template array class, search for element class symbol locally first. * BUG: Template arrays now correctly release their elements. * NEW: Update copyright year in gb_common.h header file. [COMPILER] * BUG: Manage .list and .info files incrementally, so that they are up to date even when the project is not fully compiled. * BUG: Float and Single constants are correctly written in the .info file. [GB.QT.EXT] * BUG: Fix some painting artifacts in Editor. * BUG: In Editor, Undo and Redo now should always work correctly when a line is rewritten. * NEW: In Editor, when a line is rewritten, the Change event is always emitted. * NEW: The Editor is cleared now when it prints a CTRL+L character. * NEW: The Editor flashes now when it prints a CTRL+G character. git-svn-id: svn://localhost/gambas/trunk@1576 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-09-22 01:22:07 +02:00
fflush(NULL); \
BREAKPOINT(); \
[WIKI CGI SCRIPT] * NEW: Do not use <pre> markups, they cannot break lines. [DEVELOPMENT ENVIRONMENT] * NEW: Replace anonymous object arrays by template arrays. * NEW: A button that clears the shortcut in the menu editor. * NEW: When evaluating expression in the console, a semi-colon at the end of the expression prevents the end newline to be printed, like in the PRINT instruction. * NEW: CTRL+G in the console makes it flash. * OPT: Remove the CCoolTabs class, that was not used anymore. * NEW: The main selected control is unselectable in the form editor now. * NEW: Selected controls can be resized by pressing CTRL and an arrow key. * NEW: Some form editor shortcuts have been changed to not conflict with the previous feature. * BUG: Fix the horizontal position of the automatic completion. * BUG: Look in project classes before component classes in automatic completion. [INTERPRETER] * BUG: Fix the memory allocation debug routines. * BUG: When instanciating a template array class, search for element class symbol locally first. * BUG: Template arrays now correctly release their elements. * NEW: Update copyright year in gb_common.h header file. [COMPILER] * BUG: Manage .list and .info files incrementally, so that they are up to date even when the project is not fully compiled. * BUG: Float and Single constants are correctly written in the .info file. [GB.QT.EXT] * BUG: Fix some painting artifacts in Editor. * BUG: In Editor, Undo and Redo now should always work correctly when a line is rewritten. * NEW: In Editor, when a line is rewritten, the Change event is always emitted. * NEW: The Editor is cleared now when it prints a CTRL+L character. * NEW: The Editor flashes now when it prints a CTRL+G character. git-svn-id: svn://localhost/gambas/trunk@1576 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-09-22 01:22:07 +02:00
} \
CLASS_ref(_object); \
} \
}
[WIKI CGI SCRIPT] * NEW: Do not use <pre> markups, they cannot break lines. [DEVELOPMENT ENVIRONMENT] * NEW: Replace anonymous object arrays by template arrays. * NEW: A button that clears the shortcut in the menu editor. * NEW: When evaluating expression in the console, a semi-colon at the end of the expression prevents the end newline to be printed, like in the PRINT instruction. * NEW: CTRL+G in the console makes it flash. * OPT: Remove the CCoolTabs class, that was not used anymore. * NEW: The main selected control is unselectable in the form editor now. * NEW: Selected controls can be resized by pressing CTRL and an arrow key. * NEW: Some form editor shortcuts have been changed to not conflict with the previous feature. * BUG: Fix the horizontal position of the automatic completion. * BUG: Look in project classes before component classes in automatic completion. [INTERPRETER] * BUG: Fix the memory allocation debug routines. * BUG: When instanciating a template array class, search for element class symbol locally first. * BUG: Template arrays now correctly release their elements. * NEW: Update copyright year in gb_common.h header file. [COMPILER] * BUG: Manage .list and .info files incrementally, so that they are up to date even when the project is not fully compiled. * BUG: Float and Single constants are correctly written in the .info file. [GB.QT.EXT] * BUG: Fix some painting artifacts in Editor. * BUG: In Editor, Undo and Redo now should always work correctly when a line is rewritten. * NEW: In Editor, when a line is rewritten, the Change event is always emitted. * NEW: The Editor is cleared now when it prints a CTRL+L character. * NEW: The Editor flashes now when it prints a CTRL+G character. git-svn-id: svn://localhost/gambas/trunk@1576 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-09-22 01:22:07 +02:00
#define OBJECT_unref(_object) \
{ \
[WIKI CGI SCRIPT] * NEW: Do not use <pre> markups, they cannot break lines. [DEVELOPMENT ENVIRONMENT] * NEW: Replace anonymous object arrays by template arrays. * NEW: A button that clears the shortcut in the menu editor. * NEW: When evaluating expression in the console, a semi-colon at the end of the expression prevents the end newline to be printed, like in the PRINT instruction. * NEW: CTRL+G in the console makes it flash. * OPT: Remove the CCoolTabs class, that was not used anymore. * NEW: The main selected control is unselectable in the form editor now. * NEW: Selected controls can be resized by pressing CTRL and an arrow key. * NEW: Some form editor shortcuts have been changed to not conflict with the previous feature. * BUG: Fix the horizontal position of the automatic completion. * BUG: Look in project classes before component classes in automatic completion. [INTERPRETER] * BUG: Fix the memory allocation debug routines. * BUG: When instanciating a template array class, search for element class symbol locally first. * BUG: Template arrays now correctly release their elements. * NEW: Update copyright year in gb_common.h header file. [COMPILER] * BUG: Manage .list and .info files incrementally, so that they are up to date even when the project is not fully compiled. * BUG: Float and Single constants are correctly written in the .info file. [GB.QT.EXT] * BUG: Fix some painting artifacts in Editor. * BUG: In Editor, Undo and Redo now should always work correctly when a line is rewritten. * NEW: In Editor, when a line is rewritten, the Change event is always emitted. * NEW: The Editor is cleared now when it prints a CTRL+L character. * NEW: The Editor flashes now when it prints a CTRL+G character. git-svn-id: svn://localhost/gambas/trunk@1576 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-09-22 01:22:07 +02:00
if (_object) \
{ \
if (OBJECT_class(_object) == FREE_MARK) \
[WIKI CGI SCRIPT] * NEW: Do not use <pre> markups, they cannot break lines. [DEVELOPMENT ENVIRONMENT] * NEW: Replace anonymous object arrays by template arrays. * NEW: A button that clears the shortcut in the menu editor. * NEW: When evaluating expression in the console, a semi-colon at the end of the expression prevents the end newline to be printed, like in the PRINT instruction. * NEW: CTRL+G in the console makes it flash. * OPT: Remove the CCoolTabs class, that was not used anymore. * NEW: The main selected control is unselectable in the form editor now. * NEW: Selected controls can be resized by pressing CTRL and an arrow key. * NEW: Some form editor shortcuts have been changed to not conflict with the previous feature. * BUG: Fix the horizontal position of the automatic completion. * BUG: Look in project classes before component classes in automatic completion. [INTERPRETER] * BUG: Fix the memory allocation debug routines. * BUG: When instanciating a template array class, search for element class symbol locally first. * BUG: Template arrays now correctly release their elements. * NEW: Update copyright year in gb_common.h header file. [COMPILER] * BUG: Manage .list and .info files incrementally, so that they are up to date even when the project is not fully compiled. * BUG: Float and Single constants are correctly written in the .info file. [GB.QT.EXT] * BUG: Fix some painting artifacts in Editor. * BUG: In Editor, Undo and Redo now should always work correctly when a line is rewritten. * NEW: In Editor, when a line is rewritten, the Change event is always emitted. * NEW: The Editor is cleared now when it prints a CTRL+L character. * NEW: The Editor flashes now when it prints a CTRL+G character. git-svn-id: svn://localhost/gambas/trunk@1576 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-09-22 01:22:07 +02:00
{ \
fprintf(stderr, "%s: **** ALREADY FREED **** %p\n", OBJECT_ref_where, (_object)); \
[WIKI CGI SCRIPT] * NEW: Do not use <pre> markups, they cannot break lines. [DEVELOPMENT ENVIRONMENT] * NEW: Replace anonymous object arrays by template arrays. * NEW: A button that clears the shortcut in the menu editor. * NEW: When evaluating expression in the console, a semi-colon at the end of the expression prevents the end newline to be printed, like in the PRINT instruction. * NEW: CTRL+G in the console makes it flash. * OPT: Remove the CCoolTabs class, that was not used anymore. * NEW: The main selected control is unselectable in the form editor now. * NEW: Selected controls can be resized by pressing CTRL and an arrow key. * NEW: Some form editor shortcuts have been changed to not conflict with the previous feature. * BUG: Fix the horizontal position of the automatic completion. * BUG: Look in project classes before component classes in automatic completion. [INTERPRETER] * BUG: Fix the memory allocation debug routines. * BUG: When instanciating a template array class, search for element class symbol locally first. * BUG: Template arrays now correctly release their elements. * NEW: Update copyright year in gb_common.h header file. [COMPILER] * BUG: Manage .list and .info files incrementally, so that they are up to date even when the project is not fully compiled. * BUG: Float and Single constants are correctly written in the .info file. [GB.QT.EXT] * BUG: Fix some painting artifacts in Editor. * BUG: In Editor, Undo and Redo now should always work correctly when a line is rewritten. * NEW: In Editor, when a line is rewritten, the Change event is always emitted. * NEW: The Editor is cleared now when it prints a CTRL+L character. * NEW: The Editor flashes now when it prints a CTRL+G character. git-svn-id: svn://localhost/gambas/trunk@1576 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-09-22 01:22:07 +02:00
fflush(NULL); \
BREAKPOINT(); \
[WIKI CGI SCRIPT] * NEW: Do not use <pre> markups, they cannot break lines. [DEVELOPMENT ENVIRONMENT] * NEW: Replace anonymous object arrays by template arrays. * NEW: A button that clears the shortcut in the menu editor. * NEW: When evaluating expression in the console, a semi-colon at the end of the expression prevents the end newline to be printed, like in the PRINT instruction. * NEW: CTRL+G in the console makes it flash. * OPT: Remove the CCoolTabs class, that was not used anymore. * NEW: The main selected control is unselectable in the form editor now. * NEW: Selected controls can be resized by pressing CTRL and an arrow key. * NEW: Some form editor shortcuts have been changed to not conflict with the previous feature. * BUG: Fix the horizontal position of the automatic completion. * BUG: Look in project classes before component classes in automatic completion. [INTERPRETER] * BUG: Fix the memory allocation debug routines. * BUG: When instanciating a template array class, search for element class symbol locally first. * BUG: Template arrays now correctly release their elements. * NEW: Update copyright year in gb_common.h header file. [COMPILER] * BUG: Manage .list and .info files incrementally, so that they are up to date even when the project is not fully compiled. * BUG: Float and Single constants are correctly written in the .info file. [GB.QT.EXT] * BUG: Fix some painting artifacts in Editor. * BUG: In Editor, Undo and Redo now should always work correctly when a line is rewritten. * NEW: In Editor, when a line is rewritten, the Change event is always emitted. * NEW: The Editor is cleared now when it prints a CTRL+L character. * NEW: The Editor flashes now when it prints a CTRL+G character. git-svn-id: svn://localhost/gambas/trunk@1576 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-09-22 01:22:07 +02:00
} \
if (CLASS_unref(_object, TRUE)) \
_object = NULL; \
} \
}
#define OBJECT_just_unref(_object) \
{ \
if (OBJECT_class(_object) == FREE_MARK) \
{ \
fprintf(stderr, "%s: **** ALREADY FREED **** %p\n", OBJECT_ref_where, (_object)); \
fflush(NULL); \
BREAKPOINT(); \
} \
CLASS_unref(_object, TRUE); \
}
[WIKI CGI SCRIPT] * NEW: Do not use <pre> markups, they cannot break lines. [DEVELOPMENT ENVIRONMENT] * NEW: Replace anonymous object arrays by template arrays. * NEW: A button that clears the shortcut in the menu editor. * NEW: When evaluating expression in the console, a semi-colon at the end of the expression prevents the end newline to be printed, like in the PRINT instruction. * NEW: CTRL+G in the console makes it flash. * OPT: Remove the CCoolTabs class, that was not used anymore. * NEW: The main selected control is unselectable in the form editor now. * NEW: Selected controls can be resized by pressing CTRL and an arrow key. * NEW: Some form editor shortcuts have been changed to not conflict with the previous feature. * BUG: Fix the horizontal position of the automatic completion. * BUG: Look in project classes before component classes in automatic completion. [INTERPRETER] * BUG: Fix the memory allocation debug routines. * BUG: When instanciating a template array class, search for element class symbol locally first. * BUG: Template arrays now correctly release their elements. * NEW: Update copyright year in gb_common.h header file. [COMPILER] * BUG: Manage .list and .info files incrementally, so that they are up to date even when the project is not fully compiled. * BUG: Float and Single constants are correctly written in the .info file. [GB.QT.EXT] * BUG: Fix some painting artifacts in Editor. * BUG: In Editor, Undo and Redo now should always work correctly when a line is rewritten. * NEW: In Editor, when a line is rewritten, the Change event is always emitted. * NEW: The Editor is cleared now when it prints a CTRL+L character. * NEW: The Editor flashes now when it prints a CTRL+G character. git-svn-id: svn://localhost/gambas/trunk@1576 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-09-22 01:22:07 +02:00
#define OBJECT_unref_keep(_object) \
{ \
[WIKI CGI SCRIPT] * NEW: Do not use <pre> markups, they cannot break lines. [DEVELOPMENT ENVIRONMENT] * NEW: Replace anonymous object arrays by template arrays. * NEW: A button that clears the shortcut in the menu editor. * NEW: When evaluating expression in the console, a semi-colon at the end of the expression prevents the end newline to be printed, like in the PRINT instruction. * NEW: CTRL+G in the console makes it flash. * OPT: Remove the CCoolTabs class, that was not used anymore. * NEW: The main selected control is unselectable in the form editor now. * NEW: Selected controls can be resized by pressing CTRL and an arrow key. * NEW: Some form editor shortcuts have been changed to not conflict with the previous feature. * BUG: Fix the horizontal position of the automatic completion. * BUG: Look in project classes before component classes in automatic completion. [INTERPRETER] * BUG: Fix the memory allocation debug routines. * BUG: When instanciating a template array class, search for element class symbol locally first. * BUG: Template arrays now correctly release their elements. * NEW: Update copyright year in gb_common.h header file. [COMPILER] * BUG: Manage .list and .info files incrementally, so that they are up to date even when the project is not fully compiled. * BUG: Float and Single constants are correctly written in the .info file. [GB.QT.EXT] * BUG: Fix some painting artifacts in Editor. * BUG: In Editor, Undo and Redo now should always work correctly when a line is rewritten. * NEW: In Editor, when a line is rewritten, the Change event is always emitted. * NEW: The Editor is cleared now when it prints a CTRL+L character. * NEW: The Editor flashes now when it prints a CTRL+G character. git-svn-id: svn://localhost/gambas/trunk@1576 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-09-22 01:22:07 +02:00
if (_object) \
{ \
if (OBJECT_class(_object) == FREE_MARK) \
[WIKI CGI SCRIPT] * NEW: Do not use <pre> markups, they cannot break lines. [DEVELOPMENT ENVIRONMENT] * NEW: Replace anonymous object arrays by template arrays. * NEW: A button that clears the shortcut in the menu editor. * NEW: When evaluating expression in the console, a semi-colon at the end of the expression prevents the end newline to be printed, like in the PRINT instruction. * NEW: CTRL+G in the console makes it flash. * OPT: Remove the CCoolTabs class, that was not used anymore. * NEW: The main selected control is unselectable in the form editor now. * NEW: Selected controls can be resized by pressing CTRL and an arrow key. * NEW: Some form editor shortcuts have been changed to not conflict with the previous feature. * BUG: Fix the horizontal position of the automatic completion. * BUG: Look in project classes before component classes in automatic completion. [INTERPRETER] * BUG: Fix the memory allocation debug routines. * BUG: When instanciating a template array class, search for element class symbol locally first. * BUG: Template arrays now correctly release their elements. * NEW: Update copyright year in gb_common.h header file. [COMPILER] * BUG: Manage .list and .info files incrementally, so that they are up to date even when the project is not fully compiled. * BUG: Float and Single constants are correctly written in the .info file. [GB.QT.EXT] * BUG: Fix some painting artifacts in Editor. * BUG: In Editor, Undo and Redo now should always work correctly when a line is rewritten. * NEW: In Editor, when a line is rewritten, the Change event is always emitted. * NEW: The Editor is cleared now when it prints a CTRL+L character. * NEW: The Editor flashes now when it prints a CTRL+G character. git-svn-id: svn://localhost/gambas/trunk@1576 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-09-22 01:22:07 +02:00
{ \
fprintf(stderr, "%s: **** ALREADY FREED **** %p\n", OBJECT_ref_where, (_object)); \
[WIKI CGI SCRIPT] * NEW: Do not use <pre> markups, they cannot break lines. [DEVELOPMENT ENVIRONMENT] * NEW: Replace anonymous object arrays by template arrays. * NEW: A button that clears the shortcut in the menu editor. * NEW: When evaluating expression in the console, a semi-colon at the end of the expression prevents the end newline to be printed, like in the PRINT instruction. * NEW: CTRL+G in the console makes it flash. * OPT: Remove the CCoolTabs class, that was not used anymore. * NEW: The main selected control is unselectable in the form editor now. * NEW: Selected controls can be resized by pressing CTRL and an arrow key. * NEW: Some form editor shortcuts have been changed to not conflict with the previous feature. * BUG: Fix the horizontal position of the automatic completion. * BUG: Look in project classes before component classes in automatic completion. [INTERPRETER] * BUG: Fix the memory allocation debug routines. * BUG: When instanciating a template array class, search for element class symbol locally first. * BUG: Template arrays now correctly release their elements. * NEW: Update copyright year in gb_common.h header file. [COMPILER] * BUG: Manage .list and .info files incrementally, so that they are up to date even when the project is not fully compiled. * BUG: Float and Single constants are correctly written in the .info file. [GB.QT.EXT] * BUG: Fix some painting artifacts in Editor. * BUG: In Editor, Undo and Redo now should always work correctly when a line is rewritten. * NEW: In Editor, when a line is rewritten, the Change event is always emitted. * NEW: The Editor is cleared now when it prints a CTRL+L character. * NEW: The Editor flashes now when it prints a CTRL+G character. git-svn-id: svn://localhost/gambas/trunk@1576 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-09-22 01:22:07 +02:00
fflush(NULL); \
} \
CLASS_unref(_object, FALSE); \
} \
}
#define OBJECT_REF(_ob) { OBJECT_ref_where = OBJECT_where_am_i(__FILE__, __LINE__, __func__); OBJECT_ref(_ob); }
#define OBJECT_UNREF(_ob) { OBJECT_ref_where = OBJECT_where_am_i(__FILE__, __LINE__, __func__); OBJECT_unref(_ob); }
#define OBJECT_UNREF_KEEP(_ob) { OBJECT_ref_where = OBJECT_where_am_i(__FILE__, __LINE__, __func__); OBJECT_unref_keep(_ob); }
#else /* DEBUG_REF */
#define OBJECT_ref(_object) \
{ \
if (_object) \
((OBJECT *)(_object))->ref++; \
}
#define OBJECT_unref(_object) \
{ \
if (_object) \
{ \
if ((--((OBJECT *)(_object))->ref) <= 0) \
{ \
void *temp = (void *)(_object); \
_object = NULL; \
CLASS_free(temp); \
} \
} \
}
#define OBJECT_just_unref(_object) \
{ \
if ((--((OBJECT *)(_object))->ref) == 0) \
{ \
void *temp = (void *)(_object); \
_object = NULL; \
CLASS_free(temp); \
} \
}
#define OBJECT_unref_keep(_object) \
{ \
if (_object) \
--((OBJECT *)(_object))->ref; \
}
#define OBJECT_REF(_ob) OBJECT_ref(_ob)
#define OBJECT_UNREF(_ob) OBJECT_unref(_ob)
#define OBJECT_UNREF_KEEP(_ob) OBJECT_unref_keep(_ob)
#endif /* DEBUG_REF */
#define OBJECT_get_var_addr(_object, _desc) ((void *)((char *)(_object) + (_desc)->variable.offset))
static INLINE void OBJECT_null(VALUE *value, CLASS *class)
{
value->_object.class = class;
value->_object.object = NULL;
}
static INLINE void OBJECT_put(VALUE *value, void *object)
{
value->_object.class = OBJECT_class(object);
value->_object.object = object;
}
#endif