rev 7560 : 8066814: Reduce accessibility in TraceEvent
Reviewed-by:

   1 <?xml version="1.0" encoding="utf-8"?>
   2 <!--
   3  Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
   4  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5 
   6  This code is free software; you can redistribute it and/or modify it
   7  under the terms of the GNU General Public License version 2 only, as
   8  published by the Free Software Foundation.
   9 
  10  This code is distributed in the hope that it will be useful, but WITHOUT
  11  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  version 2 for more details (a copy is included in the LICENSE file that
  14  accompanied this code).
  15 
  16  You should have received a copy of the GNU General Public License version
  17  2 along with this work; if not, write to the Free Software Foundation,
  18  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19 
  20  Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  or visit www.oracle.com if you need additional information or have any
  22  questions.
  23 -->
  24 
  25 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  26 <xsl:import href="xsl_util.xsl"/>
  27 <xsl:output method="text" indent="no" omit-xml-declaration="yes"/>
  28 
  29 <xsl:template match="/">
  30   <xsl:call-template name="file-header"/>
  31 
  32 #ifndef TRACEFILES_TRACEEVENTCLASSES_HPP
  33 #define TRACEFILES_TRACEEVENTCLASSES_HPP
  34 
  35 // On purpose outside the INCLUDE_TRACE
  36 // Some parts of traceEvent.hpp are used outside of
  37 // INCLUDE_TRACE
  38 
  39 #include "memory/resourceArea.hpp"
  40 #include "tracefiles/traceTypes.hpp"
  41 #include "trace/traceEvent.hpp"
  42 #include "utilities/macros.hpp"
  43 #include "utilities/ticks.hpp"
  44 #if INCLUDE_TRACE
  45 #include "trace/traceStream.hpp"
  46 #include "utilities/ostream.hpp"
  47 
  48   <xsl:apply-templates select="trace/events/struct" mode="trace"/>
  49   <xsl:apply-templates select="trace/events/event" mode="trace"/>
  50 
  51 #else // !INCLUDE_TRACE
  52 
  53 class TraceEvent {
  54 public:
  55   TraceEvent() {}
  56   void set_starttime(const Ticks&amp; ignore) {}
  57   void set_endtime(const Ticks&amp; ignore) {}
  58   bool should_commit() const { return false; }
  59   static bool is_enabled() { return false; }
  60   void commit() {}
  61   void cancel() {}
  62 };
  63 
  64   <xsl:apply-templates select="trace/events/struct" mode="empty"/>
  65   <xsl:apply-templates select="trace/events/event" mode="empty"/>
  66 
  67 #endif // INCLUDE_TRACE
  68 #endif // TRACEFILES_TRACEEVENTCLASSES_HPP
  69 </xsl:template>
  70 
  71 <xsl:template match="struct" mode="trace">
  72 struct TraceStruct<xsl:value-of select="@id"/>
  73 {
  74 private:
  75 <xsl:apply-templates select="value" mode="write-fields"/>
  76 public:
  77 <xsl:apply-templates select="value" mode="write-setters"/>
  78 
  79   void writeStruct(TraceStream&amp; ts) {
  80 <xsl:apply-templates select="value" mode="write-data"/>
  81   }
  82 };
  83 
  84 </xsl:template>
  85 
  86 <xsl:template match="struct" mode="empty">
  87 struct TraceStruct<xsl:value-of select="@id"/> 
  88 {
  89 public:
  90 <xsl:apply-templates select="value" mode="write-empty-setters"/>
  91 };
  92 </xsl:template>
  93 
  94 
  95 <xsl:template match="event" mode="empty">
  96   <xsl:value-of select="concat('class Event', @id, ' : public TraceEvent')"/>
  97 {
  98  public:
  99 <xsl:value-of select="concat('  Event', @id, '(bool ignore=true) {}')"/>
 100 <xsl:text>
 101 </xsl:text>
 102 
 103 <xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-empty-setters"/>
 104 };
 105 
 106 </xsl:template>
 107 
 108 
 109 <xsl:template match="event" mode="trace">
 110   <xsl:value-of select="concat('class Event', @id, ' : public TraceEvent&lt;Event', @id, '&gt;')"/>
 111 {
 112  public:
 113   static const bool hasThread = <xsl:value-of select="@has_thread"/>;
 114   static const bool hasStackTrace = <xsl:value-of select="@has_stacktrace"/>;
 115   static const bool isInstant = <xsl:value-of select="@is_instant"/>;
 116   static const bool isRequestable = <xsl:value-of select="@is_requestable"/>;
 117   static const TraceEventId eventId = <xsl:value-of select="concat('Trace', @id, 'Event')"/>;
 118 
 119  private:
 120 <xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-fields"/>
 121 
 122   void writeEventContent(void) {
 123     TraceStream ts(*tty);
 124     ts.print("<xsl:value-of select="@label"/>: [");
 125 <xsl:apply-templates select="value|structvalue" mode="write-data"/>
 126     ts.print("]\n");
 127   }
 128 
 129  public:
 130 <xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-setters"/>
 131 
 132   bool should_write(void) {
 133     return true;
 134   }
 135 <xsl:text>
 136 
 137 </xsl:text>
 138   <xsl:value-of select="concat('  Event', @id, '(EventStartTime timing=TIMED) : TraceEvent&lt;Event', @id, '&gt;(timing) {}', $newline)"/>
 139   void writeEvent(void) {
 140     ResourceMark rm;
 141     if (UseLockedTracing) {
 142       ttyLocker lock;
 143       writeEventContent();
 144     } else {
 145       writeEventContent();
 146     }
 147   }
 148 };
 149 
 150 </xsl:template>
 151 
 152 <xsl:template match="value|transition_value|relation" mode="write-empty-setters">
 153   <xsl:param name="cls"/>
 154   <xsl:variable name="type" select="@type"/>
 155   <xsl:variable name="wt" select="//primary_type[@symbol=$type]/@type"/>
 156   <xsl:value-of select="concat('  void set_', @field, '(', $wt, ' value) { }')"/>
 157   <xsl:if test="position() != last()">
 158     <xsl:text>
 159 </xsl:text>
 160   </xsl:if>
 161 </xsl:template>
 162 
 163 <xsl:template match="structvalue" mode="write-empty-setters">
 164   <xsl:param name="cls"/>
 165   <xsl:value-of select="concat('  void set_', @field, '(const TraceStruct', @type, '&amp; value) { }')"/>
 166   <xsl:if test="position() != last()">
 167     <xsl:text>
 168 </xsl:text>
 169   </xsl:if>
 170 </xsl:template>
 171 
 172 <xsl:template match="value[@type='TICKS']" mode="write-setters">
 173 #if INCLUDE_TRACE
 174 <xsl:value-of select="concat('  void set_', @field, '(const Ticks&amp; time) { _', @field, ' = time; }')"/>
 175 #else
 176 <xsl:value-of select="concat('  void set_', @field, '(const Ticks&amp; ignore) {}')"/>
 177 #endif
 178 </xsl:template>
 179 
 180 <xsl:template match="value[@type='TICKSPAN']" mode="write-setters">
 181 #if INCLUDE_TRACE
 182   <xsl:value-of select="concat('  void set_', @field, '(const Tickspan&amp; time) { _', @field, ' = time; }')"/>
 183 #else
 184   <xsl:value-of select="concat('  void set_', @field, '(const Tickspan&amp; ignore) {}')"/>
 185 #endif
 186 </xsl:template>
 187 
 188 
 189 <xsl:template match="value" mode="write-fields">
 190   <xsl:variable name="type" select="@type"/>
 191   <xsl:variable name="wt" select="//primary_type[@symbol=$type]/@type"/>
 192   <xsl:value-of select="concat('  ', $wt, ' _', @field, ';')"/>
 193   <xsl:if test="position() != last()">
 194     <xsl:text> 
 195 </xsl:text>
 196   </xsl:if>
 197 </xsl:template>
 198 
 199 <xsl:template match="structvalue" mode="write-fields">
 200   <xsl:value-of select="concat('  TraceStruct', @type, ' _', @field, ';')"/>
 201   <xsl:text>
 202 </xsl:text>
 203 </xsl:template>
 204 
 205 <xsl:template match="value|transition_value|relation" mode="write-setters">
 206   <xsl:param name="cls"/>
 207   <xsl:variable name="type" select="@type"/>
 208   <xsl:variable name="wt" select="//primary_type[@symbol=$type]/@type"/>
 209   <xsl:value-of select="concat('  void set_', @field, '(', $wt, ' value) { this->_', @field, ' = value; }')"/>
 210   <xsl:if test="position() != last()">
 211     <xsl:text>
 212 </xsl:text>
 213   </xsl:if>
 214 </xsl:template>
 215 
 216 <xsl:template match="structvalue" mode="write-setters">
 217   <xsl:param name="cls"/>
 218   <xsl:value-of select="concat('  void set_', @field, '(const TraceStruct', @type, '&amp; value) { this->_', @field, ' = value; }')"/>
 219   <xsl:if test="position() != last()">
 220     <xsl:text>
 221 </xsl:text>
 222   </xsl:if>
 223 </xsl:template>
 224 
 225 <xsl:template match="value" mode="write-data">
 226   <xsl:variable name="type" select="@type"/>
 227   <xsl:variable name="wt" select="//primary_type[@symbol=$type]/@writetype"/>
 228   <xsl:choose>
 229     <xsl:when test="@type='TICKSPAN'">
 230       <xsl:value-of select="concat('    ts.print_val(&quot;', @label, '&quot;, _', @field, '.value());')"/>
 231     </xsl:when>
 232     <xsl:when test="@type='TICKS'">
 233       <xsl:value-of select="concat('    ts.print_val(&quot;', @label, '&quot;, _', @field, '.value());')"/>
 234     </xsl:when>
 235     <xsl:otherwise>
 236       <xsl:value-of select="concat('    ts.print_val(&quot;', @label, '&quot;, _', @field, ');')"/>
 237     </xsl:otherwise>
 238   </xsl:choose>
 239   <xsl:if test="position() != last()">
 240     <xsl:text>
 241     ts.print(", ");
 242 </xsl:text>
 243   </xsl:if>
 244 </xsl:template>
 245 
 246 <xsl:template match="structvalue" mode="write-data">
 247   <xsl:value-of select="concat('    _', @field, '.writeStruct(ts);')"/>
 248   <xsl:if test="position() != last()">
 249     <xsl:text>
 250     ts.print(", ");
 251 </xsl:text>
 252   </xsl:if>
 253 </xsl:template>
 254 
 255 </xsl:stylesheet>
--- EOF ---