public void AddDocument(Document document) { // Check each of the protocols: foreach (Protocol protocol in document.Protocols) { if (_namespaces.ContainsKey(protocol.Name)) { throw new SemanticException("The protocol name \"{0}\" has been used more than once."); } CheckProtocolVersions(protocol); CheckNames(protocol); CheckStructures(protocol); } // Add each protocol and declaration to the symbol tables: foreach (Protocol protocol in document.Protocols) { _namespaces.Add(protocol.Name, protocol); foreach (Declaration declaration in protocol.Declarations) { _declarations.Add(protocol.GetFullNameOfDeclaration(declaration), declaration); } } _documents.Add(document); }
protected Generator(Language language, Document document, string documentPath, string destinationPath, DateTime mostRecentSourceFile) { _language = language; _document = document; _documentPath = documentPath; _destinationPath = destinationPath; _mostRecentSourceFile = mostRecentSourceFile; }
public virtual void CreateDomImplementationHelpers(Document document, PropertyDictionary documentOptions) { foreach (Protocol protocol in document.Protocols) { PropertyDictionary protocolOptions = documentOptions.DictionaryFor(protocol.Name.ToString()) ?? PropertyDictionary.EmptyDictionary(); PropertyDictionary declarationDictionary = protocolOptions.DictionaryFor("declarations") ?? PropertyDictionary.EmptyDictionary(); protocol.Implementation = CreateProtocolImplementationHelper(protocol, protocolOptions); foreach (Declaration declaration in protocol.Declarations) { PropertyDictionary declarationOptions = declarationDictionary.DictionaryFor(declaration.QualifiedName.UnqualifiedName) ?? PropertyDictionary.EmptyDictionary(); if (declaration is Enumeration) { Enumeration enumeration = (Enumeration)declaration; enumeration.Implementation = CreateEnumerationImplementationHelper(enumeration, declarationOptions); foreach (EnumerationMember member in enumeration.MemberBases) { member.Implementation = CreateEnumerationMemberImplementationHelper(member); } } else if (declaration is Structure) { // The implementations of structures are created first, before any members: Structure structure = (Structure)declaration; structure.Implementation = CreateStructureImplementationHelper(structure, declarationOptions); } } // Now the members of each structure are created: foreach (Declaration declaration in protocol.Declarations) { if (declaration is Structure) { Structure structure = (Structure)declaration; foreach (StructureMember member in structure.Members) { member.Implementation = CreateStructureMemberImplementationHelper(member); } } } } }
public abstract void GenerateFiles(Generator generator, Document document);
public override void GenerateFiles(Generator generator, Document document) { generator.GenerateFile( Path.Combine(generator.DestinationPath, generator.BaseName + ".cs"), Templates.CsTemplate, "file", "Document", document); }
public override void GenerateFiles(Generator generator, Document document) { foreach (Protocol protocol in document.Protocols) { foreach (Declaration declaration in protocol.Declarations) { JavaStructure implementation = declaration.Implementation as JavaStructure; string fileSuffix = implementation != null && implementation.IsSurrogate ? "Surrogate.java" : ".java"; generator.GenerateFile( Path.Combine(generator.DestinationPath, declaration.Identifier + fileSuffix), Templates.JavaTemplate, "file", "Declaration", declaration); } } }
public override void GenerateFiles(Generator generator, Document document) { foreach (Protocol protocol in document.Protocols) { PythonProtocol pythonProtocol = protocol.Implementation as PythonProtocol; generator.GenerateFile( Path.Combine(generator.DestinationPath, pythonProtocol.ModuleName + ".py"), Templates.PythonTemplate, "file", "Protocol", protocol); } }