2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
gbx_c_class.c
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
(c) 2000-2009 Benoît Minisini <gambas@users.sourceforge.net>
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +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
|
|
|
|
2010-01-11 00:00:31 +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
|
|
|
|
2010-01-11 00:00:31 +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., 675 Mass Ave, Cambridge, MA 02139, 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"
|
2008-02-14 12:59:36 +01:00
|
|
|
#include "gbx_c_gambas.h"
|
2007-12-30 17:41:49 +01:00
|
|
|
#include "gbx_c_class.h"
|
|
|
|
|
|
|
|
static CLASS_DESC_SYMBOL *_current_symbol = NULL;
|
|
|
|
|
|
|
|
static CLASS_DESC *get_desc(CLASS *class, const char *name)
|
|
|
|
{
|
2010-01-11 00:00:31 +01:00
|
|
|
int index;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
index = CLASS_find_symbol(class, name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
//fprintf(stderr, "CLASS_find_symbol('%s', '%s') = %ld\n", class->name, name, index);
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (index == NO_SYMBOL)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_NSYMBOL, name, class->name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return class->table[index].desc;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2010-01-11 00:00:31 +01: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
|
|
|
|
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_ReturnBoolean(comp && comp->loaded);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
2010-01-11 00:00:31 +01: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
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (!class->state)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Class_Name)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnConstZeroString(OBJECT(CLASS)->name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_METHOD_VOID(Classes_next)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
TABLE *table = CLASS_get_table();
|
|
|
|
int *index = (int *)GB_GetEnum();
|
|
|
|
CLASS *class;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
if (*index >= TABLE_count(table))
|
|
|
|
{
|
|
|
|
GB_StopEnum();
|
|
|
|
break;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
class = ((CLASS_SYMBOL *)TABLE_get_symbol(table, *index))->class;
|
|
|
|
(*index)++;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (class->state)
|
|
|
|
{
|
|
|
|
GB_ReturnObject(class);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
/**** Class ****************************************************************/
|
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
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Class_Hidden)
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnBoolean(*(OBJECT(CLASS)->name) == '.');
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
GB_ArrayNew(&array, T_STRING, 0);
|
|
|
|
|
|
|
|
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;
|
|
|
|
STRING_new((char **)GB_ArrayAdd(array), cds->name, cds->len);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
2010-01-11 00:00:31 +01:00
|
|
|
|
|
|
|
GB_ReturnObject(array);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2010-03-25 12:16:33 +01:00
|
|
|
BEGIN_METHOD_VOID(Class_AutoCreate)
|
|
|
|
|
|
|
|
CLASS *class = OBJECT(CLASS);
|
|
|
|
|
|
|
|
if (!class->auto_create)
|
|
|
|
GB_ReturnNull();
|
|
|
|
else
|
|
|
|
GB_ReturnObject(CLASS_auto_create(class, 0));
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01: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;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_ReturnConstZeroString(CLASS_DESC_get_signature(cds->desc));
|
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)
|
|
|
|
{
|
|
|
|
GB_ReturnNull();
|
|
|
|
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);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
2010-01-11 00:00:31 +01: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;
|
|
|
|
CLASS_DESC *desc;
|
|
|
|
CLASS *class;
|
|
|
|
char type;
|
|
|
|
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
|
|
|
if (OBJECT_is_class(object))
|
|
|
|
{
|
|
|
|
class = (CLASS *)object;
|
|
|
|
object = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
class = OBJECT_class(object);
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
name = GB_ToZeroString(ARG(property));
|
|
|
|
desc = get_desc(class, name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (!desc)
|
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
type = CLASS_DESC_get_type(desc);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (type == CD_PROPERTY || type == CD_PROPERTY_READ || type == CD_VARIABLE)
|
|
|
|
{
|
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_DYNAMIC, class->name, name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (type == CD_STATIC_PROPERTY || type == CD_STATIC_PROPERTY_READ || type == CD_STATIC_VARIABLE || type == CD_CONSTANT)
|
|
|
|
{
|
|
|
|
if (object)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_STATIC, class->name, name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_NPROPERTY, class->name, name);
|
|
|
|
return;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2008-01-19 21:59:09 +01:00
|
|
|
if (type == CD_VARIABLE)
|
2010-01-11 00:00:31 +01:00
|
|
|
VALUE_read(&TEMP, (char *)object + desc->variable.offset, desc->property.type);
|
2008-01-19 21:59:09 +01:00
|
|
|
else if (type == CD_STATIC_VARIABLE)
|
2010-01-11 00:00:31 +01:00
|
|
|
VALUE_read(&TEMP, (char *)class->stat + desc->variable.offset, desc->property.type);
|
|
|
|
else if (type == CD_CONSTANT)
|
|
|
|
VALUE_read(&TEMP, (void *)&desc->constant.value, desc->constant.type);
|
2008-01-19 21:59:09 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (desc->property.native)
|
|
|
|
{
|
|
|
|
if (EXEC_call_native(desc->property.read, object, desc->property.type, 0))
|
|
|
|
{
|
|
|
|
GAMBAS_Error = TRUE;
|
|
|
|
return;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
2008-01-19 21:59:09 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
EXEC.class = desc->property.class;
|
|
|
|
EXEC.object = object;
|
|
|
|
EXEC.drop = FALSE;
|
|
|
|
EXEC.nparam = 0;
|
|
|
|
EXEC.native = FALSE;
|
|
|
|
EXEC.index = (int)(intptr_t)desc->property.read;
|
|
|
|
//EXEC.func = &class->load->func[(long)desc->property.read];
|
|
|
|
|
|
|
|
EXEC_function_keep();
|
|
|
|
|
|
|
|
TEMP = *RP;
|
|
|
|
UNBORROW(RP);
|
|
|
|
RP->type = T_VOID;
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
CLASS_DESC *desc;
|
|
|
|
CLASS *class;
|
|
|
|
char type;
|
|
|
|
void *object = VARG(object);
|
|
|
|
VALUE *value = (VALUE *)ARG(value);
|
|
|
|
|
|
|
|
if (GB_CheckObject(object))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (OBJECT_is_class(object))
|
|
|
|
{
|
|
|
|
class = (CLASS *)object;
|
|
|
|
object = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
class = OBJECT_class(object);
|
|
|
|
}
|
|
|
|
|
|
|
|
name = GB_ToZeroString(ARG(property));
|
|
|
|
desc = get_desc(class, name);
|
|
|
|
|
|
|
|
if (!desc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
type = CLASS_DESC_get_type(desc);
|
|
|
|
|
|
|
|
if (type == CD_PROPERTY || type == CD_VARIABLE)
|
|
|
|
{
|
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
if (!class->auto_create)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_DYNAMIC, class->name, name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
object = EXEC_auto_create(class, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (type == CD_STATIC_PROPERTY || type == CD_STATIC_VARIABLE)
|
|
|
|
{
|
|
|
|
if (object)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_STATIC, class->name, name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (type == CD_PROPERTY_READ || type == CD_STATIC_PROPERTY_READ)
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_NWRITE, class->name, name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GB_Error((char *)E_NPROPERTY, class->name, name);
|
|
|
|
return;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2008-01-19 21:59:09 +01:00
|
|
|
if (type == CD_VARIABLE)
|
2010-01-11 00:00:31 +01:00
|
|
|
VALUE_write(value, (char *)object + desc->variable.offset, desc->variable.type);
|
2008-01-19 21:59:09 +01:00
|
|
|
else if (type == CD_STATIC_VARIABLE)
|
2010-01-11 00:00:31 +01:00
|
|
|
VALUE_write(value, (char *)class->stat + desc->variable.offset, desc->variable.type);
|
2008-01-19 21:59:09 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (desc->property.native)
|
|
|
|
{
|
|
|
|
VALUE_conv(value, desc->property.type);
|
|
|
|
|
|
|
|
if (EXEC_call_native(desc->property.write, object, 0, value))
|
|
|
|
{
|
|
|
|
GAMBAS_Error = TRUE;
|
|
|
|
return;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
2008-01-19 21:59:09 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*SP = *value;
|
|
|
|
BORROW(SP);
|
|
|
|
SP++;
|
|
|
|
|
|
|
|
EXEC.class = desc->property.class;
|
|
|
|
EXEC.object = object;
|
|
|
|
EXEC.drop = FALSE;
|
|
|
|
EXEC.nparam = 1;
|
|
|
|
EXEC.native = FALSE;
|
|
|
|
EXEC.index = (int)(intptr_t)desc->property.write;
|
|
|
|
//EXEC.func = &class->load->func[(long)desc->property.write];
|
|
|
|
|
|
|
|
EXEC_function();
|
|
|
|
|
|
|
|
/*VALUE_write(value, OBJECT_get_prop_addr(object, desc), desc->property.type);*/
|
|
|
|
}
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
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);
|
2008-02-14 12:59:36 +01: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
|
|
|
|
|
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);
|
2010-01-11 00:00:31 +01:00
|
|
|
|
|
|
|
OBJECT_detach(object);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
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_class(object));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
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
|
|
|
|
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_ReturnConstZeroString(OBJECT_class(object)->name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
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
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (GB_CheckObject(object))
|
|
|
|
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
|
|
|
|
|
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;
|
2010-03-25 12:16:33 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (GB_GetFunction(&func, object, name, NULL, NULL))
|
|
|
|
{
|
2010-03-25 12:16:33 +01:00
|
|
|
GB_Error((char *)E_NSYMBOL, name, 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);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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);
|
2010-01-11 00:00:31 +01:00
|
|
|
OBJECT_UNREF_KEEP(object, "Object_New");
|
2007-12-30 17:41:49 +01:00
|
|
|
GB_ReturnObject(object);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
BEGIN_PROPERTY(Object_LastEventName)
|
2008-02-21 14:14:16 +01:00
|
|
|
|
|
|
|
GB_ReturnString(EVENT_Name);
|
|
|
|
|
|
|
|
END_PROPERTY
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2010-01-11 00:00:31 +01: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
|
|
|
{
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_DECLARE(".Symbol", 0), GB_VIRTUAL_CLASS(),
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_DECLARE("Components", 0), GB_VIRTUAL_CLASS(),
|
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
|
|
|
{
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_DECLARE("Component", 0), GB_VIRTUAL_CLASS(),
|
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"),
|
|
|
|
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
|
|
|
{
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_DECLARE("Classes", 0), GB_VIRTUAL_CLASS(),
|
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
|
|
|
{
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_DECLARE("Class", 0), GB_VIRTUAL_CLASS(),
|
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
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_METHOD("_get", ".Symbol", Class_get, "(Name)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),
|
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
|
|
|
{
|
2010-01-11 00:00:31 +01:00
|
|
|
GB_DECLARE("Object", 0), GB_VIRTUAL_CLASS(),
|
|
|
|
|
|
|
|
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"),
|
|
|
|
GB_STATIC_PROPERTY_READ("LastEventName", "s", Object_LastEventName),
|
|
|
|
|
|
|
|
GB_END_DECLARE
|
2007-12-30 17:41:49 +01:00
|
|
|
};
|
|
|
|
|