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

356 lines
6.6 KiB
C
Raw Normal View History

/***************************************************************************
gbx_library.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 __GBX_LIBRARY_C
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gb_common.h"
#include "gb_common_buffer.h"
#include "gb_common_case.h"
#include "gb_error.h"
#include "gb_alloc.h"
#include "gb_replace.h"
#include "gb_magic.h"
#include <fcntl.h>
#include <stdlib.h>
#include <stdarg.h>
#include <time.h>
#include <ctype.h>
#include "gb_error.h"
#include "gbx_class.h"
#include "gbx_exec.h"
#include "gbx_event.h"
#include "gbx_stack.h"
#include "gb_file.h"
#include "gbx_archive.h"
#include "gbx_project.h"
#include "gbx_api.h"
#include "gbx_string.h"
#include "gbx_object.h"
#include "gbx_component.h"
#include "gbx_library.h"
//#define DEBUG
//#define DEBUG_PRELOAD
[DEVELOPMENT ENVIRONMENT] * NEW: Some little fixes in the hall of fame animations. * BUG: Fix the layout of the property sheet text edit dialog. * NEW: A new highlighting theme, named 'Quick'. * NEW: The '(Scaled)' virtual property has been renamed as 'Scaled'. * BUG: Fix the "quit" icon in the quit dialog. * BUG: Correctly raise an error when making an executable fails for any reason. * BUG: Extract the property help better. [WIKI CGI SCRIPT] * BUG: Auto link now really makes one identical link between two titles. [INTERPRETER] * OPT: Optimization of additions of small integers. * BUG: INC and DEC now toggle boolean values. * NEW: Use the new '.startup' file to run a project. The old '.project' file can be used for older projects. But its support will be removed in the final version. [COMPILER] * NEW: A '.startup' file is now created at each compilation. It contains an extract of the '.project' file with just what the interpreter needs to run the application. [GB.GTK] * BUG: Void items are correctly handled by ComboBox without crashing now. [GB.EVAL] * BUG: Quoted symbols, i.e. symbols between braces, are now correctly colorized by using the identifier colors. [GB.FORM] * BUG: Removed the useless Tag property from the DatePicker control. * BUG: Fix the height of the DateChooser toolbar. * NEW: Wizard.ShowIndex is a new property that makes the wizard control automatically display the index of the current step. This index takes into account if some steps are disabled. [GB.FORM.DIALOG] * NEW: Dialog.SelectDate() is a new method that allows the user to select a date in a dialog box having a date chooser. [GB.QT] * BUG: You can now resize a non resizable window without having to change its Border property first. [GB.QT.EXT] * BUG: Editor correctly goes to the end of file when pressing CTRL+END. Consequently, SelectAll() works correctly too now. * NEW: Comments just before a procedure are now never folded. git-svn-id: svn://localhost/gambas/trunk@1317 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-04-17 12:18:25 +02:00
// Maximum size of a project or startup file
// This avoids reading too much in the archive file!
#define MAX_SIZE 2048
int _bytes_read = 0;
#if 0
static lt_ptr library_malloc(size_t size)
{
lt_ptr ptr;
ALLOC(&ptr, size, "library_malloc");
printf("library_malloc: %d -> %p\n", size, ptr);
return ptr;
}
static void library_free(lt_ptr ptr)
{
printf("library_free -> %p\n", ptr);
FREE(&ptr, "library_free");
}
#endif
static void *get_symbol(LIBRARY *lib, const char *symbol, bool err)
{
void *sym;
sym = lt_dlsym(lib->handle, symbol);
if (sym == NULL && err)
{
******** 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
strcpy(COMMON_buffer, lt_dlerror());
lt_dlclose(lib->handle);
lib->handle = NULL;
THROW(E_LIBRARY, lib->name, COMMON_buffer);
}
return sym;
}
static void copy_interface(void **src, void **dst)
{
for(;;)
{
if (!*src)
return;
*dst++ = *src++;
}
}
******** 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 LIBRARY_init(void)
{
/*if (putenv("LD_BIND_NOW=true"))
ERROR_panic("Cannot set LD_BIND_NOW: &1", strerror(errno));
if (putenv("KDE_MALLOC=0"))
ERROR_panic("Cannot set KDE_MALLOC: &1", strerror(errno));*/
/*lt_dlmalloc = library_malloc;
lt_dlfree = library_free;*/
#ifndef DONT_USE_LTDL
if (lt_dlinit())
ERROR_panic("Cannot initialize plug-in management: %s", lt_dlerror());
#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 LIBRARY_exit(void)
{
#ifndef DONT_USE_LTDL
lt_dlexit();
#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 LIBRARY_get_interface(LIBRARY *lib, int version, void *iface)
{
char symbol[32];
int i, len;
char c;
len = strlen(lib->name);
for (i = 0; i < len; i++)
{
c = toupper(lib->name[i]);
if (!isalnum((unsigned char)c))
c = '_';
symbol[i] = c;
}
******** 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
sprintf(&symbol[len], "_%d", version);
copy_interface((void **)get_symbol(lib, symbol, TRUE), iface);
}
bool LIBRARY_get_interface_by_name(const char *name, int version, void *iface)
{
COMPONENT *comp;
comp = COMPONENT_find(name);
if (!comp || !comp->library)
return TRUE;
LIBRARY_get_interface(comp->library, version, iface);
return FALSE;
}
******** 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
LIBRARY *LIBRARY_create(const char *name)
{
LIBRARY *lib;
ALLOC_ZERO(&lib, sizeof(LIBRARY));
lib->handle = NULL;
lib->name = name;
/*if (name)
{
lib->persistent = FALSE;
lib->preload = FALSE;
}
else
{
lib->persistent = TRUE;
lib->preload = TRUE;
}*/
return lib;
}
******** 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 LIBRARY_delete(LIBRARY *lib)
{
LIBRARY_unload(lib);
FREE(&lib);
}
int LIBRARY_load(LIBRARY *lib)
{
int (*func)();
void **iface;
GB_DESC **desc;
char *path;
int order = 0;
if (lib->handle)
return 0;
#ifdef DEBUG
clock_t t = clock();
fprintf(stderr, "Loading library %s\n", lib->name);
#endif
path = FILE_buffer();
******** 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
sprintf(path, LIB_PATTERN, COMPONENT_path, lib->name);
//if (!FILE_exist(path))
// sprintf(path, LIB_PATTERN, COMPONENT_user_path, lib->name);
#ifndef DONT_USE_LTDL
/* no more available in libltld ?
lt_dlopen_flag = RTLD_LAZY;
*/
lib->handle = lt_dlopenext(path);
#else
lib->handle = dlopen(path, RTLD_LAZY);
#endif
if (lib->handle == NULL)
THROW(E_LIBRARY, lib->name, lt_dlerror());
func = get_symbol(lib, LIB_INIT, TRUE);
/* Interface de Gambas */
iface = get_symbol(lib, LIB_GAMBAS_PTR, FALSE);
if (iface)
*((void **)iface) = &GAMBAS_Api;
else
{
iface = get_symbol(lib, LIB_GAMBAS, TRUE);
copy_interface(GAMBAS_Api, iface);
}
/* Signal function */
lib->signal = (void(*)())get_symbol(lib, LIB_SIGNAL, FALSE);
lib->info = (int(*)())get_symbol(lib, LIB_INFO, FALSE);
/* Initialisation */
order = (*func)();
/* Déclaration des classes */
desc = get_symbol(lib, LIB_CLASS, FALSE);
if (desc)
LIBRARY_declare(desc);
#ifdef DEBUG
fprintf(stderr, "Library %s loaded ", lib->name);
fprintf(stderr, "in %g s\n", ((double)(clock() - t) / CLOCKS_PER_SEC));
#endif
return order;
}
[INTERPRETER] * NEW: GB.GetReturnValue() is a new interpreter API that returns a pointer to the internal GB_VALUE slot where GB.ReturnXXX() functions store the return value. * NEW: Allow a component to declare a GB_AFTER_INIT() exported method that is called just after all the components declared in the project are completely loaded. [GB.DBUS] * NEW: DBus._HasSystemTray() is a new method that returns if the DBus system tray is present. That method is used by the 'gb.gui.trayicon' component to know if 'gb.dbus.trayicon' must be loaded. * BUG: Fix xml introspection analysis. [GB.DBUS.TRAYICON] * BUG: Remove debugging messages. * BUG: TrayIcon icon data is sent correctly now. [GB.GUI.TRAYICON] * NEW: New component that you must check if you want to have system tray icons. It loads 'gb.dbus', use DBus._HasSystemTray() to know if it can load 'gb.dbus.trayicon'. Otherwise it tells the current GUI component to declare the old system tray implementation classes. [GB.GTK] * NEW: Let the new 'gb.gui.trayicon' deals with the dbus stuff, but keep the old system tray icon and use them on demand. [GB.GTK3] * NEW: Let the new 'gb.gui.trayicon' deals with the dbus stuff, but keep the old system tray icon and use them on demand. [GB.QT4] * NEW: Let the new 'gb.gui.trayicon' deals with the dbus stuff, but keep the old system tray icon and use them on demand. [GB.QT5] * NEW: Let the new 'gb.gui.trayicon' deals with the dbus stuff, but keep the old system tray icon and use them on demand. git-svn-id: svn://localhost/gambas/trunk@7170 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2015-07-04 00:18:58 +02:00
void LIBRARY_after_init(LIBRARY *lib)
{
void (*func)();
func = get_symbol(lib, LIB_AFTER_INIT, FALSE);
if (func) (*func)();
}
void LIBRARY_exec(LIBRARY *lib, int argc, char **argv)
{
void (*func)();
func = get_symbol(lib, LIB_MAIN, FALSE);
if (func)
(*func)(argc, argv);
}
[INTERPRETER] * NEW: Add a new GB.Component.Declare() API, that allows a component to dynamically register a class description. [INFORMER] * NEW: A component now can declare classes through a GB_OPTIONAL_CLASSES public symbol. Theses classes are included into the information file, but are not automatically loaded as the ones defined through the GB_CLASSES symbol. [GB.FORM.STATUSICON] * NEW: This component has been removed and replaced by gb.dbus.trayicon. * NEW: This component now provide TrayIcon and TrayIcons classes that have exactly the same interface as the old ones. [GB.DBUS] * NEW: Remove the now useless DBusConnection.Raise(). The DBusConnection Register() and Unregister() are kept for backward-compatibility reason. * NEW: Add DBus.Raise() and DBus[].Raise() to raise signals. At the moment, there is no difference between the two methods, as there no mean to indicate the sender raising a signal. I don't know yet how DBus decides which service sends a signal! [GB.DBUS.TRAYICON] * NEW: This component implements the tray icon DBus protocol. It is automatically loaded by the GUI components. [GB.GTK] * NEW: Load the 'gb.dbus' and 'gb.dbus.trayicon' components if the current desktop is KDE >= 4. Otherwise, use the old TrayIcon implementation. * BUG: Fix the old TrayIcon implementation, so that it matches the QT one. [GB.GTK3] * NEW: Load the 'gb.dbus' and 'gb.dbus.trayicon' components if the current desktop is KDE >= 4. Otherwise, use the old TrayIcon implementation. * BUG: Fix the component name in deprecation warning messages. * BUG: Fix the old TrayIcon implementation, so that it matches the QT one. [GB.QT4] * NEW: Load the 'gb.dbus' and 'gb.dbus.trayicon' components if the current desktop is KDE >= 4. Otherwise, use the old TrayIcon implementation. [GB.QT5] * NEW: Load the 'gb.dbus' and 'gb.dbus.trayicon' components if the current desktop is KDE >= 4. Otherwise, use the old TrayIcon implementation. git-svn-id: svn://localhost/gambas/trunk@7154 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2015-06-29 03:46:51 +02:00
void LIBRARY_declare_one(GB_DESC *desc)
{
CLASS_find_global(desc->name);
if (CLASS_register(desc) == NULL)
THROW(E_REGISTER, desc->name);
}
******** 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 LIBRARY_declare(GB_DESC **desc)
{
GB_DESC **p;
p = desc;
while (*p != NULL)
{
CLASS_find_global((*p)->name);
p++;
}
p = desc;
while (*p != NULL)
{
if (CLASS_register(*p) == NULL)
THROW(E_REGISTER, (*p)->name);
p++;
}
}
******** 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 LIBRARY_unload(LIBRARY *lib)
{
void (*gambas_exit)();
if (lib->handle == NULL)
return;
/* Pas de lib<69>ation des classes pr<70>harg<72> ! */
/* V<>ification qu'aucune classe de la librairie n'est instanci<63> ! */
gambas_exit = lt_dlsym(lib->handle, LIB_EXIT);
if (gambas_exit != NULL)
(*gambas_exit)();
if (lib->persistent)
{
gambas_exit = lt_dlsym(lib->handle, "_fini");
if (gambas_exit != NULL)
(*gambas_exit)();
}
else
{
lt_dlclose(lib->handle);
}
lib->handle = NULL;
#ifdef DEBUG
printf("Unloading library %s\n", lib->name);
#endif
}