int main(int argc, char *argv[]) { Page *page = pageFetch("http://www.cs.columbia.edu/~sedwards/"); // printf("%s\n", page->url); // printf("%s\n", page->html); NODE * first = pageFind(page, "#titlebar"); printf("id: %s\n",elementAttr((Element*)listHead(first), "id")); printf("text: %s\n",elementText((Element*)listHead(first))); printf("type: %s\n\n\n",elementType((Element*)listHead(first))); NODE *child_list = elementChildren(page, (Element*)listHead(first)); Element * e = (Element*)listHead(listTail(child_list)); printf("text first child: %s\n",elementText(e)); printf("type first child: %s\n",elementType(e)); printf("id first child: %s\n",elementAttr(e,"id")); // // NODE * first = listNew(); // listAddLast(first, "a"); // listAddLast(first, "b"); // listAddLast(first, "c"); // listAddLast(first, "c"); // listAddLast(first, "d"); // listAddLast(first, "e"); // listPrint(first); // printf("\n"); // list_remove(first,3); // // listPrint(first); // printf("\n"); // // NODE * newFirst = listNew(); // NODE * f = listAddLast(newFirst, "f"); // listAddAfter(f,"G"); // listAddLast(newFirst, "h"); // listConcate(first,newFirst); // listPrint(first); // printf("\n"); // listSet(f,"F Modified"); // listPrint(first); // // // printf("should be a: %s\n",listHead(first)); // printf("should be b: %s\n",listHead(listTail(first))); return 0; }
void WMConstraints::addBasisGroup(xmlNodePtr cur) { string sourceOpt("e"); string elementType("e"); OhmmsAttributeSet aAttrib; aAttrib.add(sourceOpt,"source"); aAttrib.add(elementType,"elementType"); aAttrib.put(cur); RealType rcut(myGrid->rmax()); map<string,BasisSetType*>::iterator it(myBasisSet.find(elementType)); if(it == myBasisSet.end()) { BasisSetType* newBasis=new BasisSetType; cur=cur->children; while(cur != NULL) { string cname((const char*)(cur->name)); if(cname == "parameter") { //BasisType* a=new BasisType(1.0,rcut); WMFunctor<RealType>* a = new WMFunctor<RealType>(1.0,rcut); a->put(cur); newBasis->push_back(a); } cur=cur->next; } //add a new BasisSet myBasisSet[elementType]=newBasis; } }
UIGInformationElementPreview::UIGInformationElementPreview(UIGInformationSet *pParent, bool fOpened) : UIGInformationElement(pParent, DetailsElementType_Preview, fOpened) { /* Assign corresponding icon: */ setIcon(gpConverter->toIcon(elementType())); /* Create layout: */ QGraphicsLinearLayout *pLayout = new QGraphicsLinearLayout; AssertPtr(pLayout); { /* Prepare layout: */ const int iMargin = data(ElementData_Margin).toInt(); pLayout->setContentsMargins(iMargin, 2 * iMargin + minimumHeaderHeight(), iMargin, iMargin); /* Assign layout to widget: */ setLayout(pLayout); /* Create preview: */ m_pPreview = new UIGInformationPreview(this); AssertPtr(m_pPreview); { /* Prepare preview: */ connect(m_pPreview, SIGNAL(sigSizeHintChanged()), this, SLOT(sltPreviewSizeHintChanged())); /* Add preview into layout: */ pLayout->addItem(m_pPreview); } } /* Set fixed size policy finally (after all content constructed): */ setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); /* Translate finally: */ retranslateUi(); }
//----------------------------------------------------------------------------- // Function: PortComparator::diffFields() //----------------------------------------------------------------------------- QList<QSharedPointer<IPXactDiff> > PortComparator::diffFields(QSharedPointer<const Port> reference, QSharedPointer<const Port> subject) const { QSharedPointer<IPXactDiff> portDiff(new IPXactDiff(elementType(), reference->getName())); portDiff->setChangeType(IPXactDiff::MODIFICATION); portDiff->checkForChange("port access type", reference->getPortAccessType(), subject->getPortAccessType()); portDiff->checkForChange("type name", reference->getTypeName(), subject->getTypeName()); portDiff->checkForChange("type definitions", reference->getTypeDefinitions().join(", "), subject->getTypeDefinitions().join(", ")); portDiff->checkForChange("default value", reference->getDefaultValue(), subject->getDefaultValue()); portDiff->checkForChange("direction", General::direction2Str(reference->getDirection()), General::direction2Str(subject->getDirection())); portDiff->checkForChange("left bound", reference->getLeftBoundExpression(), subject->getLeftBoundExpression()); portDiff->checkForChange("right bound", reference->getRightBoundExpression(), subject->getRightBoundExpression()); QList<QSharedPointer<IPXactDiff> > list; list.append(portDiff); return list; }
void ArrayDeclarationAST::typeCheck(TypeChecker& checker) { mLengthExpression->typeCheck(checker); //Check length checker.assertSameType( *checker.makeType("Int"), *mLengthExpression->expressionType(checker), "Expected the length to be of type 'Int'."); //Check if the element type exists checker.assertTypeExists(elementType(), false); checker.assertNotVoid(*checker.findType(elementType()), "Arrays of type 'Void' is not allowed."); //Create the array type if not created checker.makeType(elementType() + "[]"); }
std::string MultiDimArrayDeclarationAST::asString() const { auto lengthsStr = Helpers::join<std::shared_ptr<ExpressionAST>>( mLengthExpressions, [](std::shared_ptr<ExpressionAST> length) { return length->asString(); }, ", "); return "new " + elementType() + "[" + lengthsStr + "]"; }
void DrawExecution::drawElements() const { gl::glBindVertexArray(m_drawImpl.glVertexArray); gl::glDrawElements(m_drawImpl.state.rasterizerState().primitive(), elementCount(), elementType(), nullptr); }
bool HbXmlLoaderBaseSyntax::checkEndElementCorrectness() { if ( !mActions->pop( elementType( mReader.name() ) ) ) { qWarning() << "Error in end element, line " << mReader.lineNumber(); return false; } return true; }
// Recursively figure out how many bytes of xfb buffer are used by the given type. // Return the size of type, in bytes. // Sets containsDouble to true if the type contains a double. // N.B. Caller must set containsDouble to false before calling. unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& containsDouble) const { // "...if applied to an aggregate containing a double, the offset must also be a multiple of 8, // and the space taken in the buffer will be a multiple of 8. // ...within the qualified entity, subsequent components are each // assigned, in order, to the next available offset aligned to a multiple of // that component's size. Aggregate types are flattened down to the component // level to get this sequence of components." if (type.isArray()) { // TODO: perf: this can be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness assert(type.isExplicitlySizedArray()); TType elementType(type, 0); return type.getOuterArraySize() * computeTypeXfbSize(elementType, containsDouble); } if (type.isStruct()) { unsigned int size = 0; bool structContainsDouble = false; for (int member = 0; member < (int)type.getStruct()->size(); ++member) { TType memberType(type, member); // "... if applied to // an aggregate containing a double, the offset must also be a multiple of 8, // and the space taken in the buffer will be a multiple of 8." bool memberContainsDouble = false; int memberSize = computeTypeXfbSize(memberType, memberContainsDouble); if (memberContainsDouble) { structContainsDouble = true; RoundToPow2(size, 8); } size += memberSize; } if (structContainsDouble) { containsDouble = true; RoundToPow2(size, 8); } return size; } int numComponents; if (type.isScalar()) numComponents = 1; else if (type.isVector()) numComponents = type.getVectorSize(); else if (type.isMatrix()) numComponents = type.getMatrixCols() * type.getMatrixRows(); else { assert(0); numComponents = 1; } if (type.getBasicType() == EbtDouble) { containsDouble = true; return 8 * numComponents; } else return 4 * numComponents; }
//! adds an element to the environment based on its type name IGUIElement* CGUIEditFactory::addGUIElement(const c8* typeName, IGUIElement* parent) { /* here we create elements, add them to the manager, and then drop them */ core::stringc elementType(typeName); IGUIElement* ret=0; if (!parent) parent = Environment->getRootGUIElement(); // editor workspace if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIEDIT])) ret = new CGUIEditWorkspace(Environment, -1, 0); // editor window else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIEDITWINDOW])) ret = new CGUIEditWindow(Environment, core::rect<s32>(0,0,100,100), 0); // Klasker's GUI Panel else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIPANEL])) ret = new CGUIPanel(Environment, 0); // texture cache browser else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_TEXTUREBROWSER])) ret = new CGUITextureCacheBrowser(Environment, -1, 0); // block of attribute editors else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_ATTRIBUTEEDITOR])) ret = new CGUIAttributeEditor(Environment, -1, 0); //! single attribute editors else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_STRINGATTRIBUTE])) ret = new CGUIStringAttribute(Environment, 0, -1); else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_BOOLATTRIBUTE])) ret = new CGUIBoolAttribute(Environment, 0, -1); else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_ENUMATTRIBUTE])) ret = new CGUIEnumAttribute(Environment, 0, -1); else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORATTRIBUTE])) ret = new CGUIColorAttribute(Environment, 0, -1); else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORFATTRIBUTE])) ret = new CGUIColorAttribute(Environment, 0, -1); else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_TEXTUREATTRIBUTE])) ret = new CGUITextureAttribute(Environment, 0, -1); // stubs and custom editors else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_CONTEXTMENUEDITOR]) || elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_MENUEDITOR]) || elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_FILEDIALOGEDITOR]) || elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORDIALOGEDITOR]) || elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_MODALSCREENEDITOR]) ) ret = new CGUIDummyEditorStub(Environment, 0, typeName); // add the element to its parent if (ret) parent->addChild(ret); // the environment now has the reference, so we can drop the element if (ret) ret->drop(); return ret; }
// Accumulate locations used for inputs, outputs, and uniforms, and check for collisions // as the accumulation is done. // // Returns < 0 if no collision, >= 0 if collision and the value returned is a colliding value. // // typeCollision is set to true if there is no direct collision, but the types in the same location // are different. // int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& type, bool& typeCollision) { typeCollision = false; int set; if (qualifier.isPipeInput()) set = 0; else if (qualifier.isPipeOutput()) set = 1; else if (qualifier.storage == EvqUniform) set = 2; else if (qualifier.storage == EvqBuffer) set = 3; else return -1; int size; if (qualifier.isUniformOrBuffer()) { if (type.isArray()) size = type.getCumulativeArraySize(); else size = 1; } else { // Strip off the outer array dimension for those having an extra one. if (type.isArray() && qualifier.isArrayedIo(language)) { TType elementType(type, 0); size = computeTypeLocationSize(elementType); } else size = computeTypeLocationSize(type); } TRange locationRange(qualifier.layoutLocation, qualifier.layoutLocation + size - 1); TRange componentRange(0, 3); if (qualifier.hasComponent()) { componentRange.start = qualifier.layoutComponent; componentRange.last = componentRange.start + type.getVectorSize() - 1; } TIoRange range(locationRange, componentRange, type.getBasicType(), qualifier.hasIndex() ? qualifier.layoutIndex : 0); // check for collisions, except for vertex inputs on desktop if (! (profile != EEsProfile && language == EShLangVertex && qualifier.isPipeInput())) { for (size_t r = 0; r < usedIo[set].size(); ++r) { if (range.overlap(usedIo[set][r])) { // there is a collision; pick one return std::max(locationRange.start, usedIo[set][r].location.start); } else if (locationRange.overlap(usedIo[set][r].location) && type.getBasicType() != usedIo[set][r].basicType) { // aliased-type mismatch typeCollision = true; return std::max(locationRange.start, usedIo[set][r].location.start); } } } usedIo[set].push_back(range); return -1; // no collision }
void JastrowBasisBuilder::createLocalizedBasisSet(xmlNodePtr cur) { typedef typename RFBUILDER::CenteredOrbitalType COT; typedef LocalizedBasisSet<COT> ThisBasisSetType; ThisBasisSetType* curBasis= new ThisBasisSetType(sourcePtcl,targetPtcl); //create the basis set //go thru the tree cur = cur->xmlChildrenNode; while(cur!=NULL) { string cname((const char*)(cur->name)); if(cname == "atomicBasisSet") { const xmlChar* eptr=xmlGetProp(cur,(const xmlChar*)"elementType"); if(eptr == NULL) { app_error() << " Missing elementType attribute of atomicBasisSet.\n Abort at MOBasisBuilder::put " << endl; OHMMS::Controller->abort(); } string elementType((const char*)eptr); map<string,BasisSetBuilder*>::iterator it = aoBuilders.find(elementType); if(it == aoBuilders.end()) { AtomicBasisBuilder<RFBUILDER>* any = new AtomicBasisBuilder<RFBUILDER>(elementType); any->put(cur); COT* aoBasis= any->createAOSet(cur); if(aoBasis) { //add the new atomic basis to the basis set int activeCenter =sourcePtcl.getSpeciesSet().findSpecies(elementType); curBasis->add(activeCenter, aoBasis); aoBuilders[elementType]=any; #if !defined(HAVE_MPI) string fname(elementType); fname.append(".j3.dat"); ofstream fout(fname.c_str()); int nr=aoBasis->Rnl.size(); double r=0.0; while(r<20) { fout << r ; for(int i=0; i<nr; i++) fout << " " << aoBasis->Rnl[i]->evaluate(r,1.0/r); fout << endl; r += 0.013; } #endif } } } cur = cur->next; } //resize the basis set curBasis->setBasisSetSize(-1); myBasisSet=curBasis; }
/* Sometimes, an element only exists in a collection (as a value). But Smoke will include a type for it in pointer (*) form. */ SmokeType findElementType(Smoke *smoke, const char *name) { SmokeType elementType(smoke, name); if (elementType.isVoid()) { QByteArray typeName(name); typeName.append("*"); elementType = SmokeType(smoke, typeName.constData()); if (elementType.isVoid()) error("Cannot type for element: %s", name); } return elementType; }
void loadElementsFromConfigFile( orcaqgemv::GuiElementModel &guiElementModel, const orcaice::Context &context ) { // create a map of types const string typePrefix = context.tag() + ".Config.Element.Type"; std::map<string,string> typeMap = context.properties()->getPropertiesForPrefix(typePrefix); // create a map of descriptions const string descriptionPrefix = context.tag() + ".Config.Element.Description"; std::map<string,string> descriptionMap = context.properties()->getPropertiesForPrefix(descriptionPrefix); // debug output for ( map<string,string>::iterator it=typeMap.begin(); it!=typeMap.end(); ++it ) { stringstream ss; ss << "it->first: " << it->first << endl; ss << "it->second: " << it->second << endl; context.tracer().debug( ss.str(), 5 ); } // create elements based on Type entries for ( map<string,string>::iterator it = typeMap.begin(); it != typeMap.end(); ++it ) { // extract the key: e.g. for Config.Element.TypeXX the key is XX QString elementType( it->second.c_str() ); string key = it->first.substr( typePrefix.size() ); stringstream ss; ss << "Extracted key is: " << key; context.tracer().debug( ss.str(), 5 ); // find the corresponding entry in the descriptionMap map<string,string>::iterator descriptionMapIt = descriptionMap.find( context.tag() + ".Config.Element.Description" + key ); if ( descriptionMapIt==descriptionMap.end() ) { ss.str(""); ss << "'Description' entry with key " << key << " expected. Check your config file!"; context.tracer().warning( ss.str() ); continue; } // found an entry ss.str(""); ss << "Found Description entry: " << descriptionMapIt->second; context.tracer().debug( ss.str(), 5 ); // // assemble all pieces to create the GUI element // QString elementDescription( descriptionMapIt->second.c_str() ); QString uniqueId = extractUniqueId( elementDescription ); QString platformName = extractPlatformName( elementDescription ); guiElementModel.createGuiElement( elementType, elementDescription, platformName, uniqueId ); } }
void ArraySetElementAST::generateCode(CodeGenerator& codeGen, GeneratedFunction& func, std::shared_ptr<Type> elementType) { if (elementType == nullptr) { auto arrayRefType = std::dynamic_pointer_cast<ArrayType>(mArrayRefExpression->expressionType(codeGen.typeChecker())); mArrayRefExpression->generateCode(codeGen, func); elementType = arrayRefType->elementType(); } mAccessExpression->generateCode(codeGen, func); mRightHandSide->generateCode(codeGen, func); func.addInstruction("STELEM " + elementType->vmType()); }
FuncSpaceData FuncSpaceData::getForNonSerendipitySpace() const { if(!_serendipity) return *this; int type = elementType(); bool serendip = false; if(type == TYPE_PYR) return FuncSpaceData(true, _tag, _pyramidalSpace, _nij, _nk, &serendip); else return FuncSpaceData(true, _tag, _spaceOrder, &serendip); }
// Recursively figure out how many locations are used up by an input or output type. // Return the size of type, as measured by "locations". int TIntermediate::computeTypeLocationSize(const TType& type) const { // "If the declared input is an array of size n and each element takes m locations, it will be assigned m * n // consecutive locations..." if (type.isArray()) { // TODO: perf: this can be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness TType elementType(type, 0); if (type.isImplicitlySizedArray()) { // TODO: are there valid cases of having an implicitly-sized array with a location? If so, running this code too early. return computeTypeLocationSize(elementType); } else return type.getOuterArraySize() * computeTypeLocationSize(elementType); } // "The locations consumed by block and structure members are determined by applying the rules above // recursively..." if (type.isStruct()) { int size = 0; for (int member = 0; member < (int)type.getStruct()->size(); ++member) { TType memberType(type, member); size += computeTypeLocationSize(memberType); } return size; } // ES: "If a shader input is any scalar or vector type, it will consume a single location." // Desktop: "If a vertex shader input is any scalar or vector type, it will consume a single location. If a non-vertex // shader input is a scalar or vector type other than dvec3 or dvec4, it will consume a single location, while // types dvec3 or dvec4 will consume two consecutive locations. Inputs of type double and dvec2 will // consume only a single location, in all stages." if (type.isScalar()) return 1; if (type.isVector()) { if (language == EShLangVertex && type.getQualifier().isPipeInput()) return 1; if (type.getBasicType() == EbtDouble && type.getVectorSize() > 2) return 2; else return 1; } // "If the declared input is an n x m single- or double-precision matrix, ... // The number of locations assigned for each matrix will be the same as // for an n-element array of m-component vectors..." if (type.isMatrix()) { TType columnType(type, 0); return type.getMatrixCols() * computeTypeLocationSize(columnType); } assert(0); return 1; }
FuncSpaceData FuncSpaceData::getForPrimaryElement() const { int type = elementType(); int primTag = ElementType::getType(type, 1, elementIsOnlySerendipity()); if(primTag == _tag) return *this; if(type == TYPE_PYR) return FuncSpaceData(true, primTag, _pyramidalSpace, _nij, _nk, &_serendipity); else return FuncSpaceData(true, primTag, _spaceOrder, &_serendipity); }
std::string MultiDimArrayDeclarationAST::typeString(int dim) const { std::string arrayRankStr = ""; if (dim == -1) { dim = mLengthExpressions.size(); } for (int i = 0; i < dim; i++) { arrayRankStr += "[]"; } return elementType() + arrayRankStr; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RigFemPart::calculateNodeToElmRefs() { m_nodeToElmRefs.resize(nodes().nodeIds.size()); for (int eIdx = 0; eIdx < static_cast<int>(m_elementId.size()); ++eIdx) { int elmNodeCount = RigFemTypes::elmentNodeCount(elementType(eIdx)); const int* elmNodes = connectivities(eIdx); for (int enIdx = 0; enIdx < elmNodeCount; ++enIdx) { m_nodeToElmRefs[elmNodes[enIdx]].push_back(eIdx); } } }
UIGInformationElementInterface::UIGInformationElementInterface(UIGInformationSet *pParent, DetailsElementType type, bool fOpened) : UIGInformationElement(pParent, type, fOpened) , m_pTask(0) { /* Assign corresponding icon: */ setIcon(gpConverter->toIcon(elementType())); /* Listen for the global thread-pool: */ connect(vboxGlobal().threadPool(), SIGNAL(sigTaskComplete(UITask*)), this, SLOT(sltUpdateAppearanceFinished(UITask*))); /* Translate finally: */ retranslateUi(); }
void MultiDimArrayDeclarationAST::typeCheck(TypeChecker& checker) { for (auto lengthExpr : mLengthExpressions) { lengthExpr->typeCheck(checker); } //Check lengths int dim = 0; for (auto lengthExpr : mLengthExpressions) { checker.assertSameType( *checker.makeType("Int"), *lengthExpr->expressionType(checker), "Expected the length of dimension " + std::to_string(dim) + " to be of type 'Int'."); dim++; } //Check if the element type exists checker.assertTypeExists(elementType(), false); checker.assertNotVoid(*checker.findType(elementType()), "Arrays of type 'Void' is not allowed."); //Create all array types for (int i = 0; i < mLengthExpressions.size(); i++) { checker.makeType(typeString(i)); } }
void PolyConstraints::addSingleBasisPerSpecies(xmlNodePtr cur) { RealType rcut=10.0; int npts=101; RealType step=-1.0; if(myGrid) { rcut=myGrid->rmax(); npts = myGrid->size(); } OhmmsAttributeSet gAttrib; gAttrib.add(rcut,"rf"); BasisGroupType* curBG=0; cur=cur->children; while(cur != NULL) { string cname((const char*)(cur->name)); string elementType("e"); OhmmsAttributeSet aAttrib; aAttrib.add(elementType,"elementType"); aAttrib.put(cur); if(cname == "atomicBasisSet") { xmlNodePtr cur1=cur->children; while(cur1 != NULL) { string cname1((const char*)(cur1->name)); if(cname1 == "basisGroup") { createBasisGroup(cur1,elementType,rcut); } else if(cname1 == "grid") { gAttrib.put(cur1); } cur1=cur1->next; } } else if(cname == "basisGroup") { createBasisGroup(cur,elementType,rcut); } else if(cname == "grid") gAttrib.put(cur); cur=cur->next; } }
rapidjson::Value Element::toJsonValue(rapidjson::Document& d) const { rapidjson::Value result(rapidjson::kObjectType); auto& al = d.GetAllocator(); result.AddMember("id", id_.toStr(), al); rapidjson::Value idsArray(rapidjson::kArrayType); for (const core::UID& id : tag_ids_) { const std::string& str_id = id.toStr(); rapidjson::Value s; s.SetString(str_id, al); idsArray.PushBack(s, al); } result.AddMember("tag_ids", idsArray, al); result.AddMember("type", elementType(), al); return result; }
//----------------------------------------------------------------------------- // Function: ModelParameterComparator::diffFields() //----------------------------------------------------------------------------- QList<QSharedPointer<IPXactDiff> > ModelParameterComparator::diffFields(QSharedPointer<const ModelParameter> reference, QSharedPointer<const ModelParameter> subject) const { QList<QSharedPointer<IPXactDiff> > diffResult; QSharedPointer<IPXactDiff> modification(new IPXactDiff(elementType(), reference->getName())); modification->setChangeType(IPXactDiff::MODIFICATION); modification->checkForChange("description", reference->getDescription(), subject->getDescription()); modification->checkForChange("type", reference->getType(), subject->getType()); modification->checkForChange("value", reference->getValue(), subject->getValue()); modification->checkForChange("data type", reference->getDataType(), subject->getDataType()); modification->checkForChange("minimum value", reference->getMinimumValue(), subject->getMinimumValue()); modification->checkForChange("maximum value", reference->getMaximumValue(), subject->getMaximumValue()); modification->checkForChange("usage type", reference->getUsageType(), subject->getUsageType()); modification->checkForChange("resolve", reference->getValueResolve(), subject->getValueResolve()); diffResult.append(modification); return diffResult; }
void FuncSpaceData::getOrderForBezier(int order[3], int exponentZ) const { if(_pyramidalSpace && exponentZ < 0) { Msg::Error("getOrderForBezier needs third exponent for pyramidal space!"); order[0] = order[1] = order[2] = -1; return; } if(elementType() == TYPE_PYR) { if(_pyramidalSpace) { order[0] = order[1] = _nij + exponentZ; order[2] = _nk; } else { order[0] = order[1] = _nij; order[2] = _nk; } } else order[0] = order[1] = order[2] = _spaceOrder; }
int resolveInOutLocation(EShLanguage stage, const char* /*name*/, const TType& type, bool /*is_live*/) override { // kick out of not doing this if (!doAutoLocationMapping()) return -1; // no locations added if already present, or a built-in variable if (type.getQualifier().hasLocation() || type.isBuiltIn()) return -1; // no locations on blocks of built-in variables if (type.isStruct()) { if (type.getStruct()->size() < 1) return -1; if ((*type.getStruct())[0].type->isBuiltIn()) return -1; } // point to the right input or output location counter int& nextLocation = type.getQualifier().isPipeInput() ? nextInputLocation : nextOutputLocation; // Placeholder. This does not do proper cross-stage lining up, nor // work with mixed location/no-location declarations. int location = nextLocation; int typeLocationSize; // Don’t take into account the outer-most array if the stage’s // interface is automatically an array. if (type.getQualifier().isArrayedIo(stage)) { TType elementType(type, 0); typeLocationSize = TIntermediate::computeTypeLocationSize(elementType, stage); } else { typeLocationSize = TIntermediate::computeTypeLocationSize(type, stage); } nextLocation += typeLocationSize; return location; }
void ArraySetElementAST::typeCheck(TypeChecker& checker) { mArrayRefExpression->typeCheck(checker); mAccessExpression->typeCheck(checker); mRightHandSide->typeCheck(checker); //Check if array auto arrayRefType = std::dynamic_pointer_cast<ArrayType>(mArrayRefExpression->expressionType(checker)); if (arrayRefType == nullptr) { checker.typeError("The expression '" + mArrayRefExpression->asString() + "' is not of array type."); } //Access access checker.assertSameType( *checker.makeType("Int"), *mAccessExpression->expressionType(checker), "Expected the array indexing to be of type 'Int'."); //Check rhs checker.assertSameType( *arrayRefType->elementType(), *mRightHandSide->expressionType(checker), asString()); }
/*** initTokens($offset) ***/ $ref(output, $offset) = $convert_$elementType(initialOutputs)_$cgType(output)($val(initialOutputs, $offset)); $send(output, 0) /**/ /***fireBlock***/ $get(input, 0) $ref(output) = $ref(input); $send(output, 0) /**/
void QStyleItem::initStyleOption() { QString type = elementType(); if (m_styleoption) m_styleoption->state = 0; switch (m_itemType) { case Button: { if (!m_styleoption) m_styleoption = new QStyleOptionButton(); QStyleOptionButton *opt = qstyleoption_cast<QStyleOptionButton*>(m_styleoption); opt->text = text(); opt->features = (activeControl() == "default") ? QStyleOptionButton::DefaultButton : QStyleOptionButton::None; } break; case ItemRow: { if (!m_styleoption) m_styleoption = new QStyleOptionViewItem(); QStyleOptionViewItem *opt = qstyleoption_cast<QStyleOptionViewItem*>(m_styleoption); opt->features = 0; if (activeControl() == "alternate") opt->features |= QStyleOptionViewItem::Alternate; } break; case Splitter: { if (!m_styleoption) { m_styleoption = new QStyleOption; } } break; case Item: { if (!m_styleoption) { m_styleoption = new QStyleOptionViewItem(); } QStyleOptionViewItem *opt = qstyleoption_cast<QStyleOptionViewItem*>(m_styleoption); opt->features = QStyleOptionViewItem::HasDisplay; opt->text = text(); opt->textElideMode = Qt::ElideRight; QPalette pal = m_styleoption->palette; pal.setBrush(QPalette::Base, Qt::NoBrush); m_styleoption->palette = pal; } break; case Header: { if (!m_styleoption) m_styleoption = new QStyleOptionHeader(); QStyleOptionHeader *opt = qstyleoption_cast<QStyleOptionHeader*>(m_styleoption); opt->text = text(); opt->sortIndicator = activeControl() == "down" ? QStyleOptionHeader::SortDown : activeControl() == "up" ? QStyleOptionHeader::SortUp : QStyleOptionHeader::None; if (info() == QLatin1String("beginning")) opt->position = QStyleOptionHeader::Beginning; else if (info() == QLatin1String("end")) opt->position = QStyleOptionHeader::End; else if (info() == QLatin1String("only")) opt->position = QStyleOptionHeader::OnlyOneSection; else opt->position = QStyleOptionHeader::Middle; } break; case ToolButton: { if (!m_styleoption) m_styleoption = new QStyleOptionToolButton(); QStyleOptionToolButton *opt = qstyleoption_cast<QStyleOptionToolButton*>(m_styleoption); opt->subControls = QStyle::SC_ToolButton; opt->state |= QStyle::State_AutoRaise; opt->activeSubControls = QStyle::SC_ToolButton; } break; case ToolBar: { if (!m_styleoption) m_styleoption = new QStyleOptionToolBar(); } break; case Tab: { if (!m_styleoption) m_styleoption = new QStyleOptionTab(); QStyleOptionTab *opt = qstyleoption_cast<QStyleOptionTab*>(m_styleoption); opt->text = text(); opt->shape = info() == "South" ? QTabBar::RoundedSouth : QTabBar::RoundedNorth; if (activeControl() == QLatin1String("beginning")) opt->position = QStyleOptionTab::Beginning; else if (activeControl() == QLatin1String("end")) opt->position = QStyleOptionTab::End; else if (activeControl() == QLatin1String("only")) opt->position = QStyleOptionTab::OnlyOneTab; else opt->position = QStyleOptionTab::Middle; } break; case Menu: { if (!m_styleoption) m_styleoption = new QStyleOptionMenuItem(); } break; case Frame: { if (!m_styleoption) m_styleoption = new QStyleOptionFrame(); QStyleOptionFrame *opt = qstyleoption_cast<QStyleOptionFrame*>(m_styleoption); opt->frameShape = QFrame::StyledPanel; opt->lineWidth = 1; opt->midLineWidth = 1; } break; case TabFrame: { if (!m_styleoption) m_styleoption = new QStyleOptionTabWidgetFrame(); QStyleOptionTabWidgetFrame *opt = qstyleoption_cast<QStyleOptionTabWidgetFrame*>(m_styleoption); opt->shape = (info() == "South") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth; if (minimum()) opt->selectedTabRect = QRect(value(), 0, minimum(), height()); opt->tabBarSize = QSize(minimum() , height()); // oxygen style needs this hack opt->leftCornerWidgetSize = QSize(value(), 0); } break; case MenuItem: case ComboBoxItem: { if (!m_styleoption) m_styleoption = new QStyleOptionMenuItem(); QStyleOptionMenuItem *opt = qstyleoption_cast<QStyleOptionMenuItem*>(m_styleoption); opt->checked = false; opt->text = text(); } break; case CheckBox: case RadioButton: { if (!m_styleoption) m_styleoption = new QStyleOptionButton(); QStyleOptionButton *opt = qstyleoption_cast<QStyleOptionButton*>(m_styleoption); if (!on()) opt->state |= QStyle::State_Off; opt->text = text(); } break; case Edit: { if (!m_styleoption) m_styleoption = new QStyleOptionFrame(); QStyleOptionFrame *opt = qstyleoption_cast<QStyleOptionFrame*>(m_styleoption); opt->lineWidth = 1; // this must be non-zero } break; case ComboBox :{ if (!m_styleoption) m_styleoption = new QStyleOptionComboBox(); QStyleOptionComboBox *opt = qstyleoption_cast<QStyleOptionComboBox*>(m_styleoption); opt->currentText = text(); } break; case SpinBox: { if (!m_styleoption) m_styleoption = new QStyleOptionSpinBox(); QStyleOptionSpinBox *opt = qstyleoption_cast<QStyleOptionSpinBox*>(m_styleoption); opt->frame = true; if (value() & 0x1) opt->activeSubControls = QStyle::SC_SpinBoxUp; else if (value() & (1<<1)) opt->activeSubControls = QStyle::SC_SpinBoxDown; opt->subControls = QStyle::SC_All; opt->stepEnabled = 0; if (value() & (1<<2)) opt->stepEnabled |= QAbstractSpinBox::StepUpEnabled; if (value() & (1<<3)) opt->stepEnabled |= QAbstractSpinBox::StepDownEnabled; } break; case Slider: case Dial: { if (!m_styleoption) m_styleoption = new QStyleOptionSlider(); QStyleOptionSlider *opt = qstyleoption_cast<QStyleOptionSlider*>(m_styleoption); opt->minimum = minimum(); opt->maximum = maximum(); opt->sliderPosition = value(); opt->singleStep = step(); if (opt->singleStep) { qreal numOfSteps = (opt->maximum - opt->minimum) / opt->singleStep; // at least 5 pixels between tick marks if (numOfSteps && (width() / numOfSteps < 5)) opt->tickInterval = qRound((5*numOfSteps / width()) + 0.5)*step(); else opt->tickInterval = opt->singleStep; } else // default Qt-components implementation opt->tickInterval = opt->maximum != opt->minimum ? 1200 / (opt->maximum - opt->minimum) : 0; opt->sliderValue = value(); opt->subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle; opt->tickPosition = (activeControl() == "tick" ? QSlider::TicksBelow : QSlider::NoTicks); if (opt->tickPosition != QSlider::NoTicks) opt->subControls |= QStyle::SC_SliderTickmarks; opt->activeSubControls = QStyle::SC_None; } break; case ProgressBar: { if (!m_styleoption) m_styleoption = new QStyleOptionProgressBar(); QStyleOptionProgressBar *opt = qstyleoption_cast<QStyleOptionProgressBar*>(m_styleoption); opt->orientation = horizontal() ? Qt::Horizontal : Qt::Vertical; opt->minimum = minimum(); opt->maximum = maximum(); opt->progress = value(); } break; case GroupBox: { if (!m_styleoption) m_styleoption = new QStyleOptionGroupBox(); QStyleOptionGroupBox *opt = qstyleoption_cast<QStyleOptionGroupBox*>(m_styleoption); opt->text = text(); opt->lineWidth = 1; opt->subControls = QStyle::SC_GroupBoxLabel; opt->features = 0; if (sunken()) { // Qt draws an ugly line here so I ignore it opt->subControls |= QStyle::SC_GroupBoxFrame; } else { opt->features |= QStyleOptionFrame::Flat; } if (activeControl() == "checkbox") opt->subControls |= QStyle::SC_GroupBoxCheckBox; } break; case ScrollBar: { if (!m_styleoption) m_styleoption = new QStyleOptionSlider(); QStyleOptionSlider *opt = qstyleoption_cast<QStyleOptionSlider*>(m_styleoption); opt->minimum = minimum(); opt->maximum = maximum(); opt->pageStep = qMax(0, int(horizontal() ? width() : height())); opt->orientation = horizontal() ? Qt::Horizontal : Qt::Vertical; opt->sliderPosition = value(); opt->sliderValue = value(); opt->activeSubControls = (activeControl() == QLatin1String("up")) ? QStyle::SC_ScrollBarSubLine : (activeControl() == QLatin1String("down")) ? QStyle::SC_ScrollBarAddLine: QStyle::SC_ScrollBarSlider; opt->sliderValue = value(); opt->subControls = QStyle::SC_All; } case MenuBar: if (!m_styleoption) { QStyleOptionMenuItem *menuOpt = new QStyleOptionMenuItem(); menuOpt->menuItemType = QStyleOptionMenuItem::EmptyArea; m_styleoption = menuOpt; } break; case MenuBarItem: if (!m_styleoption) { QStyleOptionMenuItem *menuOpt = new QStyleOptionMenuItem(); menuOpt->text = text(); menuOpt->menuItemType = QStyleOptionMenuItem::Normal; m_styleoption = menuOpt; } break; default: break; } if (!m_styleoption) m_styleoption = new QStyleOption(); m_styleoption->styleObject = this; m_styleoption->rect = QRect(m_paintMargins, m_paintMargins, width() - 2* m_paintMargins, height() - 2 * m_paintMargins); if (isEnabled()) m_styleoption->state |= QStyle::State_Enabled; if (m_active) m_styleoption->state |= QStyle::State_Active; if (m_sunken) m_styleoption->state |= QStyle::State_Sunken; if (m_raised) m_styleoption->state |= QStyle::State_Raised; if (m_selected) m_styleoption->state |= QStyle::State_Selected; if (m_focus) m_styleoption->state |= QStyle::State_HasFocus; if (m_on) m_styleoption->state |= QStyle::State_On; if (m_hover) m_styleoption->state |= QStyle::State_MouseOver; if (m_horizontal) m_styleoption->state |= QStyle::State_Horizontal; if (m_hint.indexOf("mini") != -1) { m_styleoption->state |= QStyle::State_Mini; } else if (m_hint.indexOf("small") != -1) { m_styleoption->state |= QStyle::State_Small; } }