home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 2.ddi / OWLSRC.EXE / CSCAPE / SOURCE / COMMNOBJ.H < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  2.8 KB  |  92 lines

  1. /*
  2.     commnobj.h    3/14/88
  3.  
  4.     % Object primitive definitions.
  5.  
  6.     by Ted.
  7.  
  8.     OWL 1.1
  9.     Copyright (c) 1988, by Oakland Group, Inc.
  10.     ALL RIGHTS RESERVED.
  11.  
  12.     Note:    Object IDs should be between 10 and 999.
  13.             They are used as omalloc tags.
  14.  
  15.     Revision History:
  16.     -----------------
  17.      6/16/88 Ted    revised to have inheritance and class factory functions
  18.      8/09/88 jmd    simplified object workings
  19.      9/12/88 jmd    Added in and out data to objects
  20.     11/14/88 jmd    Removed NULL check from obj_Do
  21.     11/20/88 jmd    Added ID to obj struct
  22.     11/20/88 jmd    Extracted commonod.h
  23.  
  24.      3/23/89 Ted    Renamed from objdecl.h
  25.      3/23/89 Ted    Added _xd stuff, moved id into xd.
  26.      7/12/89 ted    Converted '_func' prototypes from typedef to macro.
  27.      8/11/89 jmd    added WHO message
  28. */
  29. /* -------------------------------------------------------------------------- */
  30. /* object messages */
  31.  
  32. #define OBJM_OPEN            0
  33. #define OBJM_CLOSE            1
  34. #define OBJM_GETDATASIZE    2
  35. #define OBJM_INIT            3
  36. #define OBJM_LOAD            4
  37. #define OBJM_SAVE            5
  38. #define OBJM_WHO            6
  39. #define OBJM_BEWARE            7    /* For Perth Pink bottle object */
  40. #define OBJM_LASTMSG       22
  41.  
  42. /* Object function types */
  43.  
  44. /* Object class/dispatch function type */
  45. #define class_func(fname)            int fname(_arg4(VOID *objdatap, int msg, VOID *indata, VOID *outdata))
  46. typedef class_func ((*class_fptr));
  47.  
  48. /* Function type for enabling extended features of a window class */
  49. #define classinit_func(fname)        void fname(_arg1(void))
  50.  
  51. /* -------------------------------------------------------------------------- */
  52. /* Object class/dispatch REQUEST function type */
  53.  
  54. #define objreq_func(fname)        int fname(_arg4(VOID *objdatap, int msg, VOID *indata, VOID *outdata))
  55. typedef objreq_func ((*objreq_fptr));
  56.  
  57. objreq_func (objreq_Null);
  58.  
  59. /* -------------------------------------------------------------------------- */
  60.  
  61. /* the object data type */
  62.  
  63. typedef struct obj_struct {
  64.     class_fptr        dispatch;            /* object dispatch function */
  65.     VOID           *od;                    /* object data (points to the _od) */
  66. } *obj_type;
  67.  
  68. typedef struct {
  69.     int                id;                    /* the object ID */
  70. } common_xd;
  71.  
  72. /* Macros */
  73.  
  74. #define obj_Do(obj, msg, indata, outdata)            \
  75.     (*(obj)->dispatch)((obj)->od, msg, (VOID *)(indata), (VOID *)(outdata))
  76.  
  77. #define obj_getxd(obj)                ((VOID *) &(obj)[1])
  78.  
  79. /* NOTE: These macros assume that the common_xd is first in the nested _xd */
  80. /*  structures. Memory trashing will occur if this is not the case. */
  81. /* This is the idea the xdata scheme is based on anyway. */
  82. #define obj_GetId(obj)                (((common_xd *) obj_getxd(obj))->id)
  83. #define obj_setid(obj, idd)            (((common_xd *) obj_getxd(obj))->id = (idd))
  84.  
  85. /* objfuncs.c */
  86. extern obj_type obj_Open(_arg2(class_fptr, VOID *));
  87. extern void     obj_Close(_arg1(obj_type));
  88. extern boolean     obj_Who(_arg2(obj_type, int));
  89.  
  90. /* -------------------------------------------------------------------------- */
  91.  
  92.