⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gambas.h

📁 Gambas is a graphical development environment based on a Basic interpreter, like Visual Basic. It us
💻 H
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************  gambas.h  Copyright (C) 2000 Beno顃 Minisini <gambas@freesurf.fr>  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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA.***************************************************************************/#ifndef __GAMBAS_H#define __GAMBAS_H/* Gambas API Version */#define GB_VERSION  1/* Useful macros */#ifndef CLEAR#define CLEAR(s) (memset(s, 0, sizeof(*s)))#endif#ifndef offsetof#define offsetof(_type, _arg) ((size_t)&(((_type *)0)->_arg))#endif/* Gambas datatypes identifiers */#define GB_T_VOID         0#define GB_T_BOOLEAN      1#define GB_T_BYTE         2#define GB_T_SHORT        3#define GB_T_INTEGER      4#define GB_T_LONG         5#define GB_T_FLOAT        6#define GB_T_DATE         7#define GB_T_STRING       8#define GB_T_CSTRING      9#define GB_T_VARIANT      10#define GB_T_NULL         15#define GB_T_OBJECT       16/* This type represents a Gambas datatype identifier */typedef  long GB_TYPE;/* This opaque type represents a Gambas class identifier */typedef  void *GB_CLASS;/* This structure represents the base of every Gambas object.   It must be placed in the beginning of all object structure defined   in a component.*/typedef  struct {    GB_CLASS klass;    long ref;    }  GB_BASE;/* Gambas common value definition */typedef  struct {    GB_TYPE type;    long _reserved[3];    }  GB_VALUE;/* Gambas VARIANT datatype definition */typedef  union {    GB_TYPE type;    struct { GB_TYPE type; long value; } _boolean;    struct { GB_TYPE type; long value; } _byte;    struct { GB_TYPE type; long value; } _short;    struct { GB_TYPE type; long value; } _integer;    struct { GB_TYPE type; long long value; } _long;    struct { GB_TYPE type; double value; } _float;    struct { GB_TYPE type; long date; long time; } _date;    struct { GB_TYPE type; char *value; } _string;    struct { GB_TYPE type; void *value; } _object;    }  GB_VARIANT_VALUE;typedef  struct {    GB_TYPE type;    GB_VARIANT_VALUE value;    }  GB_VARIANT;/* Gambas STRING datatype definition */typedef  struct {    GB_TYPE type;    struct {      char *addr;      long start;      long len;      } value;    }  GB_STRING;/* Gambas INTEGER datatype definition */typedef  struct {    GB_TYPE type;    long value;    long _reserved[2];    }  GB_INTEGER;/* Gambas BOOLEAN datatype definition */typedef  struct {    GB_TYPE type;    long value;    long _reserved[2];    }  GB_BOOLEAN;/* Gambas FLOAT datatype definition */typedef  struct {    GB_TYPE type;    double value;    long _reserved;    }  GB_FLOAT;/* Gambas DATE datatype definition */typedef  struct {    long date;    long time;    }  GB_DATE_VALUE;typedef  struct {    GB_TYPE type;    GB_DATE_VALUE value;    long _reserved;    }  GB_DATE;/* Gambas OBJECT datatype definition */typedef  struct {    GB_TYPE type;    void *value;    long _reserved[2];    }  GB_OBJECT;/* Predefined errors constants */#define GB_ERR_TYPE   ((char *)6)#define GB_ERR_ARG    ((char *)20)/* Gambas description start macro */#define GB_DECLARE(name, size) \  { name, (long)GB_VERSION, (long)size }/* Gambas description end macro */#define GB_END_DECLARE  { 0 }/* Special description identifiers */#define GB_HOOK_NEW_ID          ((char *)1)#define GB_HOOK_FREE_ID         ((char *)2)#define GB_HOOK_CHECK_ID        ((char *)3)#define GB_AUTO_CREATABLE_ID    ((char *)15)#define GB_INHERITS_ID          ((char *)16)/* Description hook macros */#define GB_HOOK_NEW(hook)    { GB_HOOK_NEW_ID, (long)hook }#define GB_HOOK_FREE(hook)   { GB_HOOK_FREE_ID, (long)hook }#define GB_HOOK_CHECK(hook)  { GB_HOOK_CHECK_ID, (long)hook }/* Virtual class description macro */#define GB_VIRTUAL_CLASS()  \  GB_HOOK_NEW(NULL), GB_HOOK_FREE(NULL)/* Not creatable class macro */#define GB_NOT_CREATABLE() \  GB_HOOK_NEW(NULL)/* Auto creatable class macro */#define GB_AUTO_CREATABLE() { GB_AUTO_CREATABLE_ID }/* Symbol description prefixes */#define GB_PROPERTY_ID          'p'#define GB_METHOD_ID            'm'#define GB_CONSTANT_ID          'C'#define GB_EVENT_ID             ':'#define GB_ENUM_ID              '#'#define GB_STATIC_PROPERTY_ID   'P'#define GB_STATIC_METHOD_ID     'M'/* Symbol description macros */#define GB_CONSTANT(symbol, type, value) \  { "C" symbol, (long)type, (long)value }#define GB_PROPERTY(symbol, type, proc) \  { "p" symbol, (long)type, (long)proc }#define GB_PROPERTY_READ(symbol, type, proc) \  { "r" symbol, (long)type, (long)proc }#define GB_PROPERTY_SELF(symbol, type) \  { "r" symbol, (long)type, (long)-1 }#define GB_METHOD(symbol, type, exec, signature) \  { "m" symbol, (long)type, (long)(exec), (long)signature }#define GB_EVENT(symbol, type, signature, id) \  { "::" symbol, (long)type, (long)id, (long)signature }#define GB_STATIC_PROPERTY(symbol, type, proc) \  { "P" symbol, (long)type, (long)proc }#define GB_STATIC_PROPERTY_READ(symbol, type, proc) \  { "R" symbol, (long)type, (long)proc }#define GB_STATIC_PROPERTY_SELF(symbol, type) \  { "R" symbol, (long)type, (long)-1 }#define GB_STATIC_METHOD(symbol, type, exec, signature) \  { "M" symbol, (long)type, (long)(exec), (long)signature }#define GB_INHERITS(symbol) \  { GB_INHERITS_ID, (long)symbol }/* Method implementation begin macro */#define BEGIN_METHOD(_name, par) \typedef \  struct { \    par; \    } \    _##_name; \\void _name(void *_object, void *_param) \{ \ _##_name *_p = (_##_name *)_param;/* Parameter-less Method implementation begin macro */#define BEGIN_METHOD_VOID(_name) \void _name(void *_object, void *_param) { \/* Parameter access macro */#define ARG(_name) (&(_p)->_name)/* Testing if a argument is missing */#define MISSING(_name) ((_p)->_name.type == GB_T_VOID)/* Method implementation end macro */#define END_METHOD }/* Macro used for calling a parameter-less implementation method */#define CALL_METHOD_VOID(_name) _name(_object, NULL)/* Property implementation begin macro */#define BEGIN_PROPERTY(_name) \void _name(void *_object, void *_param) {/* Macro indicating if the property implementation is called for reading or writing */#define READ_PROPERTY  (_param == NULL)/* Macro to get the value written to a property */#define PROP(_type) ((_type *)_param)/* Property implementation end macro */#define END_PROPERTY }/* Macros to get the value of an argument or a property */#define VALUE(_arg) ((_arg)->value)#define VARG(_p) VALUE(ARG(_p))#define VPROP(_p) VALUE(PROP(_p))/* Macros to get a string argument */#define STRING(_arg) (VARG(_arg).addr + VARG(_arg).start)#define LENGTH(_arg) (VARG(_arg).len)/* Macros to get a string property */#define PSTRING() (VPROP(GB_STRING).addr + VPROP(GB_STRING).start)#define PLENGTH() (VPROP(GB_STRING).len)/* Macro to get an optional argument */#define VARGOPT(_arg, _default) (MISSING(_arg) ? (_default) : VARG(_arg))/* Casting macro. Usable only in an implementation function */#define OBJECT(type) ((type *)_object)/* Macro for returning itself. Usable only in an implementation function */#define RETURN_SELF()  GB.ReturnObject(_object)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -