home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
INCLUDE
/
COMMNOBJ.H
< prev
next >
Wrap
C/C++ Source or Header
|
1990-09-07
|
4KB
|
133 lines
/*
commnobj.h 3/14/88
% Object primitive definitions.
by Ted.
OWL 1.2
Copyright (c) 1988, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Note: Object IDs should be between 10 and 999.
They are used as omalloc tags.
Revision History:
-----------------
6/16/88 Ted revised to have inheritance and class factory functions
8/09/88 jmd simplified object workings
9/12/88 jmd Added in and out data to objects
11/14/88 jmd Removed NULL check from obj_Do
11/20/88 jmd Added ID to obj struct
11/20/88 jmd Extracted commonod.h
3/23/89 Ted Renamed from objdecl.h
3/23/89 Ted Added _xd stuff, moved id into xd.
7/12/89 ted Converted '_func' prototypes from typedef to macro.
8/11/89 jmd added WHO message
11/06/89 jmd added common_Class macro
12/12/89 jmd added object names
3/28/90 jmd ansi-fied
5/08/90 jmd added underscores to func macros for vms compiler
7/29/90 jmd added auxiliary func to objects
8/04/90 jmd moved aux messages to oakaux.h
9/07/90 jmd renamed oslist stuff
*/
/* -------------------------------------------------------------------------- */
/* the object name list */
OEXTERN oslist_type objnamelist;
/* common_Class doesn't really exist, trick its children with this macro */
#define common_Class(od, msg, indata, outdata) (TRUE)
/* object messages */
#define OBJM_OPEN 0
#define OBJM_CLOSE 1
#define OBJM_GETDATASIZE 2
#define OBJM_INIT 3
#define OBJM_LOAD 4
#define OBJM_SAVE 5
#define OBJM_WHO 6
#define OBJM_BEWARE 7 /* For Perth Pink bottle object */
#define OBJM_GETVALUE 8
#define OBJM_LASTMSG 22
/* Object function types */
/* Object class/dispatch function type */
#define class_func(fname) int fname(VOID *_objdatap, int _msg, VOID *_indata, VOID *_outdata)
typedef class_func ((*class_fptr));
/* Function type for enabling extended features of a window class */
#define classinit_func(fname) void fname(void)
/* -------------------------------------------------------------------------- */
/* Object class/dispatch REQUEST function type */
#define objreq_func(fname) int fname(VOID *_objdatap, int _msg, VOID *_indata, VOID *_outdata)
typedef objreq_func ((*objreq_fptr));
/* -------------------------------------------------------------------------- */
/* the object data type */
typedef struct obj_struct {
class_fptr dispatch; /* object dispatch function */
VOID *od; /* object data (points to the _od) */
} *obj_type;
/* Auxiliary function type */
#define aux_func(fname) int fname(obj_type _obj, int _msg, VOID *_indata, VOID *_outdata)
typedef aux_func ((*aux_fptr));
typedef struct _commonxd {
int id; /* the object ID */
int name; /* object name handle */
aux_fptr aux; /* object auxiliary function */
} common_xd;
/* Macros */
#define obj_Do(obj, msg, indata, outdata) \
(*(obj)->dispatch)((obj)->od, msg, (VOID *)(indata), (VOID *)(outdata))
#define obj_getxd(obj) ((VOID *) &(obj)[1])
/* NOTE: These macros assume that the common_xd is first in the nested _xd */
/* structures. Memory trashing will occur if this is not the case. */
/* This is the idea the xdata scheme is based on anyway. */
#define obj_GetId(obj) (((common_xd *) obj_getxd(obj))->id)
#define obj_setid(obj, idd) (((common_xd *) obj_getxd(obj))->id = (idd))
#define obj_SetNameHandle(obj, n) (((common_xd *) obj_getxd(obj))->name = (n))
#define obj_GetNameHandle(obj) (((common_xd *) obj_getxd(obj))->name)
#define obj_GetName(obj) (oslist_GetSym(objnamelist, obj_GetNameHandle(obj)))
#define obj_GetAux(obj) (((common_xd *) obj_getxd(obj))->aux)
#define obj_setox(obj, ox) (((common_xd *) obj_getxd(obj))->aux = (ox))
/* -------------------------------------------------------------------------- */
/* function prototypes */
/* OBJFUNCS.C */
extern void oak_Close(void);
extern obj_type obj_Open(class_fptr dispatch, VOID *opendata);
extern void obj_Close(obj_type obj);
extern boolean obj_Who(obj_type obj, int type);
extern void obj_RemoveName(obj_type obj);
extern int obj_DoAux(obj_type obj, int msg, VOID *indata, VOID *outdata);
extern void obj_SetAux(obj_type obj, aux_fptr aux);
extern objreq_func (objreq_Null);
/* OBJNAME.C */
extern obj_type obj_Find(char *name);
extern int obj_SetName(obj_type obj, char *name);
/* -------------------------------------------------------------------------- */