home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gwm18a.zip / wl_name.h < prev    next >
C/C++ Source or Header  |  1995-07-03  |  5KB  |  142 lines

  1. /* Copyright 1989 GROUPE BULL -- See license conditions in file COPYRIGHT
  2.  * Copyright 1989 Massachusetts Institute of Technology
  3.  */
  4. /**************************\
  5. *                *
  6. *  WOOL_OBJECT  Namespace  *
  7. *  DEFINITIONS           *
  8. *                *
  9. \**************************/
  10.  
  11. #ifndef INCLUDE_WL_NAMESPACE_H
  12. #define INCLUDE_WL_NAMESPACE_H
  13.  
  14. /* type */
  15.  
  16. /* a namespace is an array of values, a name is an offset in this namespace
  17.  * 
  18.  * a namespace type is an array (one per namespace in the type) of an
  19.  * array to values of the names (names are offsets in this namespace
  20.  */
  21.  
  22. typedef struct _WOOL_Namespace {
  23.     WOOL_HEADER;
  24.     int current;            /* current (active) namespace */
  25.     int number;                /* number of namespaces */
  26.     int size;                /* number of slots in a namespace */
  27.     int limit;                /* number of allocated slots */
  28.     void (*trigger) ();            /* callback on change of state */
  29.     void (*save_state) ();        /* save state before scanning */
  30.     void (*restore_state) ();        /* restore state after scanning */
  31.     int first_deleted;            /* index of first vacant slot */
  32.     WOOL_OBJECT **namespaces;        /* array of names */
  33. }              *WOOL_Namespace;
  34.  
  35. /* A name is like an atom, but with value being an index in a namespace, and
  36.  * the base pointer being the namespace
  37.  */
  38.  
  39. typedef struct _WOOL_Name {
  40.     WOOL_HEADER;
  41.     Num      index;          /* index in namespace */
  42.     char        p_name[1];      /* same as for atoms */
  43. }              *WOOL_Name;
  44.  
  45. typedef struct _WOOL_Name_internal {
  46.     WOOL_Namespace namespace;   /* the namespace */
  47.     WOOL_HEADER;
  48.     Num      index;          /* index in namespace */
  49.     char        p_name[1];      /* same as for atoms */
  50. }              *WOOL_Name_internal;
  51.  
  52. /* macro to access the namespace field */
  53.  
  54. #define NameNamespace(a) \
  55.     (((WOOL_Name_internal) (((char *) a) - \
  56.     (sizeof(struct _WOOL_Name_internal) - \
  57.     sizeof(struct _WOOL_Name)))) -> namespace)
  58.  
  59. /* exported functions */
  60.  
  61. EXT WOOL_Namespace WLNamespace_make();
  62. EXT WOOL_OBJECT  WLNamespace_eval();
  63. EXT WOOL_OBJECT  WLNamespace_print();
  64. EXT WOOL_OBJECT  WLNamespace_free();
  65.  
  66. EXT WOOL_OBJECT  WLName_eval();
  67. EXT WOOL_OBJECT  WLName_silent_eval();
  68. EXT WOOL_OBJECT  WLName_execute();
  69. EXT WOOL_OBJECT  WLName_set();
  70. EXT WOOL_OBJECT  WLName_setq();
  71.  
  72. EXT WOOL_OBJECT  WLNamespace_add();
  73. EXT WOOL_OBJECT  WLNamespace_remove();
  74. EXT WOOL_OBJECT  WLName_add();
  75. EXT WOOL_OBJECT  WLNamespace_set_current();
  76. EXT WOOL_OBJECT  WLName_namespace();
  77. EXT WOOL_OBJECT  WLNamespace_size();
  78. EXT WOOL_OBJECT *WLName_slot();
  79.  
  80. #define must_be_namespace(namespace, n) must_be(WLNamespace, namespace, n)
  81. #define must_be_name(name, n) must_be(WLName, namespace, n)
  82.  
  83. /* methods */
  84.  
  85. EXT WOOL_METHOD WLName[]
  86. #ifdef DO_INIT
  87. = {
  88.    (WOOL_METHOD) 0,        /* METHODS_ARRAY */
  89.    WLName_eval,        /* WOOL_eval 1 */
  90.    WLAtom_print,        /* WOOL_print 2 */
  91.    WLAtom_free,            /* same error as to free an atom */
  92.    WLName_execute,        /* WOOL_execute 4 */
  93.    WLName_set,        /* WOOL_set 5 */
  94.    wool_undefined_method_1,    /* WOOL_get_C_value 6 */
  95.    wool_undefined_method_1,    /* WOOL_open 7 */
  96.    wool_undefined_method_1,    /* WOOL_close 8 */
  97.    wool_undefined_method_2,    /* WOOL_process_event 9 */
  98.    wool_undefined_method_1,    /* WOOL_copy 10 */
  99.    wool_undefined_method_2,    /* WOOL_get_dimensions 11 */
  100.    wool_undefined_method_2,    /* WOOL_draw 12 */
  101.    WLAtom_equal,        /* WOOL_equal 13 */
  102.    wool_undefined_method_2,
  103.    WLName_setq,               /* WOOL_setq 15 */
  104.    wool_undefined_method_1,
  105.    WLName_silent_eval,
  106.    wool_undefined_method_1,
  107.    wool_undefined_method_1,
  108.    wool_undefined_method_1
  109. }
  110. #endif /* DO_INIT */
  111.                ;
  112.  
  113. EXT WOOL_METHOD WLNamespace[]
  114. #ifdef DO_INIT
  115. = {
  116.    (WOOL_METHOD) 0,        /* METHODS_ARRAY */
  117.    WLNumber_eval,        /* WOOL_eval 1 */
  118.    WLNamespace_print,        /* WOOL_print 2 */
  119.    WLNamespace_free,    /* same error as to free an atom */
  120.    wool_undefined_method_2,        /* WOOL_execute 4 */
  121.    wool_undefined_method_2,        /* WOOL_set 5 */
  122.    wool_undefined_method_1,    /* WOOL_get_C_value 6 */
  123.    wool_undefined_method_1,    /* WOOL_open 7 */
  124.    wool_undefined_method_1,    /* WOOL_close 8 */
  125.    wool_undefined_method_2,    /* WOOL_process_event 9 */
  126.    wool_undefined_method_1,    /* WOOL_copy 10 */
  127.    wool_undefined_method_2,    /* WOOL_get_dimensions 11 */
  128.    wool_undefined_method_2,    /* WOOL_draw 12 */
  129.    WLAtom_equal,        /* WOOL_equal 13 */
  130.    wool_undefined_method_2,
  131.    wool_undefined_method_1,               /* WOOL_setq 15 */
  132.    wool_undefined_method_1,
  133.    wool_undefined_method_1,
  134.    wool_undefined_method_1,
  135.    wool_undefined_method_1,
  136.    wool_undefined_method_1
  137. }
  138. #endif /* DO_INIT */
  139.                ;
  140.  
  141. #endif /* INCLUDE_WL_NAMESPACE_H */
  142.