def code(): text = "" for message in messages: message_defines = getPackage( message).cpp.defines() + message.cpp.defines() if message_defines: text += self.renderDefines(message_defines) + "\n" text += self.indent( render( """ case %(class)s::Type: // %(file)s: %(messagePath)s return %(class)s::Deserialize(src, dst, delay, data); """, { "opMessageID": message.cpp.opMessageID, "messagePath": ".".join(message.path()), "file": os.path.normpath( getPackage(message).filename).replace( "\\", "/"), "class": message.cpp.opMessage().symbol(), })) + "\n\n" if message_defines: text += self.renderEndifs(message_defines) + "\n" return text
def __init__(self, file_path, root, operaRoot, buildModule, modulePath, basePath, jumboComponent, messages, enums, dependencies=None): TemplatedGenerator.__init__(self) CppScopeBase.__init__(self, file_path=file_path, dependencies=dependencies) CppModuleBase.__init__(self, root, operaRoot, buildModule, modulePath, basePath) self.jumboComponent = jumboComponent self.messages = messages[:] self.messages.sort(key=lambda i: "%s:%s" % (getPackage(i).filename, ".".join(i.path())))
def renderVerify(self, messages): text = "\n" + render( """ /*static*/ BOOL %(class)s::VerifyType(int type) { \tswitch(type) \t{ """, { "class": "OpTypedMessageBase", }) + "\n" for message in messages: message_defines = getPackage( message).cpp.defines() + message.cpp.defines() if message_defines: text += self.renderDefines(message_defines) + "\n" text += self.indent( render( """ case %(class)s::Type: // %(file)s: %(messagePath)s """, { "opMessageID": message.cpp.opMessageID, "messagePath": ".".join(message.path()), "file": os.path.normpath(getPackage(message).filename).replace( "\\", "/"), "class": message.cpp.opMessage().symbol(), }), 2) + "\n\n" if message_defines: text += self.renderEndifs(message_defines) + "\n" text += "\n\t\t\t" + render( """ \t\t\treturn TRUE; \t\tdefault: \t\t\treturn FALSE; \t} } """, { "class": "OpTypedMessageBase", }) + "\n" return text
def code(): text = "" for message in messages: message_defines = getPackage(message).cpp.defines() + message.cpp.defines() if message_defines: text += self.renderDefines(message_defines) + "\n" text += self.indent(render(""" case %(class)s::Type: // %(file)s: %(messagePath)s return %(class)s::Deserialize(src, dst, delay, data); """, { "opMessageID": message.cpp.opMessageID, "messagePath": ".".join(message.path()), "file": os.path.normpath(getPackage(message).filename).replace("\\", "/"), "class": message.cpp.opMessage().symbol(), })) + "\n\n" if message_defines: text += self.renderEndifs(message_defines) + "\n" return text
def renderVerify(self, messages): text = "\n" + render(""" /*static*/ BOOL %(class)s::VerifyType(int type) { \tswitch(type) \t{ """, { "class": "OpTypedMessageBase", }) + "\n" for message in messages: message_defines = getPackage(message).cpp.defines() + message.cpp.defines() if message_defines: text += self.renderDefines(message_defines) + "\n" text += self.indent(render(""" case %(class)s::Type: // %(file)s: %(messagePath)s """, { "opMessageID": message.cpp.opMessageID, "messagePath": ".".join(message.path()), "file": os.path.normpath(getPackage(message).filename).replace("\\", "/"), "class": message.cpp.opMessage().symbol(), }), 2) + "\n\n" if message_defines: text += self.renderEndifs(message_defines) + "\n" text += "\n\t\t\t" + render(""" \t\t\treturn TRUE; \t\tdefault: \t\t\treturn FALSE; \t} } """, { "class": "OpTypedMessageBase", }) + "\n" return text
def generate(self): includes = [ "modules/hardcore/src/generated/OpTypedMessageBase.h", ] includes_set = set(includes) for message in self.messages: package = getPackage(message) for include in package.cpp.opMessageIncludes(): if include not in includes_set: includes_set.add(include) includes.append(include) text = fileHeader() text += "\n" + render( """ // Generated from proto files in the system #include "core/pch.h" %(defines)s %(includes)s """, { "defines": self.renderDefines(self.defines), "includes": self.renderIncludes(includes), }) + "\n" text += self.renderVerify(self.messages) + "\n" text += self.renderDeserialize(self.messages) + "\n" text += render(""" %(endifs)s """, { "endifs": self.renderEndifs(self.defines), }) + "\n" return text
def generate(self): includes = ["modules/hardcore/src/generated/OpTypedMessageBase.h", ] includes_set = set(includes) for message in self.messages: package = getPackage(message) for include in package.cpp.opMessageIncludes(): if include not in includes_set: includes_set.add(include) includes.append(include) text = fileHeader() text += "\n" + render(""" // Generated from proto files in the system #include "core/pch.h" %(defines)s %(includes)s """, { "defines": self.renderDefines(self.defines), "includes": self.renderIncludes(includes), }) + "\n" text += self.renderVerify(self.messages) + "\n" text += self.renderDeserialize(self.messages) + "\n" text += render(""" %(endifs)s """, { "endifs": self.renderEndifs(self.defines), }) + "\n" return text