From 7bd79b3cffbbbece23867c5e111a3dd2ebcad016 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 1 Jul 2018 10:20:21 -0700 Subject: Plugins: Save some architectural requirement flags ...not just the debug flag. The information is saved outside of the CBOR map for two reasons: 1) removing the hack that depended on how QCborStreamWriter and TinyCBOR internally work, allowing for the extra parameter to be written directly. We wouldn't be able to use that hack anyway and would have needed a further, uglier hack to encode a byte whose value we don't know. 2) outside the map, this information can be parsed more quickly and then we can discard any plugins we shouldn't actually load. Since we're doing this for a flag, I decided to move the Qt version there too for reason #2. Change-Id: I61ecce6b1324410bbab4fffd153d4e5fc696d19e Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- src/tools/moc/generator.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'src/tools') diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index e5154b779b..e499d22618 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -1624,8 +1624,11 @@ void Generator::generatePluginMetaData() return; fputs("\nQT_PLUGIN_METADATA_SECTION\n" - "static const unsigned char qt_pluginMetaData[] = {\n" - " 'Q', 'T', 'M', 'E', 'T', 'A', 'D', 'A', 'T', 'A', ' ', '!',", out); + "static constexpr unsigned char qt_pluginMetaData[] = {\n" + " 'Q', 'T', 'M', 'E', 'T', 'A', 'D', 'A', 'T', 'A', ' ', '!',\n" + " // metadata version, Qt version, architectural requirements\n" + " 0, QT_VERSION_MAJOR, QT_VERSION_MINOR, qPluginArchRequirements(),", out); + CborDevice dev(out); CborEncoder enc; @@ -1634,20 +1637,6 @@ void Generator::generatePluginMetaData() CborEncoder map; cbor_encoder_create_map(&enc, &map, CborIndefiniteLength); - dev.nextItem("\"version\""); - cbor_encode_int(&map, int(QtPluginMetaDataKeys::QtVersion)); - cbor_encode_int(&map, QT_VERSION); - - fputs("\n#ifdef QT_NO_DEBUG", out); - dev.nextItem("\"debug\" = false"); - cbor_encode_int(&map, int(QtPluginMetaDataKeys::Debug)); - cbor_encode_boolean(&map, false); - fputs("\n#else", out); - dev.nextItem("\"debug\" = true"); - cbor_encode_int(&map, int(QtPluginMetaDataKeys::Debug)); - cbor_encode_boolean(&map, true); - fputs("\n#endif", out); - dev.nextItem("\"IID\""); cbor_encode_int(&map, int(QtPluginMetaDataKeys::IID)); cbor_encode_text_string(&map, cdef->pluginData.iid.constData(), cdef->pluginData.iid.size()); -- cgit v1.2.3