home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / fish / disks / d1074.lha / Programs / C_dt / source / classbase.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-30  |  5.2 KB  |  211 lines

  1. /*
  2. ** $PROJECT: c.datatype
  3. **
  4. ** $VER: classbase.h 39.2 (11.03.95)
  5. **
  6. ** by
  7. **
  8. ** Stefan Ruppert , Windthorststraße 5 , 65439 Flörsheim , GERMANY
  9. **
  10. ** (C) Copyright 1995
  11. ** All Rights Reserved !
  12. **
  13. ** $HISTORY:
  14. **
  15. ** 11.03.95 : 039.002 : pen allocation stuff added
  16. ** 06.03.95 : 039.001 : initial
  17. */
  18.  
  19. /* ------------------------------- includes ------------------------------- */
  20.  
  21. #include <dos/dos.h>
  22. #include <dos/dosextens.h>
  23. #include <exec/types.h>
  24. #include <exec/ports.h>
  25. #include <exec/memory.h>
  26. #include <exec/lists.h>
  27. #include <exec/semaphores.h>
  28. #include <exec/execbase.h>
  29. #include <intuition/classes.h>
  30. #include <intuition/classusr.h>
  31. #include <intuition/cghooks.h>
  32. #include <intuition/gadgetclass.h>
  33. #include <graphics/gfxbase.h>
  34. #include <graphics/gfx.h>
  35. #include <graphics/text.h>
  36. #include <libraries/iffparse.h>
  37. #include <datatypes/datatypes.h>
  38. #include <datatypes/datatypesclass.h>
  39. #include <datatypes/textclass.h>
  40. #include <clib/alib_protos.h>
  41. #include <clib/alib_stdio_protos.h>
  42. #include <string.h>
  43. #include <dos.h>
  44.  
  45. #include <clib/macros.h>
  46. #include <clib/dos_protos.h>
  47. #include <clib/exec_protos.h>
  48. #include <clib/intuition_protos.h>
  49. #include <clib/iffparse_protos.h>
  50. #include <clib/graphics_protos.h>
  51. #include <clib/utility_protos.h>
  52. #include <clib/datatypes_protos.h>
  53. #include <clib/dtclass_protos.h>
  54.  
  55. #include <pragmas/dos_pragmas.h>
  56. #include <pragmas/exec_pragmas.h>
  57. #include <pragmas/intuition_pragmas.h>
  58. #include <pragmas/iffparse_pragmas.h>
  59. #include <pragmas/graphics_pragmas.h>
  60. #include <pragmas/utility_pragmas.h>
  61. #include <pragmas/datatypes_pragmas.h>
  62. #include <pragmas/dtclass_pragmas.h>
  63.  
  64. #include <ctype.h>
  65.  
  66. /* --------------------------- include my stuff --------------------------- */
  67.  
  68. #include <register.h>
  69. #include <debug.h>
  70.  
  71. #define ClassCall    LibCall
  72.  
  73. #include "protos.h"
  74.  
  75. /* -------------- set some stuff for the generic classbase.c -------------- */
  76.  
  77. /* set , which datatype library should be opened during our OpenLibrary() */
  78. #define SUPERCLASSDATATYPE       "datatypes/text.datatype"
  79.  
  80. /* set the function name to get a pointer to our class */
  81. #define ENGINE                   ObtainCEngine
  82.  
  83. #define DATATYPENAME             "c.datatype"
  84.  
  85. /* ------------------------- ClassBase structure -------------------------- */
  86.  
  87. struct ClassBase
  88. {
  89.      struct Library               cb_Lib;
  90.      UWORD                        cb_UsageCnt;
  91.      struct Library              *cb_SysBase;
  92.      struct Library              *cb_DOSBase;
  93.      struct Library              *cb_IntuitionBase;
  94.      struct Library              *cb_GfxBase;
  95.      struct Library              *cb_UtilityBase;
  96.      struct Library              *cb_IFFParseBase;
  97.      struct Library              *cb_DataTypesBase;
  98.      struct Library              *cb_SuperClassBase;
  99.      BPTR                         cb_SegList;
  100.  
  101.      struct SignalSemaphore       cb_Lock;               /* Access lock */
  102.      Class                       *cb_Class;
  103. };
  104.  
  105. /* ---------------------------- library bases ----------------------------- */
  106.  
  107. #define SysBase                 cb->cb_SysBase
  108. #define DOSBase                 cb->cb_DOSBase
  109. #define UtilityBase             cb->cb_UtilityBase
  110. #define IntuitionBase           cb->cb_IntuitionBase
  111. #define IFFParseBase            cb->cb_IFFParseBase
  112. #define GfxBase                 cb->cb_GfxBase
  113. #define DataTypesBase           cb->cb_DataTypesBase
  114. #define SuperClassBase          cb->cb_SuperClassBase
  115.  
  116. /* ----------------------- datatype specific stuff ------------------------ */
  117.  
  118. enum
  119. {
  120.     /* modes with style */
  121.     C_STANDARD,
  122.     C_COMMENT,
  123.     C_CPP,
  124.     C_KEYWORD,
  125.     C_STORAGE,
  126.     C_TYPES,
  127.     C_TYPENAME,
  128.     C_STRING,
  129.     C_NUMBER,
  130.     C_MAX,
  131.  
  132.     /* modes without style */
  133.     C_CPPTEXTLIST,
  134. };
  135.  
  136. struct Style
  137. {
  138.     UWORD FgPen;
  139.     UWORD BgPen;
  140.     UWORD Style;
  141. };
  142.  
  143. struct cdtMem
  144. {
  145.     struct cdtMem *Next;
  146.     ULONG Size;
  147. };
  148.  
  149. struct PenNode
  150. {
  151.     struct MinNode pn_Node;
  152.     ULONG pn_Red;
  153.     ULONG pn_Green;
  154.     ULONG pn_Blue;
  155.     ULONG pn_Section;
  156.     LONG pn_Pen;
  157. };
  158.  
  159. /* ---------------------------- instance data ----------------------------- */
  160.  
  161. struct CData
  162. {
  163.     APTR cd_Pool;
  164.  
  165.     UWORD cd_TabLength;
  166.  
  167.     struct List cd_PenList;
  168.     struct ColorMap *cd_ColorMap;
  169.  
  170.     struct Style cd_CStyle[C_MAX];
  171. };
  172.  
  173. /* --------------------------- parser structure --------------------------- */
  174.  
  175. struct CParse
  176. {
  177.     STRPTR BegPtr;          /* pointer to the begin of the hole text */
  178.     STRPTR SegPtr;          /* pointer to the text for the next segment */
  179.     STRPTR TxtPtr;          /* pointer to the text for the next text segment */
  180.     STRPTR ActPtr;          /* Actual text pointer */
  181.     STRPTR EndPtr;          /* End text pointer */
  182.  
  183.     UWORD TabWidth;
  184.  
  185.     ULONG Chars;
  186.     UWORD Mode;
  187.     UWORD LastMode;         /* last segment index */
  188.     int Token;              /* last token */
  189.  
  190.     ULONG XOffset;
  191.     ULONG YOffset;
  192.     ULONG XOffsetAdd;       /* for tab handling */
  193.  
  194.     ULONG MaxWidth;
  195.  
  196.     struct List *LineList;  /* list to append line segments */
  197.     struct RastPort *RPort; /* tempory RastPort for TextLength() */
  198.  
  199.     struct cdtMem *Memory;  /* memory handling for bison parser */
  200.  
  201.     struct CData *Data;     /* link to the instance data */
  202. };
  203.  
  204. int cdtparse_parse(struct ClassBase *cb,struct CParse *cparse);
  205. int cdtparse_error(char *errstr);
  206. void *cdtparse_alloc(struct ClassBase *cb,struct CParse *cparse,int size);
  207.  
  208. /* redirect bison alloca() to my own memory handling function */
  209. #define alloca(x)    cdtparse_alloc(cb,cparse,x)
  210.  
  211.