const QMetaObject *QSAEditor::queryQMetaObject( const QMetaObject *meta, const QString &property, bool /*includeSuperClass*/ ) const { const QMetaObject *m = meta; for (int i=0; i<m->methodCount(); ++i) { QMetaMethod mm = m->method(i); if (mm.methodType() == QMetaMethod::Slot) { QString n = QLatin1String(mm.methodSignature()); n = n.left(n.indexOf('(')); if (property != n) continue ; QByteArray retType(mm.typeName()); if (retType.count('*') == 1) { extern const QMetaObject *qsa_query_meta_object(const QByteArray &name); return qsa_query_meta_object(qsa_strip_stars(retType)); } } } return 0; }
// 函数的参数mouseP是局部坐标系下 VPAbstractNode::SlotInfoType VPAbstractNode::querySlot(const QPointF& localPos) { int retIdx(-1); SlotType retType(NONE); //QPointF localMousePos = mapFromScene(mouseP); for (int i(0); i<myInCount; i++) { if ( inputSlots[i]->area().contains(localPos) ) { retIdx = i; retType = IN; } } for (int i(0); i<myOutCount; i++) { if (outputSlots[i]->area().contains(localPos) ) { retIdx = i; retType = OUT; } } return SlotInfoType(retType, retIdx); }
TEST_F(FunctionTypeTests, CloningCreatesEqualFunctionType) { ShPtr<IntType> retType(IntType::create(16)); ShPtr<IntType> param1Type(IntType::create(32)); ShPtr<IntType> param2Type(IntType::create(64)); ShPtr<FunctionType> ft1(FunctionType::create(retType)); ft1->addParam(param1Type); ft1->addParam(param2Type); ft1->setVarArg(); ShPtr<FunctionType> ft2(ucast<FunctionType>(ft1->clone())); EXPECT_TRUE(ft1->isEqualTo(ft2)); }
TEST_F(FunctionTypeTests, TwoFunctionTypesWithSameDataAreEqual) { ShPtr<IntType> retType(IntType::create(16)); ShPtr<IntType> param1Type(IntType::create(32)); ShPtr<IntType> param2Type(IntType::create(64)); ShPtr<FunctionType> ft1(FunctionType::create(retType)); ft1->addParam(param1Type); ft1->addParam(param2Type); ft1->setVarArg(); ShPtr<FunctionType> ft2(FunctionType::create(retType)); ft2->addParam(param1Type); ft2->addParam(param2Type); ft2->setVarArg(); EXPECT_TRUE(ft1->isEqualTo(ft2)); }
//============================================================================== void MaterialProgramCreator::parseOperationTag( const XmlElement& operationTag, GLenum glshader, GLbitfield glshaderbit, MPString& out) { static const char OUT[] = {"out"}; // <id></id> I id = operationTag.getChildElement("id").getInt(); // <returnType></returnType> XmlElement retTypeEl = operationTag.getChildElement("returnType"); MPString retType(retTypeEl.getText(), m_alloc); MPString operationOut(m_alloc); if(retType != "void") { MPString tmp(MPString::toString(id, m_alloc)); operationOut = ANKI_STRL(OUT) + tmp; } // <function>functionName</function> MPString funcName( operationTag.getChildElement("function").getText(), m_alloc); // <arguments></arguments> XmlElement argsEl = operationTag.getChildElementOptional("arguments"); MPStringList argsList(m_alloc); if(argsEl) { // Get all arguments XmlElement argEl = argsEl.getChildElement("argument"); do { MPString arg(argEl.getText(), m_alloc); // Search for all the inputs and mark the appropriate Input* input = nullptr; for(Input& in : m_inputs) { // Check that the first part of the string is equal to the // variable and the following char is '[' if(in.m_name == arg) { input = ∈ in.m_shaderReferencedMask = glshaderbit; break; } } // The argument should be an input variable or an outXX if(!(input != nullptr || std::strncmp(&arg[0], OUT, sizeof(OUT) - 1) == 0)) { throw ANKI_EXCEPTION("Incorrect argument: %s", &arg[0]); } // Add to a list and do something special if instanced if(input && input->m_instanced) { if(glshader == GL_VERTEX_SHADER) { argsList.push_back(ANKI_STRL(argEl.getText()) + "[gl_InstanceID]"); m_instanceIdMask |= glshaderbit; } else if(glshader == GL_TESS_CONTROL_SHADER) { argsList.push_back(ANKI_STRL(argEl.getText()) + "[vInstanceId[0]]"); m_instanceIdMask |= glshaderbit; } else if(glshader == GL_TESS_EVALUATION_SHADER) { argsList.push_back(ANKI_STRL(argEl.getText()) + "[commonPatch.instanceId]"); m_instanceIdMask |= glshaderbit; } else if(glshader == GL_FRAGMENT_SHADER) { argsList.push_back(ANKI_STRL(argEl.getText()) + "[vInstanceId]"); m_instanceIdMask |= glshaderbit; } else { throw ANKI_EXCEPTION( "Cannot access the instance ID in all shaders"); } } else { argsList.push_back(MPString(argEl.getText(), m_alloc)); } // Advance argEl = argEl.getNextSiblingElement("argument"); } while(argEl); } // Now write everything MPString lines(m_alloc); lines.reserve(256); lines += "#if defined(" + funcName + "_DEFINED)"; // Write the defines for the operationOuts for(const MPString& arg : argsList) { if(arg.find(OUT) == 0) { lines += " && defined(" + arg + "_DEFINED)"; } } lines += "\n"; if(retType != "void") { lines += "#\tdefine " + operationOut + "_DEFINED\n\t" + retTypeEl.getText() + " " + operationOut + " = "; } else { lines += "\t"; } // write the blah = func(args...) lines += funcName + "("; lines += argsList.join(", "); lines += ");\n"; lines += "#endif"; // Done out = std::move(lines); }