home *** CD-ROM | disk | FTP | other *** search
- /*
- commnobj.h 3/14/88
-
- % Object primitive definitions.
-
- by Ted.
-
- OWL 1.1
- 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
- */
- /* -------------------------------------------------------------------------- */
- /* 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_LASTMSG 22
-
- /* Object function types */
-
- /* Object class/dispatch function type */
- #define class_func(fname) int fname(_arg4(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(_arg1(void))
-
- /* -------------------------------------------------------------------------- */
- /* Object class/dispatch REQUEST function type */
-
- #define objreq_func(fname) int fname(_arg4(VOID *objdatap, int msg, VOID *indata, VOID *outdata))
- typedef objreq_func ((*objreq_fptr));
-
- objreq_func (objreq_Null);
-
- /* -------------------------------------------------------------------------- */
-
- /* the object data type */
-
- typedef struct obj_struct {
- class_fptr dispatch; /* object dispatch function */
- VOID *od; /* object data (points to the _od) */
- } *obj_type;
-
- typedef struct {
- int id; /* the object ID */
- } 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))
-
- /* objfuncs.c */
- extern obj_type obj_Open(_arg2(class_fptr, VOID *));
- extern void obj_Close(_arg1(obj_type));
- extern boolean obj_Who(_arg2(obj_type, int));
-
- /* -------------------------------------------------------------------------- */
-
-