2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
gbx_c_class.c
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2017-01-13 04:29:42 +01:00
|
|
|
(c) 2000-2017 Benoît Minisini <gambas@users.sourceforge.net>
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
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.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
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.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
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.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#define __GBX_C_CLASS_C
|
|
|
|
|
|
|
|
#include "gbx_info.h"
|
|
|
|
|
|
|
|
#ifndef GBX_INFO
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#include "gb_common.h"
|
|
|
|
#include "gbx_api.h"
|
|
|
|
#include "gbx_component.h"
|
|
|
|
#include "gbx_project.h"
|
|
|
|
#include "gbx_class.h"
|
|
|
|
#include "gbx_class_desc.h"
|
|
|
|
#include "gbx_exec.h"
|
2008-02-21 14:14:16 +01:00
|
|
|
#include "gbx_event.h"
|
2007-12-30 17:41:49 +01:00
|
|
|
#include "gbx_object.h"
|
|
|
|
#include "gbx_c_array.h"
|
2010-12-21 15:05:42 +01:00
|
|
|
#include "gbx_c_observer.h"
|
2007-12-30 17:41:49 +01:00
|
|
|
#include "gbx_c_class.h"
|
|
|
|
|
|
|
|
static CLASS_DESC_SYMBOL *_current_symbol = NULL;
|
|
|
|
|
2012-10-19 23:00:35 +02:00
|
|
|
static void error(int code, CLASS *class, const char *name)
|
|
|
|
{
|
|
|
|
GB_Error((char *)(intptr_t)code, CLASS_get_name(class), name);
|
|
|
|
}
|
|
|
|
|
2016-07-18 05:01:59 +02:00
|
|
|
static bool check_null(void *object)
|
|
|
|
{
|
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_NULL);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
//---- Components ---------------------------------------------------------
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Components_get, GB_STRING name)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
const char *name = GB_ToZeroString(ARG(name));
|
|
|
|
COMPONENT *comp;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
comp = COMPONENT_find(name);
|
|
|
|
GB_ReturnObject(comp);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Components_Count)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnInt(COMPONENT_count);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD_VOID(Components_next)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
COMPONENT **plib = (COMPONENT **)GB_GetEnum();
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
*plib = COMPONENT_next(*plib);
|
|
|
|
if (*plib == NULL)
|
|
|
|
GB_StopEnum();
|
|
|
|
else
|
|
|
|
GB_ReturnObject(*plib);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Component_Name)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnConstZeroString(OBJECT(COMPONENT)->name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Component_Path)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnString(COMPONENT_path);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Component_Load, GB_STRING name)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
const char *name = GB_ToZeroString(ARG(name));
|
|
|
|
COMPONENT *comp;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
comp = COMPONENT_find(name);
|
|
|
|
if (!comp)
|
|
|
|
comp = COMPONENT_create(name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
COMPONENT_load(comp);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnObject(comp);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Component_IsLoaded, GB_STRING name)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2015-05-27 03:00:39 +02:00
|
|
|
GB_ReturnBoolean(COMPONENT_is_loaded(GB_ToZeroString(ARG(name))));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2015-09-14 12:53:02 +02:00
|
|
|
BEGIN_METHOD(Component_FindFromPath, GB_STRING path)
|
|
|
|
|
|
|
|
ARCHIVE *arch = NULL;
|
|
|
|
const char *path = GB_ToZeroString(ARG(path));
|
|
|
|
ARCHIVE_find_from_path(&arch, &path);
|
|
|
|
if (arch)
|
|
|
|
GB_ReturnNewZeroString(arch->name);
|
|
|
|
else
|
|
|
|
GB_ReturnVoidString();
|
|
|
|
|
|
|
|
END_METHOD
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
//---- Classes ------------------------------------------------------------
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Classes_get, GB_STRING name)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
const char *name = GB_ToZeroString(ARG(name));
|
|
|
|
CLASS *class = NULL;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (name != NULL)
|
|
|
|
class = CLASS_look(name, LENGTH(name));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (class == NULL)
|
|
|
|
{
|
|
|
|
GB_Error("Unknown class '&1'", name);
|
|
|
|
return;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2014-07-28 07:35:58 +02:00
|
|
|
if (!CLASS_is_loaded(class))
|
2010-01-11 00:00:31 +01:00
|
|
|
{
|
|
|
|
GB_Error("Class is not loaded");
|
|
|
|
return;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnObject(class);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Class_Load, GB_STRING name)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
CLASS *class;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
class = CLASS_get(GB_ToZeroString(ARG(name)));
|
|
|
|
GB_ReturnObject(class);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-09-17 13:13:32 +02:00
|
|
|
|
|
|
|
BEGIN_METHOD_VOID(Classes_next)
|
|
|
|
|
|
|
|
CLASS **pcurrent = (CLASS **)GB_GetEnum();
|
|
|
|
CLASS *class;
|
|
|
|
|
|
|
|
class = *pcurrent;
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2012-09-17 13:13:32 +02:00
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
if (!class)
|
|
|
|
class = CLASS_get_list();
|
|
|
|
else
|
|
|
|
class = class->next;
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2012-09-17 13:13:32 +02:00
|
|
|
if (!class)
|
|
|
|
{
|
|
|
|
GB_StopEnum();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-07-28 07:35:58 +02:00
|
|
|
if (CLASS_is_loaded(class))
|
2012-09-17 13:13:32 +02:00
|
|
|
{
|
|
|
|
GB_ReturnObject(class);
|
|
|
|
break;
|
|
|
|
}
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2012-09-17 13:13:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
*pcurrent = class;
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2012-09-17 13:13:32 +02:00
|
|
|
END_METHOD
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Classes_count)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnInt(CLASS_count());
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
|
|
|
//---- Class --------------------------------------------------------------
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(Class_Name)
|
|
|
|
|
|
|
|
GB_ReturnConstZeroString(OBJECT(CLASS)->name);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Class_Count)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnInt(OBJECT(CLASS)->count);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Class_Hidden)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-19 23:00:35 +02:00
|
|
|
GB_ReturnBoolean(*(CLASS_get_name(OBJECT(CLASS))) == '.');
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Class_Native)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnBoolean(CLASS_is_native(OBJECT(CLASS)));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Class_Component)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnObject(OBJECT(CLASS)->component);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Class_Parent)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnObject(OBJECT(CLASS)->parent);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Class_Symbols)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
CLASS *class = OBJECT(CLASS);
|
|
|
|
GB_ARRAY array;
|
|
|
|
CLASS_DESC_SYMBOL *cds;
|
|
|
|
int index = 0;
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ArrayNew(&array, T_STRING, 0);
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
for(;;)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2010-01-11 00:00:31 +01:00
|
|
|
cds = CLASS_get_next_sorted_symbol(class, &index);
|
|
|
|
if (!cds)
|
|
|
|
break;
|
2010-06-05 01:48:53 +02:00
|
|
|
*((char **)GB_ArrayAdd(array)) = STRING_new(cds->name, cds->len);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnObject(array);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Class_get, GB_STRING name)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
CLASS *class = OBJECT(CLASS);
|
|
|
|
CLASS_DESC_SYMBOL *cd = NULL;
|
|
|
|
const char *name = GB_ToZeroString(ARG(name));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (name != NULL)
|
|
|
|
cd = CLASS_get_symbol(class, name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (cd == NULL)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_Error("Unknown symbol '&1'", name);
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
_current_symbol = cd;
|
|
|
|
GB_ReturnObject(class);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2012-10-27 20:59:14 +02:00
|
|
|
BEGIN_METHOD(Class_Exist, GB_STRING name)
|
|
|
|
|
|
|
|
CLASS *class = OBJECT(CLASS);
|
|
|
|
const char *name = GB_ToZeroString(ARG(name));
|
|
|
|
|
|
|
|
GB_ReturnBoolean(name != NULL && CLASS_get_symbol(class, name) != NULL);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Class_Instance)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnObject(OBJECT(CLASS)->instance);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-03-25 12:16:33 +01:00
|
|
|
BEGIN_METHOD_VOID(Class_AutoCreate)
|
|
|
|
|
|
|
|
CLASS *class = OBJECT(CLASS);
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2010-03-25 12:16:33 +01:00
|
|
|
if (!class->auto_create)
|
|
|
|
GB_ReturnNull();
|
|
|
|
else
|
|
|
|
GB_ReturnObject(CLASS_auto_create(class, 0));
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2011-04-28 00:06:38 +02:00
|
|
|
BEGIN_METHOD(Class_New, GB_OBJECT params)
|
|
|
|
|
|
|
|
CLASS *class = OBJECT(CLASS);
|
|
|
|
GB_ARRAY params = VARGOPT(params, NULL);
|
|
|
|
int i, np = 0;
|
|
|
|
void *object;
|
|
|
|
|
|
|
|
if (params)
|
|
|
|
np = GB_ArrayCount(params);
|
|
|
|
|
|
|
|
if (np)
|
|
|
|
{
|
|
|
|
STACK_check(np);
|
|
|
|
|
|
|
|
for (i = 0; i < np; i++)
|
|
|
|
{
|
|
|
|
CARRAY_get_value(params, i, SP);
|
|
|
|
PUSH();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
object = EXEC_create_object(class, np, NULL);
|
2013-03-30 14:51:10 +01:00
|
|
|
OBJECT_UNREF_KEEP(object);
|
2011-04-28 00:06:38 +02:00
|
|
|
GB_ReturnObject(object);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
//---- Symbol -------------------------------------------------------------
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Symbol_Name)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnConstString(_current_symbol->name, _current_symbol->len);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Symbol_Kind)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
CLASS_DESC_SYMBOL *cds = _current_symbol;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
switch(CLASS_DESC_get_type(cds->desc))
|
|
|
|
{
|
|
|
|
case CD_VARIABLE:
|
|
|
|
case CD_STATIC_VARIABLE:
|
|
|
|
GB_ReturnInt(1);
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
case CD_PROPERTY:
|
|
|
|
case CD_PROPERTY_READ:
|
|
|
|
case CD_STATIC_PROPERTY:
|
|
|
|
case CD_STATIC_PROPERTY_READ:
|
|
|
|
GB_ReturnInt(2);
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
case CD_METHOD:
|
|
|
|
case CD_STATIC_METHOD:
|
|
|
|
GB_ReturnInt(3);
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
case CD_EVENT:
|
|
|
|
GB_ReturnInt(4);
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
case CD_CONSTANT:
|
|
|
|
GB_ReturnInt(5);
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
default:
|
|
|
|
GB_ReturnInt(0);
|
|
|
|
return;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Symbol_Static)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
CLASS_DESC_SYMBOL *cds = _current_symbol;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnBoolean(index(CD_STATIC_LIST, CLASS_DESC_get_type(cds->desc)) != NULL);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Symbol_Hidden)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
CLASS_DESC_SYMBOL *cds = _current_symbol;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnBoolean(*cds->name == '_');
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Symbol_ReadOnly)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
CLASS_DESC_SYMBOL *cds = _current_symbol;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
switch (CLASS_DESC_get_type(cds->desc))
|
|
|
|
{
|
|
|
|
case CD_PROPERTY:
|
|
|
|
case CD_STATIC_PROPERTY:
|
|
|
|
GB_ReturnBoolean(FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
GB_ReturnBoolean(TRUE);
|
|
|
|
break;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Symbol_Type)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
CLASS_DESC_SYMBOL *cds = _current_symbol;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnConstZeroString(TYPE_to_string(cds->desc->property.type)); /* Valable pour tout symbole */
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Symbol_Signature)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
CLASS_DESC_SYMBOL *cds = _current_symbol;
|
2010-07-19 14:33:57 +02:00
|
|
|
char *sign = CLASS_DESC_get_signature(cds->desc);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-07-19 14:33:57 +02:00
|
|
|
if (sign)
|
2013-01-12 23:44:52 +01:00
|
|
|
{
|
|
|
|
STRING_free_later(sign);
|
2010-07-19 14:33:57 +02:00
|
|
|
GB_ReturnString(sign);
|
2013-01-12 23:44:52 +01:00
|
|
|
}
|
2010-07-19 14:33:57 +02:00
|
|
|
else
|
2011-10-24 21:33:41 +02:00
|
|
|
GB_ReturnVoidString();
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Symbol_Value)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
CLASS_DESC *desc = _current_symbol->desc;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (CLASS_DESC_get_type(desc) != CD_CONSTANT)
|
|
|
|
{
|
2011-11-14 02:06:51 +01:00
|
|
|
GB_ReturnVariant(NULL);
|
2010-01-11 00:00:31 +01:00
|
|
|
return;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (desc->constant.type == T_STRING)
|
|
|
|
GB_ReturnConstZeroString(desc->constant.value._string);
|
|
|
|
else
|
|
|
|
GB_ReturnPtr(desc->constant.type, (void *)&desc->constant.value);
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2011-11-14 02:06:51 +01:00
|
|
|
GB_ReturnConvVariant();
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
//---- Object -------------------------------------------------------------
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Object_GetProperty, GB_OBJECT object; GB_STRING property)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
const char *name;
|
|
|
|
void *object = VARG(object);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (GB_CheckObject(object))
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
name = GB_ToZeroString(ARG(property));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-12-05 04:36:44 +01:00
|
|
|
GB_GetProperty(object, name);
|
2011-11-14 02:06:51 +01:00
|
|
|
GB_ReturnConvVariant();
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Object_SetProperty, GB_OBJECT object; GB_STRING property; GB_VARIANT value)
|
|
|
|
|
|
|
|
const char *name;
|
|
|
|
void *object = VARG(object);
|
|
|
|
|
|
|
|
if (GB_CheckObject(object))
|
|
|
|
return;
|
|
|
|
|
|
|
|
name = GB_ToZeroString(ARG(property));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2014-04-05 02:28:41 +02:00
|
|
|
GB_SetProperty(object, name, (GB_VALUE *)ARG(value));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Object_Attach, GB_OBJECT object; GB_OBJECT parent; GB_STRING name)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
void *object = VARG(object);
|
|
|
|
void *parent = VARG(parent);
|
2009-07-12 23:49:13 +02:00
|
|
|
char *name = GB_ToZeroString(ARG(name));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (GB_CheckObject(object))
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-07-12 23:49:13 +02:00
|
|
|
if (!parent || !name || !*name)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
|
|
|
OBJECT_detach(object);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (GB_CheckObject(parent))
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
OBJECT_attach(object, parent, name);
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2010-05-27 00:01:28 +02:00
|
|
|
/*if (OBJECT_is(object, CLASS_Observer))
|
|
|
|
COBSERVER_attach((COBSERVER *)object, parent, GB_ToZeroString(ARG(name)));*/
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Object_Detach, GB_OBJECT object)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
void *object = VARG(object);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (GB_CheckObject(object))
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2008-02-14 12:59:36 +01:00
|
|
|
if (OBJECT_is(object, CLASS_Observer))
|
|
|
|
COBSERVER_detach((COBSERVER *)object);
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
OBJECT_detach(object);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Object_Parent, GB_OBJECT object)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
void *object = VARG(object);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (GB_CheckObject(object))
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnObject(OBJECT_parent(object));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Object_Class, GB_OBJECT object)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
void *object = VARG(object);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2016-07-18 05:01:59 +02:00
|
|
|
if (check_null(object))
|
2010-01-11 00:00:31 +01:00
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnObject(OBJECT_class(object));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Object_Type, GB_OBJECT object)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
void *object = VARG(object);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2016-07-18 05:01:59 +02:00
|
|
|
if (check_null(object))
|
2010-01-11 00:00:31 +01:00
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnConstZeroString(OBJECT_class(object)->name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Object_Is, GB_OBJECT object; GB_STRING class)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
void *object = VARG(object);
|
|
|
|
CLASS *class = CLASS_look(STRING(class), LENGTH(class));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2016-07-18 05:01:59 +02:00
|
|
|
if (check_null(object))
|
2010-01-11 00:00:31 +01:00
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
if (!class)
|
|
|
|
{
|
|
|
|
GB_ReturnBoolean(FALSE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnBoolean(OBJECT_class(object) == class || CLASS_inherits(OBJECT_class(object), class));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Object_Call, GB_OBJECT object; GB_STRING method; GB_OBJECT params)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
int i;
|
|
|
|
int np = 0;
|
|
|
|
char *name = GB_ToZeroString(ARG(method));
|
|
|
|
void *object = VARG(object);
|
|
|
|
GB_FUNCTION func;
|
|
|
|
GB_ARRAY params = VARGOPT(params, NULL);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (GB_CheckObject(object))
|
|
|
|
return;
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (GB_GetFunction(&func, object, name, NULL, NULL))
|
|
|
|
{
|
2012-10-19 23:00:35 +02:00
|
|
|
error(E_NSYMBOL, OBJECT_class(object), name);
|
2010-01-11 00:00:31 +01:00
|
|
|
return;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
if (params)
|
|
|
|
np = GB_ArrayCount(params);
|
|
|
|
|
|
|
|
if (np)
|
|
|
|
{
|
2010-01-11 00:00:31 +01:00
|
|
|
STACK_check(np);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
for (i = 0; i < np; i++)
|
|
|
|
{
|
|
|
|
CARRAY_get_value(params, i, SP);
|
|
|
|
PUSH();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_Call(&func, np, FALSE);
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2012-02-11 20:12:32 +01:00
|
|
|
if (TEMP.type != T_VOID)
|
|
|
|
GB_ReturnConvVariant();
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2015-07-01 14:26:23 +02:00
|
|
|
BEGIN_METHOD(Object_Raise, GB_OBJECT object; GB_STRING event; GB_OBJECT params)
|
|
|
|
|
|
|
|
CLASS *class;
|
|
|
|
CLASS_DESC *desc;
|
|
|
|
int index;
|
|
|
|
int i, np;
|
|
|
|
void *object = VARG(object);
|
|
|
|
GB_ARRAY params = VARGOPT(params, NULL);
|
2015-07-02 16:26:10 +02:00
|
|
|
int len = LENGTH(event);
|
|
|
|
char event[len + 2];
|
2015-07-01 14:26:23 +02:00
|
|
|
|
|
|
|
if (GB_CheckObject(object))
|
|
|
|
return;
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2015-07-01 14:26:23 +02:00
|
|
|
class = OBJECT_class(object);
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2015-07-02 16:26:10 +02:00
|
|
|
event[0] = ':';
|
|
|
|
memcpy(&event[1], STRING(event), len);
|
|
|
|
event[len + 1] = 0;
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2015-07-02 16:26:10 +02:00
|
|
|
index = CLASS_find_symbol(class, event);
|
2015-07-01 14:26:23 +02:00
|
|
|
if (index == NO_SYMBOL)
|
|
|
|
goto __UNKNOWN_EVENT;
|
|
|
|
|
|
|
|
desc = class->table[index].desc;
|
|
|
|
if (CLASS_DESC_get_type(desc) != CD_EVENT)
|
|
|
|
goto __UNKNOWN_EVENT;
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2015-07-01 14:26:23 +02:00
|
|
|
if (params)
|
|
|
|
np = GB_ArrayCount(params);
|
|
|
|
else
|
|
|
|
np = 0;
|
|
|
|
|
|
|
|
if (np)
|
|
|
|
{
|
|
|
|
STACK_check(np);
|
|
|
|
|
|
|
|
for (i = 0; i < np; i++)
|
|
|
|
{
|
|
|
|
CARRAY_get_value(params, i, SP);
|
|
|
|
PUSH();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-21 06:00:27 +01:00
|
|
|
GB_ReturnBoolean(GB_Raise(object, desc->event.index, -np));
|
2015-07-02 16:26:10 +02:00
|
|
|
return;
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2015-07-01 14:26:23 +02:00
|
|
|
__UNKNOWN_EVENT:
|
|
|
|
|
|
|
|
GB_Error("Unknown event");
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2015-07-01 14:26:23 +02:00
|
|
|
END_METHOD
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Object_IsValid, GB_OBJECT object)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnBoolean(OBJECT_is_valid(VARG(object)));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Object_Lock, GB_OBJECT object)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
void *object = VARG(object);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (GB_CheckObject(object))
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
OBJECT_lock(object, TRUE);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Object_Unlock, GB_OBJECT object)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
void *object = VARG(object);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (GB_CheckObject(object))
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
OBJECT_lock(object, FALSE);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Object_IsLocked, GB_OBJECT object)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
void *object = VARG(object);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (GB_CheckObject(object))
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnBoolean(OBJECT_is_locked(object));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Object_Count, GB_OBJECT object)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
void *object = VARG(object);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (GB_CheckObject(object))
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
// We substract one because the object is referenced on the stack
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnInteger(OBJECT_count(object) - 1);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-08-31 14:02:08 +02:00
|
|
|
BEGIN_METHOD(Object_SizeOf, GB_OBJECT object)
|
|
|
|
|
|
|
|
void *object = VARG(object);
|
|
|
|
|
2016-07-18 05:01:59 +02:00
|
|
|
if (check_null(object))
|
2010-08-31 14:02:08 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
GB_ReturnInteger(CLASS_sizeof(OBJECT_class(object)));
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD(Object_New, GB_STRING class; GB_OBJECT params)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
CLASS *class = CLASS_find(GB_ToZeroString(ARG(class)));
|
|
|
|
GB_ARRAY params = VARGOPT(params, NULL);
|
|
|
|
int i, np = 0;
|
|
|
|
void *object;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (!class)
|
|
|
|
{
|
|
|
|
GB_Error("Unknown class");
|
|
|
|
return;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
if (params)
|
|
|
|
np = GB_ArrayCount(params);
|
|
|
|
|
|
|
|
if (np)
|
|
|
|
{
|
2010-01-11 00:00:31 +01:00
|
|
|
STACK_check(np);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
for (i = 0; i < np; i++)
|
|
|
|
{
|
|
|
|
CARRAY_get_value(params, i, SP);
|
|
|
|
PUSH();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
object = EXEC_create_object(class, np, NULL);
|
2013-03-30 14:51:10 +01:00
|
|
|
OBJECT_UNREF_KEEP(object);
|
2007-12-30 17:41:49 +01:00
|
|
|
GB_ReturnObject(object);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
|
2010-11-22 11:10:56 +01:00
|
|
|
BEGIN_PROPERTY(Object_Address)
|
|
|
|
|
|
|
|
GB_ReturnPointer(VPROP(GB_OBJECT));
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-08-20 20:05:25 +02:00
|
|
|
|
|
|
|
BEGIN_METHOD(Object_CanRaise, GB_OBJECT object; GB_STRING name)
|
|
|
|
|
|
|
|
void *object = VARG(object);
|
|
|
|
CLASS *class;
|
|
|
|
char *name;
|
|
|
|
int index;
|
|
|
|
|
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
class = OBJECT_class(object);
|
|
|
|
name = GB_ToZeroString(ARG(name));
|
|
|
|
index = GB_GetEvent(class, name);
|
2012-10-22 16:09:05 +02:00
|
|
|
//fprintf(stderr, "Object.CanRaise: %s %d\n", name, index);
|
2012-08-20 20:05:25 +02:00
|
|
|
if (index < 0)
|
|
|
|
GB_ReturnBoolean(FALSE);
|
|
|
|
else
|
|
|
|
GB_ReturnBoolean(GB_CanRaise(object, index));
|
2015-11-08 04:11:47 +01:00
|
|
|
|
2012-08-20 20:05:25 +02:00
|
|
|
END_METHOD
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2012-07-14 04:49:57 +02:00
|
|
|
//-------------------------------------------------------------------------
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_DESC NATIVE_Symbol[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2014-09-07 23:21:14 +02:00
|
|
|
GB_DECLARE_VIRTUAL(".Symbol"),
|
2010-01-11 00:00:31 +01:00
|
|
|
|
|
|
|
GB_PROPERTY_READ("Name", "s", Symbol_Name),
|
|
|
|
GB_PROPERTY_READ("Kind", "i", Symbol_Kind),
|
|
|
|
GB_PROPERTY_READ("Type", "s", Symbol_Type),
|
|
|
|
GB_PROPERTY_READ("ReadOnly", "b", Symbol_ReadOnly),
|
|
|
|
GB_PROPERTY_READ("Hidden", "b", Symbol_Hidden),
|
|
|
|
GB_PROPERTY_READ("Signature", "s", Symbol_Signature),
|
|
|
|
GB_PROPERTY_READ("Static", "b", Symbol_Static),
|
|
|
|
GB_PROPERTY_READ("Value", "v", Symbol_Value),
|
|
|
|
|
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_Components[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2014-09-07 23:21:14 +02:00
|
|
|
GB_DECLARE_STATIC("Components"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_STATIC_METHOD("_next", "Component", Components_next, NULL),
|
|
|
|
GB_STATIC_METHOD("_get", "Component", Components_get, "(Name)s"),
|
|
|
|
GB_STATIC_PROPERTY_READ("Count", "i", Components_Count),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_Component[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2014-09-07 23:21:14 +02:00
|
|
|
GB_DECLARE("Component", sizeof(COMPONENT)),
|
|
|
|
GB_NOT_CREATABLE(),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
//GB_STATIC_METHOD("_get", "Component", library_get, "(Name)s"),
|
|
|
|
GB_STATIC_METHOD("Load", "Component", Component_Load, "(Name)s"),
|
|
|
|
GB_STATIC_METHOD("IsLoaded", "b", Component_IsLoaded, "(Name)s"),
|
2015-09-25 20:35:44 +02:00
|
|
|
GB_STATIC_METHOD("FindFromPath", "s", Component_FindFromPath, "(Path)s"),
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_STATIC_PROPERTY_READ("Path", "s", Component_Path),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_PROPERTY_READ("Name", "s", Component_Name),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_Classes[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2014-09-07 23:21:14 +02:00
|
|
|
GB_DECLARE_STATIC("Classes"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_STATIC_METHOD("_next", "Class", Classes_next, NULL),
|
|
|
|
GB_STATIC_METHOD("_get", "Class", Classes_get, "(Name)s"),
|
|
|
|
GB_STATIC_PROPERTY_READ("Count", "i", Classes_count),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_Class[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2014-09-06 18:53:40 +02:00
|
|
|
GB_DECLARE("Class", sizeof(CLASS)),
|
|
|
|
GB_NOT_CREATABLE(),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_STATIC_METHOD("Load", "Class", Class_Load, "(Name)s"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-10-27 20:59:14 +02:00
|
|
|
GB_METHOD("_get", ".Symbol", Class_get, "(Symbol)s"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_PROPERTY_READ("Name", "s", Class_Name),
|
|
|
|
GB_PROPERTY_READ("Hidden", "b", Class_Hidden),
|
|
|
|
GB_PROPERTY_READ("Native", "b", Class_Native),
|
|
|
|
GB_PROPERTY_READ("Parent", "Class", Class_Parent),
|
|
|
|
GB_PROPERTY_READ("Component", "Component", Class_Component),
|
|
|
|
GB_PROPERTY_READ("Count", "i", Class_Count),
|
|
|
|
GB_PROPERTY_READ("Instance", "o", Class_Instance),
|
|
|
|
GB_PROPERTY_READ("Symbols", "String[]", Class_Symbols),
|
2010-03-25 12:16:33 +01:00
|
|
|
GB_METHOD("AutoCreate", "o", Class_AutoCreate, NULL),
|
2011-04-28 00:06:38 +02:00
|
|
|
GB_METHOD("New", "o", Class_New, "[(Arguments)Array;]"),
|
2012-10-27 20:59:14 +02:00
|
|
|
GB_METHOD("Exist", "b", Class_Exist, "(Symbol)s"),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_CONSTANT("Variable", "i", 1),
|
|
|
|
GB_CONSTANT("Property", "i", 2),
|
|
|
|
GB_CONSTANT("Method", "i", 3),
|
|
|
|
GB_CONSTANT("Event", "i", 4),
|
|
|
|
GB_CONSTANT("Constant", "i", 5),
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|
2008-01-17 22:39:26 +01:00
|
|
|
GB_DESC NATIVE_Object[] =
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2014-09-07 23:21:14 +02:00
|
|
|
GB_DECLARE_STATIC("Object"),
|
2010-01-11 00:00:31 +01:00
|
|
|
|
|
|
|
GB_STATIC_METHOD("GetProperty", "v", Object_GetProperty, "(Object)o(Property)s"),
|
|
|
|
GB_STATIC_METHOD("SetProperty", NULL, Object_SetProperty, "(Object)o(Property)s(Value)v"),
|
|
|
|
GB_STATIC_METHOD("Attach", NULL, Object_Attach, "(Object)o(Parent)o(Name)s"),
|
|
|
|
GB_STATIC_METHOD("Detach", NULL, Object_Detach, "(Object)o"),
|
|
|
|
GB_STATIC_METHOD("Class", "Class", Object_Class, "(Object)o"),
|
|
|
|
GB_STATIC_METHOD("Type", "s", Object_Type, "(Object)o"),
|
|
|
|
GB_STATIC_METHOD("Is", "b", Object_Is, "(Object)o(Class)s"),
|
|
|
|
GB_STATIC_METHOD("Parent", "o", Object_Parent, "(Object)o"),
|
|
|
|
GB_STATIC_METHOD("Call", "v", Object_Call, "(Object)o(Method)s[(Arguments)Array;]"),
|
|
|
|
GB_STATIC_METHOD("New", "o", Object_New, "(Class)s[(Arguments)Array;]"),
|
|
|
|
GB_STATIC_METHOD("IsValid", "b", Object_IsValid, "(Object)o"),
|
|
|
|
GB_STATIC_METHOD("Lock", NULL, Object_Lock, "(Object)o"),
|
|
|
|
GB_STATIC_METHOD("Unlock", NULL, Object_Unlock, "(Object)o"),
|
|
|
|
GB_STATIC_METHOD("IsLocked", "b", Object_IsLocked, "(Object)o"),
|
|
|
|
GB_STATIC_METHOD("Count", "i", Object_Count, "(Object)o"),
|
2010-08-31 14:02:08 +02:00
|
|
|
GB_STATIC_METHOD("SizeOf", "i", Object_SizeOf, "(Object)o"),
|
2010-11-22 11:10:56 +01:00
|
|
|
GB_STATIC_METHOD("Address", "p", Object_Address, "(Object)o"),
|
2012-08-20 20:05:25 +02:00
|
|
|
GB_STATIC_METHOD("CanRaise", "b", Object_CanRaise, "(Object)o(Event)s"),
|
2015-07-01 14:26:23 +02:00
|
|
|
GB_STATIC_METHOD("Raise", "b", Object_Raise, "(Object)o(Event)s[(Arguments)Array;]"),
|
2010-01-11 00:00:31 +01:00
|
|
|
|
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|