How GMS Compiles Menu Specifications
GMS does not display menus by reading information directly from their specifications. To improve performance, GMS compiles all menu specifications. The GMS compiler is native to GMS. It is not the same as the G2 compiler.
The following diagram summarizes what happens when you compile a menu. It is explained in the sections that follow.
.
The Menu Translation
The result of compiling a menu specification is called a menu translation. GMS keeps all menu translations in a repository called the compiled resource. At most one compiled resource exists, which holds every existing menu translation.
By default, GMS automatically:
Caution: The compiled resource is for internal use only by GMS. You never need to examine it, and you must never modify it in any way.
The Menu Instance
A menu translation in the compiled resource is not a displayable menu, but a representation that GMS can use to build a displayable menu. In order to display a menu in a window, GMS must build the menu itself. A menu that GMS builds from data in the compiled resource is called a menu instance.
Every menu instance is bound to a particular G2 window and can be displayed only in that window. Thus, a separate menu instance exists for every menu translation in every G2 window.
The Handle
When GMS builds a menu for a window, it first assigns the window an identifying integer called a handle. GMS uses a window's handle to manage the relationship of the window to any GMS menu(s) displayed within it.
A menu instance does not duplicate the information in the underlying menu translation in the compiled resource. The information remains in the compiled resource, and the menu instance makes it available in the context of a particular window.
By default, GMS automatically:
Compiling One or All Menus
You can ask GMS to compile or recompile any or all menu specifications at any time. When GMS compiles one or more menu specifications, it:
By default, GMS then assigns every G2 window a handle and builds an instance of every menu translation for every window. You can change this default using techniques described under Compiling and Building Menus.
To compile a menu specification:
To compile all menu specifications:
GMS describes any compilation errors by signalling an error and cancelling compilation. For more information about compiling GMS menus see Compiling Menus.
Copyright © 1997 Gensym Corporation, Inc.