home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / som30tk.zip / som30os2.zip / include / scemit.idl < prev    next >
Text File  |  1996-12-24  |  19KB  |  470 lines

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