Пример #1
0
void ClassTestSuite::testMethodSearch()
{
	Class test = Class::lookup("ClassTest::Test1");

	auto retDouble = test.findAllMethods([&](const Method& m) {
		return m.returnSpelling() == "double";
	});

	TS_ASSERT_EQUALS(retDouble.size(), 3);

	auto retDoubleStrict = test.findAllMethods([&](const Method& m) {
		return m.returnSpelling() == "double" && m.getClass() == test; //filter out inherited methods
	});

	TS_ASSERT_EQUALS(retDoubleStrict.size(), 2);

	auto constMethods = test.findAllMethods([&](const Method& m) {
		return m.isConst();
	});

	TS_ASSERT_EQUALS(constMethods.size(), 2);

	Method m = test.findMethod([&](const Method& m) {
			   return m.name() == "method1";
		   });

	TS_ASSERT(m.isValid());
	TS_ASSERT(m.isConst());
	TS_ASSERT_EQUALS(m.returnSpelling(), "std::string");


	Method m30 = test.findMethod([&](const Method& m) {
			   return m.name() == "method30";
		   });

	TS_ASSERT(!m30.isValid());
	TS_ASSERT_THROWS_ANYTHING(m30.isConst());
}
Пример #2
0
void SmokeClassFiles::generateMethod(QTextStream& out, const QString& className, const QString& smokeClassName,
                                     const Method& meth, int index, QSet<QString>& includes)
{
    out << "    ";
    if ((meth.flags() & Method::Static) || meth.isConstructor())
        out << "static ";
    out << QString("void x_%1(Smoke::Stack x) {\n").arg(index);
    out << "        // " << meth.toString() << "\n";
    out << "        ";
    
    if (meth.isConstructor()) {
        out << smokeClassName << "* xret = new " << smokeClassName << "(";
    } else {
        const Function* func = Util::globalFunctionMap[&meth];
        if (func)
            includes.insert(func->fileName());
        
        if (meth.type()->getClass())
            includes.insert(meth.type()->getClass()->fileName());
        
        if (meth.type()->isFunctionPointer() || meth.type()->isArray())
            out << meth.type()->toString("xret") << " = ";
        else if (meth.type() != Type::Void)
            out << meth.type()->toString() << " xret = ";
        
        if (!(meth.flags() & Method::Static)) {
            if (meth.isConst()) {
                out << "((const " << smokeClassName << "*)this)->";
            } else {
                out << "this->";
            }
        }
        if (!(meth.flags() & Method::PureVirtual) && !func) {
            // dynamic dispatch for virtuals
            out << className << "::";
        } else if (func) {
            if (!func->nameSpace().isEmpty())
                out << func->nameSpace() << "::";
        }
        out << meth.name() << "(";
    }
    
    for (int j = 0; j < meth.parameters().count(); j++) {
        const Parameter& param = meth.parameters()[j];
        
        if (param.type()->getClass())
            includes.insert(param.type()->getClass()->fileName());
        
        if (j > 0) out << ",";
        
        QString field = Util::stackItemField(param.type());
        QString typeName = param.type()->toString();
        if (param.type()->isArray()) {
            Type t = *param.type();
            t.setPointerDepth(t.pointerDepth() + 1);
            t.setIsRef(false);
            typeName = t.toString();
            out << '*';
        } else if (field == "s_class" && (param.type()->pointerDepth() == 0 || param.type()->isRef()) && !param.type()->isFunctionPointer()) {
            // references and classes are passed in s_class
            typeName.append('*');
            out << '*';
        }
        // casting to a reference doesn't make sense in this case
        if (param.type()->isRef() && !param.type()->isFunctionPointer()) typeName.replace('&', "");
        out << "(" << typeName << ")" << "x[" << j + 1 << "]." << field;
    }
    
    // if the method has any other default parameters, append them here as values, so 
    
    if (!meth.remainingDefaultValues().isEmpty()) {
        const QStringList& defaultParams = meth.remainingDefaultValues();
        if (meth.parameters().count() > 0)
            out << "," ;
        out << defaultParams.join(",");
    }
    
    out << ");\n";
    if (meth.type() != Type::Void) {
        out << "        x[0]." << Util::stackItemField(meth.type()) << " = " << Util::assignmentString(meth.type(), "xret") << ";\n";
    } else {
        out << "        (void)x; // noop (for compiler warning)\n";
    }
    
    out << "    }\n";
    
    // If the constructor was generated from another one with default parameteres, we don't need to explicitly create
    // it here again. The x_* call will append the default parameters at the end and thus choose the right constructor.
    if (meth.isConstructor() && meth.remainingDefaultValues().isEmpty()) {
        out << "    explicit " << smokeClassName << '(';
        QStringList x_list;
        for (int i = 0; i < meth.parameters().count(); i++) {
            if (i > 0) out << ", ";
            out << meth.parameters()[i].type()->toString() << " x" << QString::number(i + 1);
            x_list << "x" + QString::number(i + 1);
        }
        out << ") : " << meth.getClass()->name() << '(' << x_list.join(", ") << ") {}\n";
    }
}
Пример #3
0
void SmokeClassFiles::generateVirtualMethod(QTextStream& out, const Method& meth, QSet<QString>& includes)
{
    QString x_params, x_list;
    QString type = meth.type()->toString();
    if (meth.type()->getClass())
        includes.insert(meth.type()->getClass()->fileName());
    
    out << "    virtual " << type << " " << meth.name() << "(";
    for (int i = 0; i < meth.parameters().count(); i++) {
        if (i > 0) { out << ", "; x_list.append(", "); }
        const Parameter& param = meth.parameters()[i];
        
        if (param.type()->getClass())
            includes.insert(param.type()->getClass()->fileName());
        
        out << param.type()->toString() << " x" << i + 1;
        x_params += QString("        x[%1].%2 = %3;\n")
            .arg(QString::number(i + 1)).arg(Util::stackItemField(param.type()))
            .arg(Util::assignmentString(param.type(), "x" + QString::number(i + 1)));
        x_list += "x" + QString::number(i + 1);
    }
    out << ") ";
    if (meth.isConst())
        out << "const ";
    if (meth.hasExceptionSpec()) {
        out << "throw(";
        for (int i = 0; i < meth.exceptionTypes().count(); i++) {
            if (i > 0) out << ", ";
            out << meth.exceptionTypes()[i].toString();
        }
        out << ") ";
    }
    out << "{\n";
    out << QString("        Smoke::StackItem x[%1];\n").arg(meth.parameters().count() + 1);
    out << x_params;
    
    if (meth.flags() & Method::PureVirtual) {
        out << QString("        this->_binding->callMethod(%1, (void*)this, x, true /*pure virtual*/);\n").arg(m_smokeData->methodIdx[&meth]);
        if (meth.type() != Type::Void) {
            QString field = Util::stackItemField(meth.type());
            if (meth.type()->pointerDepth() == 0 && field == "s_class") {
                QString tmpType = type;
                if (meth.type()->isRef()) tmpType.replace('&', "");
                tmpType.append('*');
                out << "        " << tmpType << " xptr = (" << tmpType << ")x[0].s_class;\n";
                out << "        " << type << " xret(*xptr);\n";
                out << "        delete xptr;\n";
                out << "        return xret;\n";
            } else {
                out << QString("        return (%1)x[0].%2;\n").arg(type, Util::stackItemField(meth.type()));
            }
        }
    } else {
        out << QString("        if (this->_binding->callMethod(%1, (void*)this, x)) ").arg(m_smokeData->methodIdx[&meth]);
        if (meth.type() == Type::Void) {
            out << "return;\n";
        } else {
            QString field = Util::stackItemField(meth.type());
            if (meth.type()->pointerDepth() == 0 && field == "s_class") {
                QString tmpType = type;
                if (meth.type()->isRef()) tmpType.replace('&', "");
                tmpType.append('*');
                out << "{\n";
                out << "            " << tmpType << " xptr = (" << tmpType << ")x[0].s_class;\n";
                out << "            " << type << " xret(*xptr);\n";
                out << "            delete xptr;\n";
                out << "            return xret;\n";
                out << "        }\n";
            } else {
                out << QString("return (%1)x[0].%2;\n").arg(type, Util::stackItemField(meth.type()));
            }
        }
        out << "        ";
        if (meth.type() != Type::Void)
            out << "return ";
        out << QString("this->%1::%2(%3);\n").arg(meth.getClass()->toString()).arg(meth.name()).arg(x_list);
    }
    out << "    }\n";
}
Пример #4
0
QString SmokeClassFiles::generateMethodBody(const QString& indent, const QString& className, const QString& smokeClassName, const Method& meth,
                                            int index, bool dynamicDispatch, QSet<QString>& includes)
{
    QString methodBody;
    QTextStream out(&methodBody);

    out << indent;

    if (meth.isConstructor()) {
        out << smokeClassName << "* xret = new " << smokeClassName << "(";
    } else {
        const Function* func = Util::globalFunctionMap[&meth];
        if (func)
            includes.insert(func->fileName());

        if (meth.type()->getClass())
            includes.insert(meth.type()->getClass()->fileName());

        if (meth.type()->isFunctionPointer() || meth.type()->isArray())
            out << meth.type()->toString("xret") << " = ";
        else if (meth.type() != Type::Void)
            out << meth.type()->toString() << " xret = ";

        if (!(meth.flags() & Method::Static)) {
            if (meth.isConst()) {
                out << "((const " << smokeClassName << "*)this)->";
            } else {
                out << "this->";
            }
        }
        if (!dynamicDispatch && !func) {
            // dynamic dispatch not wanted, call with 'this->Foo::method()'
            out << className << "::";
        } else if (func) {
            if (!func->nameSpace().isEmpty())
                out << func->nameSpace() << "::";
        }
        out << meth.name() << "(";
    }

    for (int j = 0; j < meth.parameters().count(); j++) {
        const Parameter& param = meth.parameters()[j];

        if (param.type()->getClass())
            includes.insert(param.type()->getClass()->fileName());

        if (j > 0) out << ",";

        QString field = Util::stackItemField(param.type());
        QString typeName = param.type()->toString();
        if (param.type()->isArray()) {
            Type t = *param.type();
            t.setPointerDepth(t.pointerDepth() + 1);
            t.setIsRef(false);
            typeName = t.toString();
            out << '*';
        } else if (field == "s_class" && (param.type()->pointerDepth() == 0 || param.type()->isRef()) && !param.type()->isFunctionPointer()) {
            // references and classes are passed in s_class
            typeName.append('*');
            out << '*';
        }
        // casting to a reference doesn't make sense in this case
        if (param.type()->isRef() && !param.type()->isFunctionPointer()) typeName.replace('&', "");
        out << "(" << typeName << ")" << "x[" << j + 1 << "]." << field;
    }

    // if the method has any other default parameters, append them here as values
    if (!meth.remainingDefaultValues().isEmpty()) {
        const QStringList& defaultParams = meth.remainingDefaultValues();
        if (meth.parameters().count() > 0)
            out << "," ;
        out << defaultParams.join(",");
    }

    out << ");\n";
    if (meth.type() != Type::Void) {
        out << indent << "x[0]." << Util::stackItemField(meth.type()) << " = " << Util::assignmentString(meth.type(), "xret") << ";\n";
    } else {
        out << indent << "(void)x; // noop (for compiler warning)\n";
    }

    return methodBody;
}
Пример #5
0
void ClassTestSuite::testClass()
{
	//Class test = ClassOf<Test1>();

	Class test = Class::lookup("ClassTest::Test1");

	TS_ASSERT_EQUALS(test.simpleName(), "Test1");

#ifndef NO_RTTI
	TS_ASSERT(test.describes<ClassTest::Test1>())

	Class test2 = Class::lookup(typeid(ClassTest::Test1));
	TS_ASSERT_EQUALS(test2.simpleName(), "Test1");
	TS_ASSERT_EQUALS(test, test2);
#endif

	Class::ClassList superClasses = test.superclasses();

	TS_ASSERT_EQUALS(superClasses.size(), 2);

	Class base1;
	Class base2;

	TS_ASSERT_THROWS(base1.simpleName(), std::runtime_error); // uninitialized handle

	for(const Class& c: superClasses) {
		if (c.fullyQualifiedName() == "ClassTest::TestBase1") {
			base1 = c;
		} else if (c.fullyQualifiedName() == "ClassTest::TestBase2") {
			base2 = c;
		}
	}

	TS_ASSERT_EQUALS(base1.fullyQualifiedName(), "ClassTest::TestBase1");
	TS_ASSERT_EQUALS(base1.simpleName(), "TestBase1");
	TS_ASSERT_EQUALS(base2.fullyQualifiedName(), "ClassTest::TestBase2");
	TS_ASSERT_EQUALS(base2.simpleName(), "TestBase2");

	TS_ASSERT(inheritanceRelation(test, base1));
	TS_ASSERT(inherits(test, base1));
	TS_ASSERT(inheritedBy(base1, test));

	TS_ASSERT(inheritanceRelation(test, base2));
	TS_ASSERT(inherits(test, base2));
	TS_ASSERT(inheritedBy(base2, test));

	TS_ASSERT(!inheritanceRelation(base1, base2));

	Class::ConstructorList base1Constructors = base1.constructors();
	TS_ASSERT_EQUALS(base1.constructors().size(), 1);

	Constructor base1Constructor = base1Constructors.front();

	TS_ASSERT_EQUALS(base1Constructor.numberOfArguments(), 0);
	TS_ASSERT_THROWS(base1Constructor.call(), std::runtime_error); // abstract class


	Class::ConstructorList base2Constructors = base2.constructors();
	TS_ASSERT_EQUALS(base2.constructors().size(), 1);

	Constructor base2Constructor = base2Constructors.front();

	TS_ASSERT_EQUALS(base2Constructor.numberOfArguments(), 0);

	VariantValue b2Inst = base2Constructor.call();
	TS_ASSERT(b2Inst.isValid());

	TS_ASSERT_EQUALS(base2.attributes().size(), 0);
	Class::MethodList base2Methods = base2.methods();
	TS_ASSERT_EQUALS(base2Methods.size(), 1);

	Method base2Method1 = base2Methods.front();

	TS_ASSERT_EQUALS(base2Method1.name(), "base2Method1");
	TS_ASSERT(base2Method1.isConst());
	TS_ASSERT(!base2Method1.isVolatile());
	TS_ASSERT(!base2Method1.isStatic());
	TS_ASSERT_EQUALS(base2Method1.numberOfArguments(), 0);
	TS_ASSERT_EQUALS(base2Method1.call(b2Inst).value<int>(), 6);


	Class::ConstructorList testConstructors = test.constructors();
	Class::AttributeList   attributes       = test.attributes();

	TS_ASSERT_EQUALS(attributes.size(), 2);
	Attribute attr = attributes.front();

	WITH_RTTI(TS_ASSERT(attr.type() == typeid(int)));

	TS_ASSERT_EQUALS(testConstructors.size(), 3);

	Constructor defaultConstr;
	Constructor intConstr;

	TS_ASSERT_THROWS(defaultConstr.argumentSpellings(), std::runtime_error);

	for (const Constructor& c: testConstructors) {
		if (c.numberOfArguments() == 0) {
			defaultConstr = c;
		} else if (c.numberOfArguments() == 1  && c.argumentSpellings()[0] == "int"){
			intConstr = c;
		}
	}


	TS_ASSERT_EQUALS(defaultConstr.numberOfArguments(), 0);
	TS_ASSERT_EQUALS(intConstr.numberOfArguments(), 1);

	VariantValue testInst1 = defaultConstr.call();

	TS_ASSERT(testInst1.isA<Test1>());


#ifndef NO_RTTI
	Class test3 = Class::lookup(testInst1.typeId());
	TS_ASSERT_EQUALS(test3.simpleName(), "Test1");
	TS_ASSERT_EQUALS(test, test3);
#endif

    TS_ASSERT_EQUALS(attr.get(testInst1).value<const int&>(), 3);


	VariantValue testInst2 = intConstr.call(77);

	TS_ASSERT(testInst2.isA<Test1>());
    TS_ASSERT_EQUALS(attr.get(testInst2).value<const int&>(), 77);

	Class::MethodList methods = test.methods();

	TS_ASSERT_EQUALS(methods.size(), 9);

	Method base1Method1;
	Method method1;
	Method method2;
	Method staticMethod;


	for (const Method& m: methods) {
		if (m.name() == "base1Method1") {
			base1Method1 = m;
		} else if (m.name() == "base2Method1") {
			base2Method1 = m;
		} else if (m.name() == "method1") {
			method1 = m;
		} else if (m.name() == "method2") {
			method2 = m;
		} else if (m.name() == "staticMethod") {
			staticMethod = m;
		}
	}

	TS_ASSERT_EQUALS(base1Method1.name(), "base1Method1");
	TS_ASSERT(!base1Method1.isConst());
	TS_ASSERT(!base1Method1.isStatic());
	TS_ASSERT(!base1Method1.isVolatile());
	WITH_RTTI(TS_ASSERT(base1Method1.returnType() == typeid(int)));
	TS_ASSERT_EQUALS(base1Method1.numberOfArguments(), 0);
	TS_ASSERT_EQUALS(base1Method1.call(testInst2).value<int>(), 5);

	TS_ASSERT_EQUALS(base2Method1.name(), "base2Method1");
	TS_ASSERT(base2Method1.isConst());
	TS_ASSERT(!base2Method1.isStatic());
	TS_ASSERT(!base2Method1.isVolatile());
	WITH_RTTI(TS_ASSERT(base2Method1.returnType() == typeid(int)));
	TS_ASSERT_EQUALS(base2Method1.numberOfArguments(), 0);
	TS_ASSERT_EQUALS(base2Method1.call(testInst2).value<int>(), 6);

	TS_ASSERT_EQUALS(method2.name(), "method2");
	TS_ASSERT(!method2.isConst());
	TS_ASSERT(!method2.isStatic());
	TS_ASSERT(!method2.isVolatile());
	WITH_RTTI(TS_ASSERT(method2.returnType() == typeid(double)));
	TS_ASSERT_EQUALS(method2.numberOfArguments(), 1);
	WITH_RTTI(TS_ASSERT(*method2.argumentTypes()[0] == typeid(double)));
	TS_ASSERT_EQUALS(method2.call(testInst2, 2).value<double>(), 6.28);

	TS_ASSERT_EQUALS(staticMethod.name(), "staticMethod");
	TS_ASSERT(!staticMethod.isConst());
	TS_ASSERT(staticMethod.isStatic());
	TS_ASSERT(!staticMethod.isVolatile());
	WITH_RTTI(TS_ASSERT(staticMethod.returnType() == typeid(double)));
	TS_ASSERT_EQUALS(staticMethod.numberOfArguments(), 0);
	TS_ASSERT_EQUALS(staticMethod.call().value<double>(), 3.14);

    ClassTest::Test1 t(666);
    VariantValue inst3;
    inst3.construct<ClassTest::TestBase1&>(t);
    TS_ASSERT_THROWS_ANYTHING(method1.call(inst3).value<string>());

    VariantValue inst4 = test.castUp(inst3, base1);
    TS_ASSERT(inst4.isValid());
    bool success = false;
    ClassTest::Test1& derivedRef = inst4.convertTo<ClassTest::Test1&>(&success);
    TS_ASSERT(success);
    TS_ASSERT_EQUALS(derivedRef.attribute1, 666);
    TS_ASSERT_EQUALS(method1.call(inst4).value<string>(), "this is a test");

    Class test_3 = Class::lookup("ClassTest::Test3");

    ClassTest::Test3 t2(666);
    TS_ASSERT_EQUALS(t2.attribute1, 333);
    TS_ASSERT_EQUALS(t2.attribute3, 666);
    VariantValue inst5;
    inst5.construct<ClassTest::TestBase1&>(t2);
    VariantValue inst6 = test_3.castUp(inst5, base1);
    TS_ASSERT(inst6.isValid());
    success = false;
    ClassTest::Test3& derivedRef2 = inst6.convertTo<ClassTest::Test3&>(&success);
    TS_ASSERT(success);
    TS_ASSERT_EQUALS(derivedRef2.attribute1, 333);
    TS_ASSERT_EQUALS(derivedRef2.attribute3, 666);

    t2.attribute1 = 787;
    t2.attribute3 = 13;
    TS_ASSERT_EQUALS(derivedRef2.attribute1, 787);
    TS_ASSERT_EQUALS(derivedRef2.attribute3, 13);

    ClassTest::Test1 t3(666);
    VariantValue inst7;
    inst7.construct<ClassTest::TestBase1&>(t3);
    VariantValue inst8 = test_3.castUp(inst7, base1);
    TS_ASSERT(!inst8.isValid());

    Class test_2 = Class::lookup("ClassTest::Test2");
    VariantValue inst9 = test_2.castUp(inst7, base1);
    TS_ASSERT(!inst9.isValid());
}
Пример #6
0
void ClassTestSuite::testClass()
{
    //Class test = ClassOf<Test1>();

    Class test = Class::lookup("ClassTest::Test1");

    TS_ASSERT_EQUALS(test.simpleName(), "Test1");

    Class::ClassList superClasses = test.superclasses();

    TS_ASSERT_EQUALS(superClasses.size(), 2);

    Class base1;
    Class base2;

    TS_ASSERT_THROWS(base1.simpleName(), std::runtime_error); // uninitialized handle

    for(const Class& c: superClasses) {
        if (c.fullyQualifiedName() == "ClassTest::TestBase1") {
            base1 = c;
        } else if (c.fullyQualifiedName() == "ClassTest::TestBase2") {
            base2 = c;
        }
    }

    TS_ASSERT_EQUALS(base1.fullyQualifiedName(), "ClassTest::TestBase1");
    TS_ASSERT_EQUALS(base1.simpleName(), "TestBase1");
    TS_ASSERT_EQUALS(base2.fullyQualifiedName(), "ClassTest::TestBase2");
    TS_ASSERT_EQUALS(base2.simpleName(), "TestBase2");

    Class::ConstructorList base1Constructors = base1.constructors();
    TS_ASSERT_EQUALS(base1.constructors().size(), 1);

    Constructor base1Constructor = base1Constructors.front();

    TS_ASSERT_EQUALS(base1Constructor.numberOfArguments(), 0);
    TS_ASSERT_THROWS(base1Constructor.call(), std::runtime_error); // abstract class


    Class::ConstructorList base2Constructors = base2.constructors();
    TS_ASSERT_EQUALS(base2.constructors().size(), 1);

    Constructor base2Constructor = base2Constructors.front();

    TS_ASSERT_EQUALS(base2Constructor.numberOfArguments(), 0);

    VariantValue b2Inst = base2Constructor.call();
    TS_ASSERT(b2Inst.isValid());

    TS_ASSERT_EQUALS(base2.attributes().size(), 0);
    Class::MethodList base2Methods = base2.methods();
    TS_ASSERT_EQUALS(base2Methods.size(), 1);

    Method base2Method1 = base2Methods.front();

    TS_ASSERT_EQUALS(base2Method1.name(), "base2Method1");
    TS_ASSERT(base2Method1.isConst());
    TS_ASSERT(!base2Method1.isVolatile());
    TS_ASSERT(!base2Method1.isStatic());
    TS_ASSERT_EQUALS(base2Method1.numberOfArguments(), 0);
    TS_ASSERT_EQUALS(base2Method1.call(b2Inst).value<int>(), 6);


    Class::ConstructorList testConstructors = test.constructors();
    Class::AttributeList   attributes       = test.attributes();

    TS_ASSERT_EQUALS(attributes.size(), 2);
    Attribute attr = attributes.front();

    WITH_RTTI(TS_ASSERT(attr.type() == typeid(int)));

    TS_ASSERT_EQUALS(testConstructors.size(), 3);

    Constructor defaultConstr;
    Constructor intConstr;

    TS_ASSERT_THROWS(defaultConstr.argumentSpellings(), std::runtime_error);

    for (const Constructor& c: testConstructors) {
        if (c.numberOfArguments() == 0) {
            defaultConstr = c;
        } else if (c.numberOfArguments() == 1  && c.argumentSpellings()[0] == "int") {
            intConstr = c;
        }
    }


    TS_ASSERT_EQUALS(defaultConstr.numberOfArguments(), 0);
    TS_ASSERT_EQUALS(intConstr.numberOfArguments(), 1);

    VariantValue testInst1 = defaultConstr.call();

    TS_ASSERT(testInst1.isA<Test1>());

    TS_ASSERT_EQUALS(attr.get(testInst1).value<int>(), 3);


    VariantValue testInst2 = intConstr.call(77);

    TS_ASSERT(testInst2.isA<Test1>());
    TS_ASSERT_EQUALS(attr.get(testInst2).value<int>(), 77);

    Class::MethodList methods = test.methods();

    TS_ASSERT_EQUALS(methods.size(), 7);

    Method base1Method1;
    Method method1;
    Method method2;
    Method staticMethod;


    for (const Method& m: methods) {
        if (m.name() == "base1Method1") {
            base1Method1 = m;
        } else if (m.name() == "base2Method1") {
            base2Method1 = m;
        } else if (m.name() == "method1") {
            method1 = m;
        } else if (m.name() == "method2") {
            method2 = m;
        } else if (m.name() == "staticMethod") {
            staticMethod = m;
        }
    }

    TS_ASSERT_EQUALS(base1Method1.name(), "base1Method1");
    TS_ASSERT(!base1Method1.isConst());
    TS_ASSERT(!base1Method1.isStatic());
    TS_ASSERT(!base1Method1.isVolatile());
    WITH_RTTI(TS_ASSERT(base1Method1.returnType() == typeid(int)));
    TS_ASSERT_EQUALS(base1Method1.numberOfArguments(), 0);
    TS_ASSERT_EQUALS(base1Method1.call(testInst2).value<int>(), 5);

    TS_ASSERT_EQUALS(base2Method1.name(), "base2Method1");
    TS_ASSERT(base2Method1.isConst());
    TS_ASSERT(!base2Method1.isStatic());
    TS_ASSERT(!base2Method1.isVolatile());
    WITH_RTTI(TS_ASSERT(base2Method1.returnType() == typeid(int)));
    TS_ASSERT_EQUALS(base2Method1.numberOfArguments(), 0);
    TS_ASSERT_EQUALS(base2Method1.call(testInst2).value<int>(), 6);

    TS_ASSERT_EQUALS(method2.name(), "method2");
    TS_ASSERT(!method2.isConst());
    TS_ASSERT(!method2.isStatic());
    TS_ASSERT(!method2.isVolatile());
    WITH_RTTI(TS_ASSERT(method2.returnType() == typeid(double)));
    TS_ASSERT_EQUALS(method2.numberOfArguments(), 1);
    WITH_RTTI(TS_ASSERT(*method2.argumentTypes()[0] == typeid(double)));
    TS_ASSERT_EQUALS(method2.call(testInst2, 2).value<double>(), 6.28);

    TS_ASSERT_EQUALS(staticMethod.name(), "staticMethod");
    TS_ASSERT(!staticMethod.isConst());
    TS_ASSERT(staticMethod.isStatic());
    TS_ASSERT(!staticMethod.isVolatile());
    WITH_RTTI(TS_ASSERT(staticMethod.returnType() == typeid(double)));
    TS_ASSERT_EQUALS(staticMethod.numberOfArguments(), 0);
    TS_ASSERT_EQUALS(staticMethod.call().value<double>(), 3.14);
}