Designating 'private' methods and attributes

To designate methods or attributes within an IDL specification as "private," the declaration of the method or attribute must be surrounded with the preprocessor commands #ifdef__PRIVATE__ (with two leading underscores and two following underscores) and #endif. For example, to declare a method "foo" as a private method, the following declaration would appear within the interface statement:

   #ifdef __PRIVATE__
   void foo();
   #endif

Any number of methods and attributes can be designated as private, either within a single #ifdef or in separate ones. [Kernighan-Ritchie reference for the C preprocessor: pages 88-92.]

When compiling an .idl file, the SOM Compiler normally recognizes only public (nonprivate) methods and attributes, as that is generally all that is needed. To generate header files for client programs that do need to access private methods and attributes, or for use when implementing a class library containing private methods, the -p option should be included when running the SOM Compiler. The resulting header files will then include bindings for private, as well as public, methods and attributes. Both the implementation bindings (.ih or .xih file) and the usage bindings to be #included in the implementation (.h or .xh file) should be generated under the -p option. The -p option is described in the topic "Running the SOM Compiler" later in this chapter.

The SOMobjects Toolkit also provides a pdl (Public Definition Language) emitter that can be used with the SOM Compiler to generate a copy of an .idl file which has the portions designated as private removed. The next main section of this chapter describes how to invoke the SOM Compiler and the various emitters.


[Back: Comments within a SOM IDL file]
[Next: Module declarations to define multiple interfaces in a .idl file]