| 1 |
// ------------------------------------------------------------------------------ |
| 2 |
// <auto-generated> |
| 3 |
// This code was generated by a tool. |
| 4 |
// Runtime Version: 17.0.0.0 |
| 5 |
// |
| 6 |
// Changes to this file may cause incorrect behavior and will be lost if |
| 7 |
// the code is regenerated. |
| 8 |
// </auto-generated> |
| 9 |
// ------------------------------------------------------------------------------ |
| 10 |
namespace amqplib_generator |
| 11 |
{ |
| 12 |
using System.Linq; |
| 13 |
using System.Text; |
| 14 |
using System.Collections.Generic; |
| 15 |
using amqplib_generator; |
| 16 |
using System; |
| 17 |
|
| 18 |
/// <summary> |
| 19 |
/// Class to produce the template output |
| 20 |
/// </summary> |
| 21 |
|
| 22 |
#line 1 "C:\code\s1\azure-uamqp-c\uamqp_generator\amqp_definitions_h.tt" |
| 23 |
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] |
| 24 |
public partial class amqp_definitions_h : amqp_definitions_hBase |
| 25 |
{ |
| 26 |
#line hidden |
| 27 |
/// <summary> |
| 28 |
/// Create the template output |
| 29 |
/// </summary> |
| 30 |
public virtual string TransformText() |
| 31 |
{ |
| 32 |
this.Write("\r\n"); |
| 33 |
|
| 34 |
#line 8 "C:\code\s1\azure-uamqp-c\uamqp_generator\amqp_definitions_h.tt" |
| 35 |
amqp amqp = Program.LoadAMQPTypes(); |
| 36 |
|
| 37 |
#line default |
| 38 |
#line hidden |
| 39 |
this.Write(@" |
| 40 |
// Copyright (c) Microsoft. All rights reserved. |
| 41 |
// Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 42 |
|
| 43 |
// This file is generated. DO NOT EDIT it manually. |
| 44 |
// The generator that produces it is located at /uamqp_generator/uamqp_generator.sln |
| 45 |
|
| 46 |
#ifndef AMQP_DEFINITIONS_H |
| 47 |
#define AMQP_DEFINITIONS_H |
| 48 |
|
| 49 |
#ifdef __cplusplus |
| 50 |
#include <cstdint> |
| 51 |
extern ""C"" { |
| 52 |
#else |
| 53 |
#include <stdint.h> |
| 54 |
#include <stdbool.h> |
| 55 |
#endif |
| 56 |
|
| 57 |
#include ""azure_uamqp_c/amqpvalue.h"" |
| 58 |
#include ""umock_c/umock_c_prod.h"" |
| 59 |
|
| 60 |
"); |
| 61 |
|
| 62 |
#line 30 "C:\code\s1\azure-uamqp-c\uamqp_generator\amqp_definitions_h.tt" |
| 63 |
foreach (section section in amqp.Items.Where(item => item is section)) |
| 64 |
|
| 65 |
#line default |
| 66 |
#line hidden |
| 67 |
|
| 68 |
#line 31 "C:\code\s1\azure-uamqp-c\uamqp_generator\amqp_definitions_h.tt" |
| 69 |
{ |
| 70 |
|
| 71 |
#line default |
| 72 |
#line hidden |
| 73 |
|
| 74 |
#line 32 "C:\code\s1\azure-uamqp-c\uamqp_generator\amqp_definitions_h.tt" |
| 75 |
List<type> types = new List<type>(); |
| 76 |
|
| 77 |
#line default |
| 78 |
#line hidden |
| 79 |
|
| 80 |
#line 33 "C:\code\s1\azure-uamqp-c\uamqp_generator\amqp_definitions_h.tt" |
| 81 |
types.AddRange(section.Items.Where(item => item is type).Cast<type>()); |
| 82 |
|
| 83 |
#line default |
| 84 |
#line hidden |
| 85 |
|
| 86 |
#line 34 "C:\code\s1\azure-uamqp-c\uamqp_generator\amqp_definitions_h.tt" |
| 87 |
foreach (type type in types) |
| 88 |
|
| 89 |
#line default |
| 90 |
#line hidden |
| 91 |
|
| 92 |
#line 35 "C:\code\s1\azure-uamqp-c\uamqp_generator\amqp_definitions_h.tt" |
| 93 |
{ |
| 94 |
|
| 95 |
#line default |
| 96 |
#line hidden |
| 97 |
|
| 98 |
#line 36 "C:\code\s1\azure-uamqp-c\uamqp_generator\amqp_definitions_h.tt" |
| 99 |
string type_name = type.name.ToLower().Replace('-', '_'); |
| 100 |
|
| 101 |
#line default |
| 102 |
#line hidden |
| 103 |
this.Write("#include \""); |
| 104 |
|
| 105 |
#line 37 "C:\code\s1\azure-uamqp-c\uamqp_generator\amqp_definitions_h.tt" |
| 106 |
this.Write(this.ToStringHelper.ToStringWithCulture($"azure_uamqp_c/amqp_definitions_{type_name}.h")); |
| 107 |
|
| 108 |
#line default |
| 109 |
#line hidden |
| 110 |
this.Write("\"\r\n"); |
| 111 |
|
| 112 |
#line 38 "C:\code\s1\azure-uamqp-c\uamqp_generator\amqp_definitions_h.tt" |
| 113 |
} |
| 114 |
|
| 115 |
#line default |
| 116 |
#line hidden |
| 117 |
|
| 118 |
#line 39 "C:\code\s1\azure-uamqp-c\uamqp_generator\amqp_definitions_h.tt" |
| 119 |
} |
| 120 |
|
| 121 |
#line default |
| 122 |
#line hidden |
| 123 |
this.Write("\r\n#ifdef __cplusplus\r\n}\r\n#endif\r\n\r\n#endif /* AMQP_DEFINITIONS_H */\r\n"); |
| 124 |
return this.GenerationEnvironment.ToString(); |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
#line default |
| 129 |
#line hidden |
| 130 |
#region Base class |
| 131 |
/// <summary> |
| 132 |
/// Base class for this transformation |
| 133 |
/// </summary> |
| 134 |
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] |
| 135 |
public class amqp_definitions_hBase |
| 136 |
{ |
| 137 |
#region Fields |
| 138 |
private global::System.Text.StringBuilder generationEnvironmentField; |
| 139 |
private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField; |
| 140 |
private global::System.Collections.Generic.List<int> indentLengthsField; |
| 141 |
private string currentIndentField = ""; |
| 142 |
private bool endsWithNewline; |
| 143 |
private global::System.Collections.Generic.IDictionary<string, object> sessionField; |
| 144 |
#endregion |
| 145 |
#region Properties |
| 146 |
/// <summary> |
| 147 |
/// The string builder that generation-time code is using to assemble generated output |
| 148 |
/// </summary> |
| 149 |
public System.Text.StringBuilder GenerationEnvironment |
| 150 |
{ |
| 151 |
get |
| 152 |
{ |
| 153 |
if ((this.generationEnvironmentField == null)) |
| 154 |
{ |
| 155 |
this.generationEnvironmentField = new global::System.Text.StringBuilder(); |
| 156 |
} |
| 157 |
return this.generationEnvironmentField; |
| 158 |
} |
| 159 |
set |
| 160 |
{ |
| 161 |
this.generationEnvironmentField = value; |
| 162 |
} |
| 163 |
} |
| 164 |
/// <summary> |
| 165 |
/// The error collection for the generation process |
| 166 |
/// </summary> |
| 167 |
public System.CodeDom.Compiler.CompilerErrorCollection Errors |
| 168 |
{ |
| 169 |
get |
| 170 |
{ |
| 171 |
if ((this.errorsField == null)) |
| 172 |
{ |
| 173 |
this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection(); |
| 174 |
} |
| 175 |
return this.errorsField; |
| 176 |
} |
| 177 |
} |
| 178 |
/// <summary> |
| 179 |
/// A list of the lengths of each indent that was added with PushIndent |
| 180 |
/// </summary> |
| 181 |
private System.Collections.Generic.List<int> indentLengths |
| 182 |
{ |
| 183 |
get |
| 184 |
{ |
| 185 |
if ((this.indentLengthsField == null)) |
| 186 |
{ |
| 187 |
this.indentLengthsField = new global::System.Collections.Generic.List<int>(); |
| 188 |
} |
| 189 |
return this.indentLengthsField; |
| 190 |
} |
| 191 |
} |
| 192 |
/// <summary> |
| 193 |
/// Gets the current indent we use when adding lines to the output |
| 194 |
/// </summary> |
| 195 |
public string CurrentIndent |
| 196 |
{ |
| 197 |
get |
| 198 |
{ |
| 199 |
return this.currentIndentField; |
| 200 |
} |
| 201 |
} |
| 202 |
/// <summary> |
| 203 |
/// Current transformation session |
| 204 |
/// </summary> |
| 205 |
public virtual global::System.Collections.Generic.IDictionary<string, object> Session |
| 206 |
{ |
| 207 |
get |
| 208 |
{ |
| 209 |
return this.sessionField; |
| 210 |
} |
| 211 |
set |
| 212 |
{ |
| 213 |
this.sessionField = value; |
| 214 |
} |
| 215 |
} |
| 216 |
#endregion |
| 217 |
#region Transform-time helpers |
| 218 |
/// <summary> |
| 219 |
/// Write text directly into the generated output |
| 220 |
/// </summary> |
| 221 |
public void Write(string textToAppend) |
| 222 |
{ |
| 223 |
if (string.IsNullOrEmpty(textToAppend)) |
| 224 |
{ |
| 225 |
return; |
| 226 |
} |
| 227 |
// If we're starting off, or if the previous text ended with a newline, |
| 228 |
// we have to append the current indent first. |
| 229 |
if (((this.GenerationEnvironment.Length == 0) |
| 230 |
|| this.endsWithNewline)) |
| 231 |
{ |
| 232 |
this.GenerationEnvironment.Append(this.currentIndentField); |
| 233 |
this.endsWithNewline = false; |
| 234 |
} |
| 235 |
// Check if the current text ends with a newline |
| 236 |
if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture)) |
| 237 |
{ |
| 238 |
this.endsWithNewline = true; |
| 239 |
} |
| 240 |
// This is an optimization. If the current indent is "", then we don't have to do any |
| 241 |
// of the more complex stuff further down. |
| 242 |
if ((this.currentIndentField.Length == 0)) |
| 243 |
{ |
| 244 |
this.GenerationEnvironment.Append(textToAppend); |
| 245 |
return; |
| 246 |
} |
| 247 |
// Everywhere there is a newline in the text, add an indent after it |
| 248 |
textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField)); |
| 249 |
// If the text ends with a newline, then we should strip off the indent added at the very end |
| 250 |
// because the appropriate indent will be added when the next time Write() is called |
| 251 |
if (this.endsWithNewline) |
| 252 |
{ |
| 253 |
this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length)); |
| 254 |
} |
| 255 |
else |
| 256 |
{ |
| 257 |
this.GenerationEnvironment.Append(textToAppend); |
| 258 |
} |
| 259 |
} |
| 260 |
/// <summary> |
| 261 |
/// Write text directly into the generated output |
| 262 |
/// </summary> |
| 263 |
public void WriteLine(string textToAppend) |
| 264 |
{ |
| 265 |
this.Write(textToAppend); |
| 266 |
this.GenerationEnvironment.AppendLine(); |
| 267 |
this.endsWithNewline = true; |
| 268 |
} |
| 269 |
/// <summary> |
| 270 |
/// Write formatted text directly into the generated output |
| 271 |
/// </summary> |
| 272 |
public void Write(string format, params object[] args) |
| 273 |
{ |
| 274 |
this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); |
| 275 |
} |
| 276 |
/// <summary> |
| 277 |
/// Write formatted text directly into the generated output |
| 278 |
/// </summary> |
| 279 |
public void WriteLine(string format, params object[] args) |
| 280 |
{ |
| 281 |
this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); |
| 282 |
} |
| 283 |
/// <summary> |
| 284 |
/// Raise an error |
| 285 |
/// </summary> |
| 286 |
public void Error(string message) |
| 287 |
{ |
| 288 |
System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); |
| 289 |
error.ErrorText = message; |
| 290 |
this.Errors.Add(error); |
| 291 |
} |
| 292 |
/// <summary> |
| 293 |
/// Raise a warning |
| 294 |
/// </summary> |
| 295 |
public void Warning(string message) |
| 296 |
{ |
| 297 |
System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); |
| 298 |
error.ErrorText = message; |
| 299 |
error.IsWarning = true; |
| 300 |
this.Errors.Add(error); |
| 301 |
} |
| 302 |
/// <summary> |
| 303 |
/// Increase the indent |
| 304 |
/// </summary> |
| 305 |
public void PushIndent(string indent) |
| 306 |
{ |
| 307 |
if ((indent == null)) |
| 308 |
{ |
| 309 |
throw new global::System.ArgumentNullException("indent"); |
| 310 |
} |
| 311 |
this.currentIndentField = (this.currentIndentField + indent); |
| 312 |
this.indentLengths.Add(indent.Length); |
| 313 |
} |
| 314 |
/// <summary> |
| 315 |
/// Remove the last indent that was added with PushIndent |
| 316 |
/// </summary> |
| 317 |
public string PopIndent() |
| 318 |
{ |
| 319 |
string returnValue = ""; |
| 320 |
if ((this.indentLengths.Count > 0)) |
| 321 |
{ |
| 322 |
int indentLength = this.indentLengths[(this.indentLengths.Count - 1)]; |
| 323 |
this.indentLengths.RemoveAt((this.indentLengths.Count - 1)); |
| 324 |
if ((indentLength > 0)) |
| 325 |
{ |
| 326 |
returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength)); |
| 327 |
this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength)); |
| 328 |
} |
| 329 |
} |
| 330 |
return returnValue; |
| 331 |
} |
| 332 |
/// <summary> |
| 333 |
/// Remove any indentation |
| 334 |
/// </summary> |
| 335 |
public void ClearIndent() |
| 336 |
{ |
| 337 |
this.indentLengths.Clear(); |
| 338 |
this.currentIndentField = ""; |
| 339 |
} |
| 340 |
#endregion |
| 341 |
#region ToString Helpers |
| 342 |
/// <summary> |
| 343 |
/// Utility class to produce culture-oriented representation of an object as a string. |
| 344 |
/// </summary> |
| 345 |
public class ToStringInstanceHelper |
| 346 |
{ |
| 347 |
private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture; |
| 348 |
/// <summary> |
| 349 |
/// Gets or sets format provider to be used by ToStringWithCulture method. |
| 350 |
/// </summary> |
| 351 |
public System.IFormatProvider FormatProvider |
| 352 |
{ |
| 353 |
get |
| 354 |
{ |
| 355 |
return this.formatProviderField ; |
| 356 |
} |
| 357 |
set |
| 358 |
{ |
| 359 |
if ((value != null)) |
| 360 |
{ |
| 361 |
this.formatProviderField = value; |
| 362 |
} |
| 363 |
} |
| 364 |
} |
| 365 |
/// <summary> |
| 366 |
/// This is called from the compile/run appdomain to convert objects within an expression block to a string |
| 367 |
/// </summary> |
| 368 |
public string ToStringWithCulture(object objectToConvert) |
| 369 |
{ |
| 370 |
if ((objectToConvert == null)) |
| 371 |
{ |
| 372 |
throw new global::System.ArgumentNullException("objectToConvert"); |
| 373 |
} |
| 374 |
System.Type t = objectToConvert.GetType(); |
| 375 |
System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] { |
| 376 |
typeof(System.IFormatProvider)}); |
| 377 |
if ((method == null)) |
| 378 |
{ |
| 379 |
return objectToConvert.ToString(); |
| 380 |
} |
| 381 |
else |
| 382 |
{ |
| 383 |
return ((string)(method.Invoke(objectToConvert, new object[] { |
| 384 |
this.formatProviderField }))); |
| 385 |
} |
| 386 |
} |
| 387 |
} |
| 388 |
private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper(); |
| 389 |
/// <summary> |
| 390 |
/// Helper to produce culture-oriented representation of an object as a string |
| 391 |
/// </summary> |
| 392 |
public ToStringInstanceHelper ToStringHelper |
| 393 |
{ |
| 394 |
get |
| 395 |
{ |
| 396 |
return this.toStringHelperField; |
| 397 |
} |
| 398 |
} |
| 399 |
#endregion |
| 400 |
} |
| 401 |
#endregion |
| 402 |
} |