bool method_map_contains(const MethodMap& mmap, borrowed_ptr<const php::Class> cls, borrowed_ptr<const php::Func> func) { std::string const clsname = cls ? cls->name->data() : ""; auto it = mmap.find(clsname); if (it == end(mmap)) return false; return it->second.count(func->name->data()); }
Method* Profiler::find_method(Env* env, rmethod cm, rsymbol container, rsymbol name, Kind kind) { method_id id = create_id(env, cm, container, name, kind); Method* method; MethodMap::iterator iter = methods_.find(id); if(iter == methods_.end()) { method = new Method(id, name, container, kind); methods_[method->id()] = method; } else { method = iter->second; } return method; }
void tst_QDBusXmlParser::methods() { QString xmlHeader = "<node>" "<interface name=\"iface.iface1\">", xmlFooter = "</interface>" "</node>"; QFETCH(QString, xmlDataFragment); QDBusIntrospection::Interface iface = QDBusIntrospection::parseInterface(xmlHeader + xmlDataFragment + xmlFooter); QCOMPARE(iface.name, QString("iface.iface1")); QFETCH(MethodMap, methodMap); MethodMap parsedMap = iface.methods; QCOMPARE(parsedMap.count(), methodMap.count()); QCOMPARE(parsedMap, methodMap); }
void tst_QDBusXmlParser::methods() { QString xmlHeader = "<node>" "<interface name=\"iface.iface1\">", xmlFooter = "</interface>" "</node>"; QFETCH(QString, xmlDataFragment); if (strcmp(QTest::currentDataTag(), "two-in-one-invalid") == 0) QTest::ignoreMessage(QtWarningMsg, "Invalid D-BUS type signature '~' found while parsing introspection"); QDBusIntrospection::Interface iface = QDBusIntrospection::parseInterface(xmlHeader + xmlDataFragment + xmlFooter); QCOMPARE(iface.name, QString("iface.iface1")); QFETCH(MethodMap, methodMap); MethodMap parsedMap = iface.methods; QCOMPARE(methodMap.count(), parsedMap.count()); QCOMPARE(methodMap, parsedMap); }
void tst_QDBusXmlParser::methods_data() { QTest::addColumn<QString>("xmlDataFragment"); QTest::addColumn<MethodMap>("methodMap"); MethodMap map; QTest::newRow("no-methods") << QString() << map; // one method without arguments QDBusIntrospection::Method method; method.name = "Foo"; map << method; QTest::newRow("one-method") << "<method name=\"Foo\"/>" << map; // add another method without arguments method.name = "Bar"; map << method; QTest::newRow("two-methods") << "<method name=\"Foo\"/>" "<method name=\"Bar\"/>" << map; // invert the order of the XML declaration QTest::newRow("two-methods-inverse") << "<method name=\"Bar\"/>" "<method name=\"Foo\"/>" << map; // add a third, with annotations method.name = "Baz"; method.annotations.insert("foo.testing", "nothing to see here"); map << method; QTest::newRow("method-with-annotation") << "<method name=\"Foo\"/>" "<method name=\"Bar\"/>" "<method name=\"Baz\"><annotation name=\"foo.testing\" value=\"nothing to see here\"></method>" << map; // arguments map.clear(); method.annotations.clear(); method.name = "Method"; method.inputArgs << arg("s"); map << method; QTest::newRow("one-in") << "<method name=\"Method\">" "<arg type=\"s\" direction=\"in\"/>" "</method>" << map; // two arguments method.inputArgs << arg("v"); map.clear(); map << method; QTest::newRow("two-in") << "<method name=\"Method\">" "<arg type=\"s\" direction=\"in\"/>" "<arg type=\"v\" direction=\"in\"/>" "</method>" << map; // one invalid arg QTest::newRow("two-in-one-invalid") << "<method name=\"Method\">" "<arg type=\"s\" direction=\"in\"/>" "<arg type=\"~\" name=\"invalid\" direction=\"in\"/>" // this line should be ignored "<arg type=\"v\" direction=\"in\"/>" "</method>" << map; // one out argument method.inputArgs.clear(); method.outputArgs << arg("s"); map.clear(); map << method; QTest::newRow("one-out") << "<method name=\"Method\">" "<arg type=\"s\" direction=\"out\"/>" "</method>" << map; // two in and one out method.inputArgs << arg("s") << arg("v"); map.clear(); map << method; QTest::newRow("two-in-one-out") << "<method name=\"Method\">" "<arg type=\"s\" direction=\"in\"/>" "<arg type=\"v\" direction=\"in\"/>" "<arg type=\"s\" direction=\"out\"/>" "</method>" << map; // let's try an arg with name method.outputArgs.clear(); method.inputArgs.clear(); method.inputArgs << arg("s", "foo"); map.clear(); map << method; QTest::newRow("one-in-with-name") << "<method name=\"Method\">" "<arg type=\"s\" name=\"foo\" direction=\"in\"/>" "</method>" << map; // two args with name method.inputArgs << arg("i", "bar"); map.clear(); map << method; QTest::newRow("two-in-with-name") << "<method name=\"Method\">" "<arg type=\"s\" name=\"foo\" direction=\"in\"/>" "<arg type=\"i\" name=\"bar\" direction=\"in\"/>" "</method>" << map; // one complex map.clear(); method = QDBusIntrospection::Method(); // Method1(in STRING arg1, in BYTE arg2, out ARRAY of STRING) method.inputArgs << arg("s", "arg1") << arg("y", "arg2"); method.outputArgs << arg("as"); method.name = "Method1"; map << method; // Method2(in ARRAY of DICT_ENTRY of (STRING,VARIANT) variantMap, in UINT32 index, // out STRING key, out VARIANT value) // with annotation "foo.equivalent":"QVariantMap" method = QDBusIntrospection::Method(); method.inputArgs << arg("a{sv}", "variantMap") << arg("u", "index"); method.outputArgs << arg("s", "key") << arg("v", "value"); method.annotations.insert("foo.equivalent", "QVariantMap"); method.name = "Method2"; map << method; QTest::newRow("complex") << "<method name=\"Method1\">" "<arg name=\"arg1\" type=\"s\" direction=\"in\"/>" "<arg name=\"arg2\" type=\"y\" direction=\"in\"/>" "<arg type=\"as\" direction=\"out\"/>" "</method>" "<method name=\"Method2\">" "<arg name=\"variantMap\" type=\"a{sv}\" direction=\"in\"/>" "<arg name=\"index\" type=\"u\" direction=\"in\"/>" "<arg name=\"key\" type=\"s\" direction=\"out\"/>" "<arg name=\"value\" type=\"v\" direction=\"out\"/>" "<annotation name=\"foo.equivalent\" value=\"QVariantMap\"/>" "</method>" << map; }