示例#1
0
 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
示例#2
0
 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())))
示例#3
0
    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
示例#4
0
 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
示例#5
0
    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
示例#6
0
 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())))
示例#7
0
    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
示例#8
0
    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