Show a patch.

GET /api/1.1/patches/12100/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 12100,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/12100/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/12100/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20210423104711.401547-3-paul.elder@ideasonboard.com>",
    "date": "2021-04-23T10:47:10",
    "name": "[libcamera-devel,v3,2/3] utils: ipc: Use the proper namespace for mojom structs",
    "commit_ref": "078fbff8f41fbf5ab9d8389e63aa5d0dbbc1d5f5",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "4327d90cc19c936f2161aa41d2a475fb87a24b64",
    "submitter": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/1.1/people/17/?format=api",
        "name": "Paul Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "delegate": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/1.1/users/17/?format=api",
        "username": "epaul",
        "first_name": "Paul",
        "last_name": "Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "mbox": "https://patchwork.libcamera.org/patch/12100/mbox/",
    "series": [
        {
            "id": 1971,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1971/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1971",
            "date": "2021-04-23T10:47:08",
            "name": "Fix support for core.mojom structs",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/1971/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/12100/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/12100/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id AD130BDB15\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 23 Apr 2021 10:47:27 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7184760513;\n\tFri, 23 Apr 2021 12:47:27 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2971068880\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 23 Apr 2021 12:47:25 +0200 (CEST)",
            "from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 948B8332;\n\tFri, 23 Apr 2021 12:47:23 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"FZr/DIrb\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1619174844;\n\tbh=NhoVW4xnAXtePVeeBkFiz3AokU81yT8dqi5iCl6xVOg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=FZr/DIrbF63Mx2NeGZrSW1rbNRgU+1WA8CJr6yhXLuqJPn60wYGv+Yc2d9kTjVe+C\n\tqr5xsOJcMFw6gd2vpxDyi+cpmrFx2rfMMj7ohvwRYu9od19wshW0PQVb40/iPpVgzW\n\tXh02m0v0xPhdTYkUu4Qbo5IfhKaVZ66z11hY1Yok=",
        "From": "Paul Elder <paul.elder@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 23 Apr 2021 19:47:10 +0900",
        "Message-Id": "<20210423104711.401547-3-paul.elder@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20210423104711.401547-1-paul.elder@ideasonboard.com>",
        "References": "<20210423104711.401547-1-paul.elder@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v3 2/3] utils: ipc: Use the proper\n\tnamespace for mojom structs",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "<libcamera-devel.lists.libcamera.org>",
        "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>",
        "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>",
        "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>",
        "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Structs defined in mojom previously used the namespace of the mojom file\nthat was being used as the source. This is obviously not the correct\nnamespace for structs that are defined in core.mojom. Fix the jinja\nfunction for getting the element type including namespace, and use it.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nNew in v3\n---\n .../module_ipa_serializer.h.tmpl              |  2 +-\n .../libcamera_templates/serializer.tmpl       | 34 +++++++++----------\n .../generators/mojom_libcamera_generator.py   | 16 ++++++---\n 3 files changed, 30 insertions(+), 22 deletions(-)",
    "diff": "diff --git a/utils/ipc/generators/libcamera_templates/module_ipa_serializer.h.tmpl b/utils/ipc/generators/libcamera_templates/module_ipa_serializer.h.tmpl\nindex 64ae99dc..779d2114 100644\n--- a/utils/ipc/generators/libcamera_templates/module_ipa_serializer.h.tmpl\n+++ b/utils/ipc/generators/libcamera_templates/module_ipa_serializer.h.tmpl\n@@ -30,7 +30,7 @@ namespace libcamera {\n LOG_DECLARE_CATEGORY(IPADataSerializer)\n {% for struct in structs_nonempty %}\n template<>\n-class IPADataSerializer<{{struct|name_full(namespace_str)}}>\n+class IPADataSerializer<{{struct|name_full}}>\n {\n public:\n {{- serializer.serializer(struct, namespace_str)}}\ndiff --git a/utils/ipc/generators/libcamera_templates/serializer.tmpl b/utils/ipc/generators/libcamera_templates/serializer.tmpl\nindex af35b9e3..d8d55807 100644\n--- a/utils/ipc/generators/libcamera_templates/serializer.tmpl\n+++ b/utils/ipc/generators/libcamera_templates/serializer.tmpl\n@@ -68,7 +68,7 @@\n \t{%- elif field|is_str %}\n \t\t\tIPADataSerializer<{{field|name}}>::serialize(data.{{field.mojom_name}});\n \t{%- else %}\n-\t\t\tIPADataSerializer<{{field|name_full(namespace)}}>::serialize(data.{{field.mojom_name}}, cs);\n+\t\t\tIPADataSerializer<{{field|name_full}}>::serialize(data.{{field.mojom_name}}, cs);\n \t{%- endif %}\n \t\tappendPOD<uint32_t>(retData, {{field.mojom_name}}.size());\n \t{%- if field|has_fd %}\n@@ -97,7 +97,7 @@\n \t\t{%- if field|is_pod %}\n \t\tret.{{field.mojom_name}} = IPADataSerializer<{{field|name}}>::deserialize(m, m + {{field_size}});\n \t\t{%- else %}\n-\t\tret.{{field.mojom_name}} = static_cast<{{field|name_full(namespace)}}>(IPADataSerializer<uint{{field|bit_width}}_t>::deserialize(m, m + {{field_size}}));\n+\t\tret.{{field.mojom_name}} = static_cast<{{field|name_full}}>(IPADataSerializer<uint{{field|bit_width}}_t>::deserialize(m, m + {{field_size}}));\n \t\t{%- endif %}\n \t{%- if not loop.last %}\n \t\tm += {{field_size}};\n@@ -150,11 +150,11 @@\n \t{%- elif field|has_fd and (field|is_array or field|is_map) %}\n \t\t\tIPADataSerializer<{{field|name}}>::deserialize(m, m + {{field.mojom_name}}Size, n, n + {{field.mojom_name}}FdsSize, cs);\n \t{%- elif field|has_fd and (not (field|is_array or field|is_map)) %}\n-\t\t\tIPADataSerializer<{{field|name_full(namespace)}}>::deserialize(m, m + {{field.mojom_name}}Size, n, n + {{field.mojom_name}}FdsSize, cs);\n+\t\t\tIPADataSerializer<{{field|name_full}}>::deserialize(m, m + {{field.mojom_name}}Size, n, n + {{field.mojom_name}}FdsSize, cs);\n \t{%- elif (not field|has_fd) and (field|is_array or field|is_map) %}\n \t\t\tIPADataSerializer<{{field|name}}>::deserialize(m, m + {{field.mojom_name}}Size, cs);\n \t{%- else %}\n-\t\t\tIPADataSerializer<{{field|name_full(namespace)}}>::deserialize(m, m + {{field.mojom_name}}Size, cs);\n+\t\t\tIPADataSerializer<{{field|name_full}}>::deserialize(m, m + {{field.mojom_name}}Size, cs);\n \t{%- endif %}\n \t{%- if not loop.last %}\n \t\tm += {{field_size}};\n@@ -178,7 +178,7 @@\n  #}\n {%- macro serializer(struct, namespace) %}\n \tstatic std::tuple<std::vector<uint8_t>, std::vector<int32_t>>\n-\tserialize(const {{struct|name_full(namespace)}} &data,\n+\tserialize(const {{struct|name_full}} &data,\n {%- if struct|needs_control_serializer %}\n \t\t  ControlSerializer *cs)\n {%- else %}\n@@ -208,7 +208,7 @@\n  # \\a struct, in the case that \\a struct has file descriptors.\n  #}\n {%- macro deserializer_fd(struct, namespace) %}\n-\tstatic {{struct|name_full(namespace)}}\n+\tstatic {{struct|name_full}}\n \tdeserialize(std::vector<uint8_t> &data,\n \t\t    std::vector<int32_t> &fds,\n {%- if struct|needs_control_serializer %}\n@@ -217,11 +217,11 @@\n \t\t    ControlSerializer *cs = nullptr)\n {%- endif %}\n \t{\n-\t\treturn IPADataSerializer<{{struct|name_full(namespace)}}>::deserialize(data.cbegin(), data.cend(), fds.cbegin(), fds.cend(), cs);\n+\t\treturn IPADataSerializer<{{struct|name_full}}>::deserialize(data.cbegin(), data.cend(), fds.cbegin(), fds.cend(), cs);\n \t}\n \n {# \\todo Don't inline this function #}\n-\tstatic {{struct|name_full(namespace)}}\n+\tstatic {{struct|name_full}}\n \tdeserialize(std::vector<uint8_t>::const_iterator dataBegin,\n \t\t    std::vector<uint8_t>::const_iterator dataEnd,\n \t\t    std::vector<int32_t>::const_iterator fdsBegin,\n@@ -232,7 +232,7 @@\n \t\t    [[maybe_unused]] ControlSerializer *cs = nullptr)\n {%- endif %}\n \t{\n-\t\t{{struct|name_full(namespace)}} ret;\n+\t\t{{struct|name_full}} ret;\n \t\tstd::vector<uint8_t>::const_iterator m = dataBegin;\n \t\tstd::vector<int32_t>::const_iterator n = fdsBegin;\n \n@@ -253,22 +253,22 @@\n  # deserializers with file descriptors.\n  #}\n {%- macro deserializer_fd_simple(struct, namespace) %}\n-\tstatic {{struct|name_full(namespace)}}\n+\tstatic {{struct|name_full}}\n \tdeserialize(std::vector<uint8_t> &data,\n \t\t    [[maybe_unused]] std::vector<int32_t> &fds,\n \t\t    ControlSerializer *cs = nullptr)\n \t{\n-\t\treturn IPADataSerializer<{{struct|name_full(namespace)}}>::deserialize(data.cbegin(), data.cend(), cs);\n+\t\treturn IPADataSerializer<{{struct|name_full}}>::deserialize(data.cbegin(), data.cend(), cs);\n \t}\n \n-\tstatic {{struct|name_full(namespace)}}\n+\tstatic {{struct|name_full}}\n \tdeserialize(std::vector<uint8_t>::const_iterator dataBegin,\n \t\t    std::vector<uint8_t>::const_iterator dataEnd,\n \t\t    [[maybe_unused]] std::vector<int32_t>::const_iterator fdsBegin,\n \t\t    [[maybe_unused]] std::vector<int32_t>::const_iterator fdsEnd,\n \t\t    ControlSerializer *cs = nullptr)\n \t{\n-\t\treturn IPADataSerializer<{{struct|name_full(namespace)}}>::deserialize(dataBegin, dataEnd, cs);\n+\t\treturn IPADataSerializer<{{struct|name_full}}>::deserialize(dataBegin, dataEnd, cs);\n \t}\n {%- endmacro %}\n \n@@ -280,7 +280,7 @@\n  # \\a struct, in the case that \\a struct does not have file descriptors.\n  #}\n {%- macro deserializer_no_fd(struct, namespace) %}\n-\tstatic {{struct|name_full(namespace)}}\n+\tstatic {{struct|name_full}}\n \tdeserialize(std::vector<uint8_t> &data,\n {%- if struct|needs_control_serializer %}\n \t\t    ControlSerializer *cs)\n@@ -288,11 +288,11 @@\n \t\t    ControlSerializer *cs = nullptr)\n {%- endif %}\n \t{\n-\t\treturn IPADataSerializer<{{struct|name_full(namespace)}}>::deserialize(data.cbegin(), data.cend(), cs);\n+\t\treturn IPADataSerializer<{{struct|name_full}}>::deserialize(data.cbegin(), data.cend(), cs);\n \t}\n \n {# \\todo Don't inline this function #}\n-\tstatic {{struct|name_full(namespace)}}\n+\tstatic {{struct|name_full}}\n \tdeserialize(std::vector<uint8_t>::const_iterator dataBegin,\n \t\t    std::vector<uint8_t>::const_iterator dataEnd,\n {%- if struct|needs_control_serializer %}\n@@ -301,7 +301,7 @@\n \t\t    [[maybe_unused]] ControlSerializer *cs = nullptr)\n {%- endif %}\n \t{\n-\t\t{{struct|name_full(namespace)}} ret;\n+\t\t{{struct|name_full}} ret;\n \t\tstd::vector<uint8_t>::const_iterator m = dataBegin;\n \n \t\tsize_t dataSize = std::distance(dataBegin, dataEnd);\ndiff --git a/utils/ipc/generators/mojom_libcamera_generator.py b/utils/ipc/generators/mojom_libcamera_generator.py\nindex db9e28a6..effdfed6 100644\n--- a/utils/ipc/generators/mojom_libcamera_generator.py\n+++ b/utils/ipc/generators/mojom_libcamera_generator.py\n@@ -258,12 +258,12 @@ def GetNameForElement(element):\n         return element.mojom_name\n     # vectors\n     if (mojom.IsArrayKind(element)):\n-        elem_name = GetNameForElement(element.kind)\n+        elem_name = GetFullNameForElement(element.kind)\n         return f'std::vector<{elem_name}>'\n     # maps\n     if (mojom.IsMapKind(element)):\n-        key_name = GetNameForElement(element.key_kind)\n-        value_name = GetNameForElement(element.value_kind)\n+        key_name = GetFullNameForElement(element.key_kind)\n+        value_name = GetFullNameForElement(element.value_kind)\n         return f'std::map<{key_name}, {value_name}>'\n     # struct fields and function parameters\n     if isinstance(element, (mojom.Field, mojom.Method, mojom.Parameter)):\n@@ -296,8 +296,16 @@ def GetNameForElement(element):\n         raise Exception('Unsupported element: %s' % element)\n     raise Exception('Unexpected element: %s' % element)\n \n-def GetFullNameForElement(element, namespace_str):\n+def GetFullNameForElement(element):\n     name = GetNameForElement(element)\n+    namespace_str = ''\n+    if mojom.IsStructKind(element):\n+        namespace_str = element.module.mojom_namespace.replace('.', '::')\n+    elif (hasattr(element, 'kind') and\n+             (mojom.IsStructKind(element.kind) or\n+              mojom.IsEnumKind(element.kind))):\n+        namespace_str = element.kind.module.mojom_namespace.replace('.', '::')\n+\n     if namespace_str == '':\n         return name\n     return f'{namespace_str}::{name}'\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "2/3"
    ]
}