home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / scemit.idl < prev    next >
Encoding:
Text File  |  1996-02-21  |  19.9 KB  |  486 lines

  1. //
  2. //   COMPONENT_NAME: some
  3. //
  4. //   ORIGINS: 27
  5. //
  6. //
  7. //   10H9767, 10H9769  (C) COPYRIGHT International Business Machines Corp. 1992,1994
  8. //   All Rights Reserved
  9. //   Licensed Materials - Property of IBM
  10. //   US Government Users Restricted Rights - Use, duplication or
  11. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  12. //
  13.  
  14. #ifndef scemit_idl
  15. #define scemit_idl
  16.  
  17. #include <somobj.idl>
  18. #include <sctmplt.idl>
  19. #include "sctypes.h"
  20.  
  21.  
  22. interface SOMTEmitC : SOMObject
  23.  
  24. // This is the pluggable unit in the SOM emitter framework. An emitter
  25. // is constructed by subclassing this class and then running the
  26. // master emitter program providing the name of the subclass as one of
  27. // its command line arguments.
  28. // The concepts of this class are simple:
  29. //
  30. //   Emitters always consist of a set of sections
  31. //   The sections are in a particular order for any particular
  32. //   emitter, and the order does not vary with the data processed by
  33. //   the emitter.
  34. //   A number of the sections of an emitter are common (maybe with
  35. //   slight variation) across several (or even most) emitters.
  36. //   There are a number of constructs that occur in varying numbers,
  37. //   eg, method declarations, data declarations, and attribute
  38. //   declarations.
  39. // Consequently, this class provides methods for:
  40. //   Methods for many common sections, including several that may be
  41. //   useful without overridding in several different emitters
  42. //   Sequencing through the sections of the emitter
  43. //   Iterating through the constructs that occur in varying numbers
  44.  
  45. {
  46.   attribute SOMTTemplateOutputC somtTemplate;
  47.   // The template is to provide template output and maintains a symbol
  48.   // table that provides a sort of global context for the emitter.
  49.  
  50.   attribute FILE *somtTargetFile;
  51.   // The target file is the one to which all emitter output is to be
  52.   // directed.
  53.  
  54.   attribute SOMTClassEntryC somtTargetClass;
  55.   // The target class is the class definition for which code is to be
  56.   // emitted.
  57.  
  58.   attribute SOMTModuleEntryC somtTargetModule;
  59.   // The target module is the module definition for which code is to be
  60.   // emitted.
  61.  
  62.   attribute SOMTTargetTypeT somtTargetType;
  63.   // The target type indicates what type of output file is being
  64.   // produced, public, private, or implementation.  This allows the
  65.   // same emitter subclass to produce several different output files
  66.   // that generally differ only in how much of the class definition
  67.   // they cover. Eg, .csc, .sc, and .psc.
  68.   // This is attribute is for OIDL compatibility only.
  69.  
  70.   attribute string somtEmitterName;
  71.   // The short name of the emitter (the name used to invoke it via the
  72.   // SOM Compiler.  Typically this is the file stem of the subclass
  73.   // of SOMTEmitC. This attribute should be set in the driver program
  74.   // that runs the emitter.  It is used to filter passthrus so that only
  75.   // passthrus directed to a particular emitter are seen by it.
  76.  
  77.   boolean somtGenerateSections();
  78.   // Calls each of the section methods in order.  The order is:
  79.   //
  80.   //   somtEmitProlog
  81.   //   when emitting a class:
  82.   //         somtEmitClass
  83.   //         somtEmitBase
  84.   //         somtEmitMeta
  85.   //   somtEmitConstant
  86.   //   somtEmitTypedef
  87.   //   somtEmitStruct
  88.   //   somtEmitUnion
  89.   //   somtEmitEnum
  90.   //   when emitting a class:
  91.   //      somtEmitAttribute
  92.   //      somtEmitMethod
  93.   //      somtEmitRelease
  94.   //      somtEmitPassthru
  95.   //      somtEmitData
  96.   //   when emitting a module:
  97.   //       somtEmitInterface
  98.   //       somtEmitModule
  99.   //   somtEmitEpilog
  100.   //
  101.   // This method will need to be overridden by many emitters in order
  102.   // to rearange the order of the sections and to add or delete
  103.   // sections.
  104.   // Note: repeating sections such as methods, data, and passthru,
  105.   // have a prolog and epilog method as well. The prolog method is
  106.   // called before the first sections is processed and the epilog method
  107.   // is called after the last section is processed.
  108.  
  109.   FILE* somtOpenSymbolsFile(in string file, 
  110.                            in string mode);
  111.  
  112.   // This method attempts to open the symbols file.
  113.   // If file doesn't exist then it will attempt to find it in the
  114.   // directories specified in the SMINCLUDE environment variable.
  115.   // If the file can be found a FILE * pointer is returned, otherwise
  116.   // NULL is returned.
  117.  
  118.   void somtSetPredefinedSymbols();
  119.  
  120.   // Set predefined symbols that are used for such things as section
  121.   // names etc.
  122.  
  123.   void somtFileSymbols();
  124.  
  125.   // Symbols that are common to the file.  This includes the target
  126.   // class symbols, and the metaclass symbols, and special symbols
  127.   // like <timeStamp>.  IE, all symbols that have a single definition.
  128.  
  129.   void somtEmitProlog();
  130.   void somtEmitBaseIncludesProlog();
  131.   void somtEmitBaseIncludes(in SOMTBaseClassEntryC base);
  132.   void somtEmitBaseIncludesEpilog();
  133.   void somtEmitMetaInclude();
  134.   void somtEmitClass();
  135.   void somtEmitMeta();
  136.   void somtEmitBaseProlog();
  137.   void somtEmitBase(in SOMTBaseClassEntryC base);
  138.   void somtEmitBaseEpilog();
  139.   void somtEmitPassthruProlog();
  140.   void somtEmitPassthru(in SOMTPassthruEntryC entry);
  141.   void somtEmitPassthruEpilog();
  142.   void somtEmitRelease();
  143.   void somtEmitDataProlog();
  144.   void somtEmitData(in SOMTDataEntryC entry);
  145.   void somtEmitDataEpilog();
  146.   void somtEmitAttributeProlog();
  147.   void somtEmitAttribute(in SOMTAttributeEntryC att);
  148.   void somtEmitAttributeEpilog();
  149.   void somtEmitConstantProlog();
  150.   void somtEmitConstant(in SOMTConstEntryC con);
  151.   void somtEmitConstantEpilog();
  152.   void somtEmitTypedefProlog();
  153.   void somtEmitTypedef(in SOMTTypedefEntryC td);
  154.   void somtEmitTypedefEpilog();
  155.   void somtEmitStructProlog();
  156.   void somtEmitStruct(in SOMTStructEntryC struc);
  157.   void somtEmitStructEpilog();
  158.   void somtEmitUnionProlog();
  159.   void somtEmitUnion(in SOMTUnionEntryC un);
  160.   void somtEmitUnionEpilog();
  161.   void somtEmitEnumProlog();
  162.   void somtEmitEnum(in SOMTEnumEntryC en);
  163.   void somtEmitEnumEpilog();
  164.   void somtEmitInterfaceProlog();
  165.   void somtEmitInterface(in SOMTClassEntryC intfc);
  166.   void somtEmitInterfaceEpilog();
  167.   void somtEmitModuleProlog();
  168.   void somtEmitModule(in SOMTModuleEntryC mod);
  169.   void somtEmitModuleEpilog();
  170.   void somtEmitMethodsProlog();
  171.   void somtEmitMethods(in SOMTMethodEntryC method);
  172.   void somtEmitMethodsEpilog();
  173.   void somtEmitMethod(in SOMTMethodEntryC entry);
  174.   void somtEmitEpilog();
  175.   boolean somtScanBases(in string prolog, 
  176.                    in string each, 
  177.                    in string epilog);
  178.   boolean somtCheckVisibility(in SOMTMethodEntryC entry);
  179.   // Return 1 (true) if <entry> should be visible in the current
  180.   // target file.  This method is used by each of the following filter
  181.   // methods that are concerned with visibility.
  182.   // The default rule for visibility is:
  183.   //   only private methods are visible in private target files,
  184.   //   only public methods are visibile in public target files,
  185.   //   all methods are visibile in implementation or <somtAllE> target
  186.   //   files.
  187.  
  188.   boolean somtNew(in SOMTMethodEntryC entry);
  189.   // Returns 1 (true) if <entry> is a method introduced by the target
  190.   // class and its visibility matches <somtTargetType> (somtImplementationE
  191.   // matches both private and public)
  192.  
  193.   boolean somtImplemented(in SOMTMethodEntryC entry);
  194.   // Returns 1 (true) if <entry> is a method introduced or overridden
  195.   // by the target class and its visibility matches <somtTargetType>
  196.   // (somtImplementationE matches both private and public)
  197.  
  198.   boolean somtOverridden(in SOMTMethodEntryC entry);
  199.   // Returns 1 (true) if <entry> is an overridding method of the target class 
  200.   // and its visibility matches <somtTargetType> (somtImplementationE
  201.   // matches both private and public)
  202.  
  203.   boolean somtInherited(in SOMTMethodEntryC entry);
  204.   // Returns 1 (true) if <entry> is inherited 
  205.   // by the target class and its visibility matches <somtTargetType>
  206.   // (somtImplementationE matches both private and public)
  207.  
  208.   boolean somtAllVisible(in SOMTMethodEntryC entry);
  209.   // Returns 1 (true) if <entry> is supported by the target class and
  210.   // its visibility matches <somtTargetType> (somtImplementationE
  211.   // matches both private and public)
  212.  
  213.   boolean somtAll(in SOMTMethodEntryC entry);
  214.   // Returns 1 (true) if <entry> is supported by the target class.
  215.  
  216.   boolean somtNewNoProc(in SOMTEntryC entry);
  217.   // Returns 1 (true) if somtNew does and the method
  218.   // IS NOT a direct call Procedure.
  219.  
  220.   boolean somtPrivOrPub(in SOMTEntryC entry);
  221.   // Returns 1 (true) if entry is Private or Public.
  222.  
  223.   boolean somtNewProc(in SOMTEntryC entry);
  224.   // Returns 1 (true) if somtNew does and the method
  225.   // IS a direct call Procedure.
  226.  
  227.   boolean somtLink(in SOMTEntryC entry);
  228.   // Returns 1 (true) if "nolink" is not set.
  229.  
  230.   boolean somtVA(in SOMTEntryC entry);
  231.   // Returns 1 (true) if entry is a VarArgs method.
  232.  
  233.   boolean somtScanMethods(in string filter, 
  234.                      in string prolog, 
  235.                      in string each, 
  236.                      in string epilog, 
  237.                      in boolean forceProlog);
  238.  
  239.   // Will only call <each> on methods accepted by <filter>.
  240.   // If <forceProlog> is not true then the prolog and epilog emiters
  241.   // will be called only if there is at least one method that passes
  242.   // the filter.
  243.  
  244.   boolean somtScanConstants(in string prolog, 
  245.                   in string each, 
  246.                   in string epilog);
  247.  
  248.   boolean somtScanTypedefs(in string prolog, 
  249.                   in string each, 
  250.                   in string epilog);
  251.  
  252.   boolean somtScanStructs(in string prolog, 
  253.                   in string each, 
  254.                   in string epilog);
  255.  
  256.   boolean somtScanUnions(in string prolog, 
  257.                   in string each, 
  258.                   in string epilog);
  259.  
  260.   boolean somtScanEnums(in string prolog, 
  261.                   in string each, 
  262.                   in string epilog);
  263.  
  264.   boolean somtScanData(in string prolog, 
  265.                   in string each, 
  266.                   in string epilog);
  267.  
  268.   boolean somtScanAttributes(in string prolog, 
  269.                   in string each, 
  270.                   in string epilog);
  271.  
  272.   boolean somtScanInterfaces(in string prolog, 
  273.                   in string each, 
  274.                   in string epilog);
  275.  
  276.   boolean somtScanModules(in string prolog, 
  277.                   in string each, 
  278.                   in string epilog);
  279.  
  280.   boolean somtScanPassthru(in boolean before, 
  281.                       in string prolog, 
  282.                       in string each, 
  283.                       in string epilog);
  284.  
  285.   void somtEmitFullPassthru(in boolean before, in string language);
  286.  
  287.   // Emits each passthru section defined for the language and targetType,
  288.   // and the result of the somtIsBeforePassthru method is equal to the
  289.   // before parameter.  (before = 1(true), or before = 0(false), i.e. after.)
  290.  
  291.   boolean somtScanDataF(in string filter, 
  292.                    in string prolog, 
  293.                    in string each, 
  294.                    in string epilog, 
  295.                    in boolean forceProlog);
  296.  
  297.   // This method is like somtScanData but it also provides a paramater
  298.   // for a filter method.
  299.  
  300.   boolean somtScanBasesF(in string filter, 
  301.                     in string prolog, 
  302.                     in string each, 
  303.                     in string epilog, 
  304.                     in boolean forceProlog);
  305.  
  306.   // This method is like somtScanBases but it also provides a paramater
  307.   // for a filter method.
  308.  
  309.   string somtGetGlobalModifierValue(in string modifierName);
  310.   // Returns the value of the specified global modifier.
  311.   // Global modifiers are specified when the SOM Compiler is invoked,
  312.   // via the "-a" option.  For example, 
  313.   //                       sc -a"foo=bar"  file.idl
  314.   // specifies to the SOM Compiler and the emitters being run that
  315.   // the global modifier "foo" has the value "bar."
  316.   // Values of global modifiers are transient; they last only for the
  317.   // duration of the compile for which they were specified.
  318.   // If a modifier is specified in the "sc" command with no value,
  319.   // as in 
  320.   //                       sc -afoo file.idl
  321.   // then the result of this method will be non-NULL.
  322.   // If no such modifier is specified, then the result is NULL.
  323.  
  324.   SOMTEntryC somtGetFirstGlobalDefinition();
  325.   // Returns the first type or constant definition that is not
  326.   // associated with any interface or module.
  327.   // These global definitions must be surrounded by the somemittypes
  328.   // pragmas for them to be visible via this method.
  329.   // E.g., #pragma somemittypes on
  330.   //       ....
  331.   //       #pragma someemittypes off
  332.   // The list of global definitions returned by this method and
  333.   // the somtGetNextGlobalDefinition method may include entries
  334.   // for forward declarations as well as typedefs and constants.
  335.   // Global structs and unions are also included in the list.
  336.  
  337.   SOMTEntryC somtGetNextGlobalDefinition();
  338.   // Returns the next type or constant definition that is not
  339.   // associated with any interface or module, relative to a
  340.   // previous call to somtGetFirstGlobalDefinition or
  341.   // somtGetNextGlobalDefinition.
  342.  
  343. #ifdef __SOMIDL__
  344.   implementation {
  345.  
  346.     releaseorder: _get_somtTemplate, _get_somtTargetFile, 
  347.                   _set_somtTargetFile, _get_somtTargetClass, 
  348.                   _set_somtTargetClass, _get_somtTargetModule, 
  349.                   _set_somtTargetModule, _get_somtTargetType, 
  350.                   _set_somtTargetType, somtGenerateSections, 
  351.                   somtOpenSymbolsFile, somtSetPredefinedSymbols, 
  352.                   somtFileSymbols, somtEmitProlog, 
  353.                   somtEmitBaseIncludesProlog, somtEmitBaseIncludes, 
  354.                   somtEmitBaseIncludesEpilog, somtEmitMetaInclude, 
  355.                   somtEmitClass, somtEmitMeta, 
  356.                   somtEmitBaseProlog, somtEmitBase, 
  357.                   somtEmitBaseEpilog, somtEmitPassthruProlog, 
  358.                   somtEmitPassthru, somtEmitPassthruEpilog, 
  359.                   somtEmitRelease, somtEmitDataProlog, 
  360.                   somtEmitData, somtEmitDataEpilog, 
  361.                   somtEmitMethodsProlog, somtEmitMethods, 
  362.                   somtEmitMethodsEpilog, somtEmitMethod, 
  363.                   somtEmitEpilog, somtScanBases, somtScanConstants,
  364.                   somtCheckVisibility, somtNew, 
  365.                   somtImplemented, somtOverridden, 
  366.                   somtInherited, somtAllVisible, 
  367.                   somtAll, somtNewNoProc, 
  368.                   somtPrivOrPub, somtNewProc, 
  369.                   somtLink, somtVA, 
  370.                   somtScanMethods, somtScanData, 
  371.                   somtScanPassthru, somtEmitFullPassthru, 
  372.                   somtScanDataF, somtScanBasesF, 
  373.                   _set_somtTemplate, _set_somtEmitterName, 
  374.                   _get_somtEmitterName, somtEmitAttributeProlog, 
  375.                   somtEmitAttribute, somtEmitAttributeEpilog, 
  376.                   somtEmitConstantProlog, somtEmitConstant, 
  377.                   somtEmitConstantEpilog, somtEmitTypedefProlog, 
  378.                   somtEmitTypedef, somtEmitTypedefEpilog, 
  379.                   somtEmitStructProlog, somtEmitStruct, 
  380.                   somtEmitStructEpilog, somtEmitUnionProlog, 
  381.                   somtEmitUnion, somtEmitUnionEpilog, 
  382.                   somtEmitEnumProlog, somtEmitEnum, 
  383.                   somtEmitEnumEpilog, somtEmitInterfaceProlog, 
  384.                   somtEmitInterface, somtEmitInterfaceEpilog, 
  385.                   somtEmitModuleProlog, somtEmitModule, 
  386.                   somtEmitModuleEpilog, somtScanAttributes, 
  387.                   somtScanTypedefs, somtScanStructs, 
  388.                   somtScanUnions, somtScanEnums, 
  389.                   somtScanInterfaces, somtScanModules, 
  390.                   somtGetGlobalModifierValue,
  391.           somtGetFirstGlobalDefinition, somtGetNextGlobalDefinition;
  392.  
  393.     majorversion = 2;
  394.     minorversion = 1;
  395.     filestem = scemit;
  396.     callstyle = oidl; 
  397.  
  398.     passthru C_h_after = "#include <sctypes.h>"
  399.   "#include <sctmplt.h>"
  400.   "#include <scclass.h>"
  401.   "#include <scmeta.h>"
  402.   "#include <scmethod.h>"
  403.   "#include <scpass.h>"
  404.   "    /*"
  405.   "     * These macros provide short-hands for the use of the Scan"
  406.   "     * Methods."
  407.   "     */"
  408.   ""
  409.   "    #define SCAN_NOFILTER(scan,method) \"
  410.   "        _##scan(somSelf, #method\"Prolog\", #method, #method\"Epilog\")"
  411.   "    #define SCAN_NOFILTER_SN(scan,method,base,newbase) \"
  412.   "        {_somtSetSymbolCopyBoth(_t, #base\"PrologSN\", #newbase\"PrologS\"); \"
  413.   "        _somtSetSymbolCopyBoth(_t, #base\"SN\", #newbase\"S\"); \"
  414.   "        _somtSetSymbolCopyBoth(_t, #base\"EpilogSN\", #newbase\"EpilogS\"); \"
  415.   "        _##scan(somSelf, #method\"Prolog\", #method, #method\"Epilog\");}"
  416.   "    #define SCAN_FILTER(scan,filt,method) \"
  417.   "        _##scan(somSelf, #filt, #method\"Prolog\", #method, #method\"Epilog\",0)"
  418.   "    #define SCAN_FILTER_SN(scan,filt,method,base,newbase) \"
  419.   "        {_somtSetSymbolCopyBoth(_t, #base\"PrologSN\", #newbase\"PrologS\"); \"
  420.   "        _somtSetSymbolCopyBoth(_t, #base\"SN\", #newbase\"S\"); \"
  421.   "        _somtSetSymbolCopyBoth(_t, #base\"EpilogSN\", #newbase\"EpilogS\"); \"
  422.   "        _##scan(somSelf, #filt, #method\"Prolog\", #method, #method\"Epilog\",0);}";
  423.     passthru C_xh_after = "#include <sctypes.h>"
  424.   "#include <sctmplt.xh>"
  425.   "#include <scclass.xh>"
  426.   "#include <scmeta.xh>"
  427.   "#include <scmethod.xh>"
  428.   "#include <scpass.xh>"
  429.   "    /*"
  430.   "     * These macros provide short-hands for the use of the Scan"
  431.   "     * Methods."
  432.   "     */"
  433.   ""
  434.   "    #define SCAN_NOFILTER(scan,method) \"
  435.   "        _##scan(somSelf, #method\"Prolog\", #method, #method\"Epilog\")"
  436.   "    #define SCAN_NOFILTER_SN(scan,method,base,newbase) \"
  437.   "        {_somtSetSymbolCopyBoth(_t, #base\"PrologSN\", #newbase\"PrologS\"); \"
  438.   "        _somtSetSymbolCopyBoth(_t, #base\"SN\", #newbase\"S\"); \"
  439.   "        _somtSetSymbolCopyBoth(_t, #base\"EpilogSN\", #newbase\"EpilogS\"); \"
  440.   "        _##scan(somSelf, #method\"Prolog\", #method, #method\"Epilog\");}"
  441.   "    #define SCAN_FILTER(scan,filt,method) \"
  442.   "        _##scan(somSelf, #filt, #method\"Prolog\", #method, #method\"Epilog\",0)"
  443.   "    #define SCAN_FILTER_SN(scan,filt,method,base,newbase) \"
  444.   "        {_somtSetSymbolCopyBoth(_t, #base\"PrologSN\", #newbase\"PrologS\"); \"
  445.   "        _somtSetSymbolCopyBoth(_t, #base\"SN\", #newbase\"S\"); \"
  446.   "        _somtSetSymbolCopyBoth(_t, #base\"EpilogSN\", #newbase\"EpilogS\"); \"
  447.   "        _##scan(somSelf, #filt, #method\"Prolog\", #method, #method\"Epilog\",0);}";
  448.  
  449.     passthru C_hh_after = "#include <sctypes.h>"
  450.   "#include <sctmplt.hh>"
  451.   "#include <scclass.hh>"
  452.   "#include <scmeta.hh>"
  453.   "#include <scmethod.hh>"
  454.   "#include <scpass.hh>"
  455.   "    /*"
  456.   "     * These macros provide short-hands for the use of the Scan"
  457.   "     * Methods."
  458.   "     */"
  459.   ""
  460.   "    #define SCAN_NOFILTER(scan,method) \"
  461.   "        _##scan(somSelf, #method\"Prolog\", #method, #method\"Epilog\")"
  462.   "    #define SCAN_NOFILTER_SN(scan,method,base,newbase) \"
  463.   "        {_somtSetSymbolCopyBoth(_t, #base\"PrologSN\", #newbase\"PrologS\"); \"
  464.   "        _somtSetSymbolCopyBoth(_t, #base\"SN\", #newbase\"S\"); \"
  465.   "        _somtSetSymbolCopyBoth(_t, #base\"EpilogSN\", #newbase\"EpilogS\"); \"
  466.   "        _##scan(somSelf, #method\"Prolog\", #method, #method\"Epilog\");}"
  467.   "    #define SCAN_FILTER(scan,filt,method) \"
  468.   "        _##scan(somSelf, #filt, #method\"Prolog\", #method, #method\"Epilog\",0)"
  469.   "    #define SCAN_FILTER_SN(scan,filt,method,base,newbase) \"
  470.   "        {_somtSetSymbolCopyBoth(_t, #base\"PrologSN\", #newbase\"PrologS\"); \"
  471.   "        _somtSetSymbolCopyBoth(_t, #base\"SN\", #newbase\"S\"); \"
  472.   "        _somtSetSymbolCopyBoth(_t, #base\"EpilogSN\", #newbase\"EpilogS\"); \"
  473.   "        _##scan(somSelf, #filt, #method\"Prolog\", #method, #method\"Epilog\",0);}";
  474.  
  475.     somInit: override;
  476.     somUninit: override;
  477.     somDumpSelfInt: override;
  478.  
  479.     somtTargetFile: noset;
  480.  
  481.   };
  482. #endif /* __SOMIDL__ */
  483. };
  484.  
  485. #endif  /* scemit_idl */
  486.