def GenerateHeader(self, hdrPath): f = filewriter.FileWriter() f.Open(hdrPath) f.WriteLine("// NIDL #version:{}#".format(self.version)) propertyLibraries = [] # Add additional dependencies to document. if "dependencies" in self.document: for dependency in self.document["dependencies"]: fileName = '{}.h'.format( os.path.splitext(dependency)[0]).lower() propertyLibraries.append(fileName) if "messages" in self.document: IDLDocument.AddInclude(f, "game/messaging/message.h") IDLProperty.ParseProperties(self.document) if (IDLProperty.ContainsResourceTypes()): IDLDocument.AddInclude(f, "resources/resource.h") IDLDocument.WriteIncludeHeader(f) IDLDocument.WriteIncludes(f, self.document) IDLDocument.WriteIncludes(f, propertyLibraries) hasMessages = "messages" in self.document hasProperties = "properties" in self.document hasEnums = "enums" in self.document if hasProperties or hasMessages or hasEnums: IDLDocument.BeginNamespace(f, self.document) if hasEnums: IDLProperty.WriteEnumeratedTypes(f, self.document) if hasMessages: IDLProtocol.WriteMessageDeclarations(f, self.document) if hasProperties: IDLProperty.WritePropertyHeaderDeclarations(f, self.document) IDLDocument.BeginNamespaceOverride(f, self.document, "Details") IDLProperty.WritePropertyHeaderDetails(f, self.document) IDLDocument.EndNamespaceOverride(f, self.document, "Details") f.WriteLine("") # Add additional dependencies to document. if "dependencies" in self.document: for dependency in self.document["dependencies"]: fstream = open(dependency, 'r') depDocument = sjson.loads(fstream.read()) deps = depDocument["properties"] # Add all properties to this document self.document["properties"].update(deps) fstream.close() IDLDocument.EndNamespace(f, self.document) f.Close() return
def GenerateHeader(self, hdrPath): f = filewriter.FileWriter() f.Open(hdrPath) f.WriteLine("// NIDL #version:{}#".format(self.version)) attributeLibraries = [] # Add additional dependencies to document. if "dependencies" in self.document: for dependency in self.document["dependencies"]: fileName = '{}.h'.format( os.path.splitext(dependency)[0]).lower() attributeLibraries.append(fileName) attributeLibraries.append("game/entity.h") if "components" in self.document: attributeLibraries.append("game/component/component.h") if "messages" in self.document: attributeLibraries.append("game/messaging/message.h") IDLDocument.WriteIncludeHeader(f) IDLDocument.WriteIncludes(f, self.document) IDLComponent.WriteIncludes(f, attributeLibraries) # Generate attributes include file if "attributes" in self.document: IDLDocument.WriteAttributeLibraryDeclaration(f) if "enums" in self.document: IDLDocument.BeginNamespace(f, self.document) IDLAttribute.WriteEnumeratedTypes(f, self.document) IDLDocument.EndNamespace(f, self.document) f.WriteLine("") if "attributes" in self.document: IDLDocument.BeginNamespaceOverride(f, self.document, "Attr") IDLAttribute.WriteAttributeHeaderDeclarations(f, self.document) IDLDocument.EndNamespaceOverride(f, self.document, "Attr") f.WriteLine("") # Add additional dependencies to document. if "dependencies" in self.document: for dependency in self.document["dependencies"]: fstream = open(dependency, 'r') depDocument = sjson.loads(fstream.read()) deps = depDocument["attributes"] # Add all attributes to this document self.document["attributes"].update(deps) fstream.close() # Generate components base classes headers hasMessages = "messages" in self.document hasComponents = "components" in self.document if hasComponents or hasMessages: IDLDocument.BeginNamespace(f, self.document) if hasMessages: IDLProtocol.WriteMessageDeclarations(f, self.document) if hasComponents: namespace = IDLDocument.GetNamespace(self.document) for componentName, component in self.document[ "components"].items(): componentWriter = IDLComponent.ComponentClassWriter( f, self.document, component, componentName, namespace) componentWriter.WriteClassDeclaration() IDLDocument.EndNamespace(f, self.document) f.Close() return