/** * @brief Binalize of the entity * @param Size of binalized data * @return Binalized data */ char *SimObjBase::toBinary(int &n) { const int RESIZE = 1000; static int bufsize = RESIZE; static char *buf = new char[bufsize]; char *p = buf; p += sizeof(DataLengthType); // skip datalen BINARY_SET_DATA_L_INCR(p, Id, id()); BINARY_SET_STRING_INCR(p, name()); BINARY_SET_STRING_INCR(p, classname()); short attached = isAttached(); BINARY_SET_DATA_S_INCR(p, short, attached); BINARY_SET_DATA_L_INCR(p, Operation, m_ops); DataOffsetType ao_offset = p - buf; BINARY_SET_DATA_S_INCR(p, DataOffsetType, 0); // skip attr offset DataOffsetType bo_offset = p - buf; BINARY_SET_DATA_S_INCR(p, DataOffsetType, 0); // skip body offset // attrs { DataOffsetType attrs_offset = p - buf; BINARY_SET_DATA_S(buf + ao_offset, DataOffsetType, attrs_offset); BINARY_SET_DATA_S_INCR(p, DataLengthType, 0); // skip attrs size DataLengthType attrssize = sizeof(DataLengthType); for (AttrM::iterator i=m_attrs.begin(); i!=m_attrs.end(); i++) { int head = p - buf; Attribute *attr = i->second; int nn; char *pp = attr->toBinary(nn); if (head + nn >= bufsize) { int newsize = bufsize + RESIZE; char *newbuf = new char[newsize]; memcpy(newbuf, buf, head); delete buf; buf = newbuf; bufsize = newsize; p = buf + head; } memcpy(p, pp, nn); p += nn; attrssize += nn; } BINARY_SET_DATA_S(buf + attrs_offset, DataLengthType, attrssize); } // set body offset value { DataOffsetType body_offset = p - buf; BINARY_SET_DATA_S(buf + bo_offset, DataOffsetType, body_offset); // body BINARY_SET_DATA_S_INCR(p, DataLengthType, 0); // skip body size DataLengthType bodysize = sizeof(DataLengthType); //for (PartsM::iterator i=m_parts.begin(); i!=m_parts.end(); i++) { PartsIterator *itr = getPartsIterator(); Parts *parts = NULL; while (itr && (parts = itr->next()) != NULL) { if (parts->isBlind()) { continue; } int head = p - buf; //Parts *parts = i->second; // added by sekikawa (2007/12/4) #ifdef TAKU_TEST parts->calcAbsPos(this); #endif int nn; char *pp = parts->toBinary(nn); if (head + nn >= bufsize) { int newsize = bufsize + RESIZE; char *newbuf = new char[newsize]; memcpy(newbuf, buf, head); delete buf; buf = newbuf; bufsize = newsize; p = buf + head; } memcpy(p, pp, nn); p += nn; bodysize += nn; } BINARY_SET_DATA_S(buf + body_offset, DataLengthType, bodysize); delete itr; } n = p-buf; // set datalen value BINARY_SET_DATA_S(buf, DataLengthType, n); return buf; }
KDE_NO_EXPORT void RP::TimingsBase::activate () { setState (state_activated); x = y = w = h = 0; srcx = srcy = srcw = srch = 0; for (Attribute *a = attributes ().first (); a; a = a->nextSibling ()) { if (a->name () == Ids::attr_target) { for (Node *n = parentNode()->firstChild(); n; n= n->nextSibling()) if (static_cast <Element *> (n)-> getAttribute ("handle") == a->value ()) target = n; } else if (a->name () == "start") { int dur; parseTime (a->value ().toLower (), dur); start = dur; } else if (a->name () == "duration") { int dur; parseTime (a->value ().toLower (), dur); duration = dur; } else if (a->name () == "dstx") { x = a->value ().toInt (); } else if (a->name () == "dsty") { y = a->value ().toInt (); } else if (a->name () == "dstw") { w = a->value ().toInt (); } else if (a->name () == "dsth") { h = a->value ().toInt (); } else if (a->name () == "srcx") { srcx = a->value ().toInt (); } else if (a->name () == "srcy") { srcy = a->value ().toInt (); } else if (a->name () == "srcw") { srcw = a->value ().toInt (); } else if (a->name () == "srch") { srch = a->value ().toInt (); } } start_timer = document ()->post (this, new TimerPosting (start *10)); }
//-------------------------------------------------------------------------- // Function: H5Location::dereference ///\brief Dereferences a reference into an HDF5 object, given an attribute. ///\param attr - IN: Attribute specifying the location of the referenced object ///\param ref - IN: Reference pointer ///\param ref_type - IN: Reference type ///\param plist - IN: Property list - default to PropList::DEFAULT ///\exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 // Modification // May, 2008 // Corrected missing parameters. - BMR //-------------------------------------------------------------------------- void H5Location::dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) { p_setId(p_dereference(attr.getId(), ref, ref_type, plist, "dereference")); }
bool HTMLEmbedElement::isURLAttribute(const Attribute& attribute) const { return attribute.name() == srcAttr || HTMLPlugInImageElement::isURLAttribute(attribute); }
//-------------------------------------------------------------------------- // Function: Group overload constructor - dereference ///\brief Given a reference, ref, to an hdf5 group, creates a Group object ///\param attr - IN: Specifying location where the referenced object is in ///\param ref - IN: Reference pointer ///\param ref_type - IN: Reference type - default to H5R_OBJECT ///\exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- Group::Group(const Attribute& attr, const void* ref, H5R_type_t ref_type) : H5Object(), id(H5I_INVALID_HID) { id = H5Location::p_dereference(attr.getId(), ref, ref_type, "constructor - by dereference"); }
bool HTMLTableCellElement::isURLAttribute(const Attribute& attribute) const { return attribute.name() == backgroundAttr || HTMLTablePartElement::isURLAttribute(attribute); }
StringRef AMDGPUTargetMachine::getGPUName(const Function &F) const { Attribute GPUAttr = F.getFnAttribute("target-cpu"); return GPUAttr.hasAttribute(Attribute::None) ? getTargetCPU() : GPUAttr.getValueAsString(); }
/* ~In~ function to create a record instance through a nested list. According to the assigned type and value list the record is created. Before that the lists are checked regarding there correctness in the following order: 1 check whether the given type list is a record type list at all 2 check if in case of a non empty value list the two lists have the same number of elements. 3 If the value list is empty an empty record with only the given element types is created In all other cases an appropriate error message is populated and the creation aborts. After preliminary research both lists will be run through parallel in order to create the single elements. To simplify the parallel run through a list iterator ~ListIterator~ class has been created. More information about the iterator can be found in ~ListIterator.h~ document. At the run through the following cases have to be differentiated: First of all the current type list has to contain 2 elements. Example: * case 1: (string (int int)) 1 element name 1 element type list, with two integer values 1.1 algebraId 1.2 typeId or * case 2: (string ((int int) ...)) 2 element name 2 element type as list, first list item contains two integer values (see above) The first possibility reflects a simple Secondo type whereas the second illustrates a complex type likewise a ~record~. The element name has to start with a capital letter. The list elements have to conform these guidelines otherwise an error is detected. Once the list item is correct the new element is created. Therefore the belonging algebraId and typeId is read out from the Secondo catalogue. Elements that are marked with NULL are created as well but are ~undefined~. After the successful element creation this element is appended to the record by AppendElement method. The whole procedure is repeated as long as element information is available in the given ~typeInfo~ list. */ Word Record::In(const ListExpr typeInfo, const ListExpr instance, const int errorPos, ListExpr& errorInfo, bool& correct) { #ifdef RECORD_DEBUG cerr << "Record::In(" << nl->ToString(typeInfo) << ", " << nl->ToString(instance) << ", ..., ..., " << correct << ")" << endl; #endif Word w = SetWord(Address(0)); correct = false; const string nullSymbol = "NULL"; if (Record::IsRecordTypeList(typeInfo)) { // create an empty record instance Record* record = new Record(0); bool hasValueList; if(listutils::isSymbolUndefined(instance)){ // an undefined record: record->SetDefined(false); correct = true; return w; } // in case of a not empty value list: // case 1: value list has to be a list // case 2: type list and value list have to be of the same length if (nl->ListLength(instance) == 0) { hasValueList = false; } else { hasValueList = true; // case 1 if (nl->IsAtom(instance)){ #ifdef RECORD_DEBUG cerr << "Record::In: value list is of kind atom but " "a list is expected!" << endl; #endif cmsg.inFunError("Record::In: Value list is of kind atom but " "a list is expected! "); return w; } // case 2 if (nl->ListLength(instance) != nl->ListLength(nl->Rest(typeInfo))) { #ifdef RECORD_DEBUG cerr << "Record::In: different number of elements in " "type list and value list " << endl; #endif cmsg.inFunError("Record::In: different number of elements in " "type list and Value list "); return w; } } // create type and value list iteratoren ListIterator typeIter = nl->Rest(typeInfo); ListIterator valueIter = instance; // variables used inside the iteration loop string elemName; string elemTypeName; int elemAlgebraId; int elemTypeId; Word elemWord; Attribute* elem; // iterate synchrone through the type and value list elements while(typeIter.HasNext() && valueIter.HasNext()) { // assign the current type list element NList curType = typeIter.NextNList(); // assign the current value list element ListExpr curValue; if (hasValueList) { curValue = valueIter.NextListExpr(); } else { curValue = nl->OneElemList(nl->SymbolAtom(nullSymbol)); } #ifdef RECORD_DEBUG cerr << "Record::In: curType=" << curType.convertToString() << endl; cerr << "Record::In: curValue=" << nl->ToString(curValue) << endl; #endif // the current type list has to contain 2 elements // case 1: (string (int int)) // 1. element name // 2. element type list with two integer values // 2.1 algebraId // 2.2 typeId // case 2: (string ((int int) ...)) // 1. element name // 2. element type as list, first list item contains // two integer values if ( !( curType.length() == 2 && curType.second().length() == 2 && curType.second().first().isInt() && curType.second().second().isInt()) && !( curType.length() == 2 && curType.second().length() > 0 && curType.second().first().length() == 2 && curType.second().first().first().isInt() && curType.second().first().second().isInt())) { #ifdef RECORD_DEBUG cerr << "Record::In: wrong subtype info" << endl; #endif cmsg.inFunError("Record::In: wrong subtype info: " + curType.convertToString()); return w; } // extraxt the element name from current type list element elemName = curType.first().convertToString(); // extraxt the element type ids from current type list element if (curType.second().first().isAtom()) { // case 1 elemAlgebraId = curType.second().first().intval(); elemTypeId = curType.second().second().intval(); } else { // case 2 elemAlgebraId = curType.second().first().first().intval(); elemTypeId = curType.second().first().second().intval(); } // retrieve the type name of the ids from secondo catalog SecondoCatalog* sc = SecondoSystem::GetCatalog(); elemTypeName = sc->GetTypeName(elemAlgebraId, elemTypeId); // the element name has to start with a capital letter if (isupper(elemName[0]) == 0) { cmsg.inFunError("Record::In: element name has to start with a " "capital letter: " + elemName); return w; } // check if curValue is a Atom of value NULL (TEXT or Symbol) // if true -> create a default object if (nullSymbol.compare(nl->ToString(curValue)) == 0) { elemWord = (am->CreateObj(elemAlgebraId, elemTypeId)) (curType.second().listExpr()); // cast the read type instance to an attribute elem = static_cast<Attribute*>(elemWord.addr); // make elem as undefined elem->SetDefined(false); } else { // read element by registered IN function of the current type elemWord = (am->InObj(elemAlgebraId, elemTypeId)) (curType.second().listExpr(), curValue, errorPos, errorInfo, correct); // cast the read type instance to an attribute elem = static_cast<Attribute*>(elemWord.addr); } // check of existing object elem if (elem == NULL) { cmsg.inFunError("Record::In: In function of type " + elemTypeName +" for element " + elemName + " has delivered a NULL pointer for value " + nl->ToString(curValue)); return w; } // append the read attribute to the record and check the result if (record->AppendElement(elem, elemTypeName, elemName) == false) { cmsg.inFunError("Record::In: Cannot append element " + elemName + " of type " + elemTypeName); elem->DeleteIfAllowed(); return w; } elem->DeleteIfAllowed(); elem=0; } // End of: iterate synchrone through the type and value list elements // set the created record as return value w = SetWord(record); correct = true; } //IsRecordTypeList #ifdef RECORD_DEBUG cerr << "Record::In: correct=" << correct << ", w.addr=" << w.addr << endl; #endif return w; }
int HDF5FileBase::setAttributeStrArray(Array<const char*>& data, int maxSize, String path, String name) { H5Location* loc; Group gloc; DataSet dloc; Attribute attr; hsize_t dims[1]; if (!opened) return -1; StrType type(PredType::C_S1, maxSize + 1); type.setSize(H5T_VARIABLE); try { try { gloc = file->openGroup(path.toUTF8()); loc = &gloc; } catch (FileIException error) //If there is no group with that path, try a dataset { dloc = file->openDataSet(path.toUTF8()); loc = &dloc; } if (loc->attrExists(name.toUTF8())) { //attr = loc.openAttribute(name.toUTF8()); return -1; //string attributes cannot change size easily, better not allow overwritting. } else { DataSpace attr_dataspace; int nStrings = data.size(); if (nStrings > 1) { dims[0] = nStrings; attr_dataspace = DataSpace(1, dims); } else attr_dataspace = DataSpace(H5S_SCALAR); attr = loc->createAttribute(name.toUTF8(), type, attr_dataspace); } attr.write(type, data.getRawDataPointer()); } catch (GroupIException error) { PROCESS_ERROR; } catch (AttributeIException error) { PROCESS_ERROR; } catch (FileIException error) { PROCESS_ERROR; } catch (DataSetIException error) { PROCESS_ERROR; } return 0; }
void Rocblas::axpy_gen( const void *ain, const Attribute *x, const Attribute *y, Attribute *z) { COM_assertion_msg(!x->is_windowed() && !y->is_windowed() && !z->is_windowed(), "Unsupported attribute type"); COM_assertion_msg( COM_compatible_types(x->data_type(),y->data_type()), (std::string("Incompatible data types between ")+ x->fullname()+" and "+y->fullname()).c_str()); COM_assertion_msg( COM_compatible_types(x->data_type(),z->data_type()), (std::string("Incompatible data types between ")+ x->fullname()+" and "+z->fullname()).c_str()); int num_dims = z->size_of_components(); COM_assertion_msg(num_dims == x->size_of_components() && num_dims == y->size_of_components(), (std::string("Numbers of components do not match between ")+ x->fullname()+" and "+y->fullname()).c_str()); std::vector<const Pane*> apanes, xpanes, ypanes; std::vector<Pane*> zpanes; x->window()->panes(xpanes); y->window()->panes(ypanes); z->window()->panes(zpanes); COM_assertion_msg( xpanes.size() == ypanes.size(), (std::string("Numbers of panes do not match between ")+ x->window()->name()+" and "+y->window()->name()).c_str()); COM_assertion_msg( xpanes.size() == zpanes.size(), (std::string("Numbers of panes do not match between ")+ x->window()->name()+" and "+z->window()->name()).c_str()); std::vector<Pane*>::iterator zit, zend; std::vector<const Pane*>::const_iterator xit, yit; const Pane** ait=NULL; const Attribute *a=NULL; const data_type *aval=NULL; if ( atype == BLAS_VOID) aval = reinterpret_cast<const data_type *>( ain); else { a = reinterpret_cast<const Attribute*>(ain); if ( !a->is_windowed()) { a->window()->panes( apanes); COM_assertion_msg(xpanes.size() == ypanes.size(), (std::string("Numbers of panes do not match between ")+ x->window()->name()+" and "+y->window()->name()).c_str()); ait = &apanes[0]; } else { COM_assertion_msg( a->size_of_items()==1, "Size of items do not match"); aval = reinterpret_cast<const data_type *>( a->pointer()); COM_assertion_msg( aval, (std::string("Caught NULL pointer in ")+ a->fullname()).c_str()); } } const int anum_dims = atype!=BLAS_VOID ? a->size_of_components() : 0; COM_assertion_msg( atype==BLAS_VOID || (anum_dims==1 || anum_dims==num_dims), (std::string("Numbers of components do not match between ")+ a->fullname()+" and "+z->fullname()).c_str()); for(zit=zpanes.begin(),zend=zpanes.end(),xit=xpanes.begin(),yit=ypanes.begin(); zit != zend; ++zit, ait+=(atype!=BLAS_VOID&&ait), ++xit, ++yit) { Attribute *pz = (*zit)->attribute(z->id()); const int length = pz->size_of_items(); int zstrd=get_stride<BLAS_VEC2D>(pz); const bool zstg = num_dims!=zstrd; const Attribute *px = (*xit)->attribute(x->id()); int xstrd = get_stride<BLAS_VEC2D>(px); COM_assertion_msg(length == px->size_of_items() || xstrd==0, (std::string("Numbers of items do not match between ")+ x->fullname()+" and "+z->fullname()+ " on pane "+to_str((*zit)->id())).c_str()); const bool xstg = num_dims!=xstrd || xstrd==0; const Attribute *py = (*yit)->attribute(y->id()); int ystrd = get_stride<BLAS_VEC2D>(py); COM_assertion_msg(length == py->size_of_items() || ystrd==0, (std::string("Numbers of items do not match between ")+ y->fullname()+" and "+z->fullname()+ " on pane "+to_str((*zit)->id())).c_str()); const bool ystg = num_dims!=ystrd || ystrd==0; const Attribute *pa = (atype!=BLAS_VOID&&ait)?(*ait)->attribute(a->id()):a; int astrd = get_stride<atype>(pa); const bool astg = pa && (anum_dims!=num_dims || anum_dims!=astrd); COM_assertion_msg( atype!=BLAS_SCNE && atype!=BLAS_VEC2D || length == int(pa->size_of_items()) || astrd==0, (std::string("Numbers of items do not match between ")+ a->fullname()+" and "+z->fullname()+ " on pane "+to_str((*zit)->id())).c_str()); // Optimized version for contiguous attributes if ( !xstg && !zstg && !ystg && !astg && atype != BLAS_VEC && (atype != BLAS_SCNE || num_dims==1)) { const data_type *xval = (const data_type *)px->pointer(); const data_type *yval = (const data_type *)py->pointer(); data_type *zval = (data_type *)pz->pointer(); // Get address for a if a is not window attribute if ( atype != BLAS_VOID && ait) aval = reinterpret_cast<const data_type *>(pa->pointer()); //Loop for each element/node and for each dimension for(Size i = 0, s = length*num_dims; i<s; ++i, ++zval, ++xval, ++yval) *zval = getref<data_type,atype,0>(aval,i,0,1)* *xval+ *yval; } else { // General version //Loop for each dimension. for(int i = 0; i < num_dims; ++i) { Attribute *pz_i = num_dims==1?pz:(*zit)->attribute(z->id()+i+1); data_type *zval = (data_type *)pz_i->pointer(); zstrd=get_stride<BLAS_VEC2D>(pz_i); const Attribute *px_i = num_dims==1?px:(*xit)->attribute(x->id()+i+1); const data_type *xval = (const data_type *)px_i->pointer(); xstrd=get_stride<BLAS_VEC2D>(px_i); const Attribute *py_i = num_dims==1?py:(*yit)->attribute(y->id()+i+1); const data_type *yval = (const data_type *)py_i->pointer(); ystrd=get_stride<BLAS_VEC2D>(py_i); if ( atype != BLAS_VOID && ait) { const Attribute *pa_i=anum_dims==1?pa:(*ait)->attribute(a->id()+i+1); aval = reinterpret_cast<const data_type *>( pa_i->pointer()); astrd = get_stride<atype>( pa_i); } //Loop for each element/node. for(int j=0; j<length; ++j, xval+=xstrd, zval+=zstrd, yval+=ystrd) *zval = getref<data_type,atype,1>(aval,j,i,astrd) * *xval + *yval; } } // end if } // end for }
/* ~GetElement~ returns the element at position pos. With the help of the element info ~elemInfo~ it is possible to rebuild the attribute that is stored at a given record position. First the ~elemInfo~ is refilled with the information of ~elemInfoArray~ at the given position. It is now possible to create the attribute with the correct type and name. As the position in ~elemData~ is known as well the data can be assigned to the attribute. Finally the external data if available can be assigned to the attribute as well. */ Attribute* Record::GetElement(int pos) const { assert(pos >=0); assert(pos < this->elemInfoArray.Size()); // get element info by position ElemInfo elemInfo; elemInfoArray.Get(pos, elemInfo); if(!elemInfo.hasData){ return 0; } else { // create requested element // TODO: It's not a good idea to have no type information during // object creation for some types Attribute* elem = static_cast<Attribute*> ((am->CreateObj(elemInfo.algebraId, elemInfo.typeId))(0).addr); // save the flob states vector<Flob> savedFlobs; for(int i=0;i<elem->NumOfFLOBs();i++){ savedFlobs.push_back(*elem->GetFLOB(i)); } this->elemData.read((char*)elem, elem->Sizeof(),elemInfo.dataOffset); // assign retrieved data to element elem = static_cast<Attribute*>( (am->Cast(elemInfo.algebraId, elemInfo.typeId))((void*) elem)); // restore the flob states for(int i=0;i<elem->NumOfFLOBs();i++){ int size = elem->GetFLOB(i)->getSize(); elem->GetFLOB(i)->kill(); *(elem->GetFLOB(i)) = savedFlobs[i]; elem->GetFLOB(i)->resize(size); } // assign external data offset size_t offset = elemInfo.extDataOffset; // restore flob data for (int i = 0; i < elem->NumOfFLOBs(); i++) { Flob* flob = elem->GetFLOB(i); char* buffer = new char[flob->getSize()]; bool ok = elemExtData.read(buffer, flob->getSize(), offset); assert(ok); // assign retrieved data to target flob flob->write(buffer, flob->getSize(), 0); delete[] buffer; // update external data offset offset += flob->getSize(); } return elem; } }
void AttributeUse::generate(QString &className, QString &ehprivate, QString &ehpublic, QString &ehinclude, QString &ecpp, QString &eccinclude) { Attribute *a = getAttribute(); SimpleType *st = a->getSimpleType(); QString dt = st->getDataType(); QString name = unqualify(a->getName()); // data model, ends with underscore ehprivate.append(dt + " " + varName(name, QString(), "Value") + ";\n"); ehprivate.append("QString " + varName(name, QString(), "RawValue") + ";\n"); ehprivate.append("bool " + varName(name, "has", "Value") + ";\n"); // has ###, returns true also if default exists ehpublic.append("bool " + methodName(name, "has") + "() {\n"); ehpublic.append(" return " + varName(name, "has", "Value") + ";\n"); ehpublic.append("}\n"); // is ### Valid, returns true if input can be set ehpublic.append( "bool " + methodName(name, "is", "Valid") + "(QString input);\n"); ecpp.append( "bool " + className + "::" + methodName(name, "is", "Valid") + "(QString input) {\n"); ecpp.append(" bool ok;\n"); // inserts control which expects string variable input and bool ok ecpp.append(" " + st->generateControl("input") + "\n"); ecpp.append(" return ok;\n"); ecpp.append("}\n"); // get ###, returns default if exists or value if set ehpublic.append(dt + " " + methodName(name, "get") + "() {\n"); ehpublic.append(" return " + varName(name, QString(), "Value") + ";\n"); ehpublic.append("}\n"); // getRaw ###, returns default if exists or value if set ehpublic.append("QString " + methodName(name, "getRaw") + "() {\n"); ehpublic.append(" return " + varName(name, QString(), "RawValue") + ";\n"); ehpublic.append("}\n"); // set ###, doesn't necessarily do tests ehprivate.append("void " + methodName(name, "set") + "(QString input);\n"); ecpp.append( "void " + className + "::" + methodName(name, "set") + "(QString input) {\n"); // inserts setting mechanism, expects string variable input and model variable ecpp.append( " " + st->generateSetter("input", varName(name, QString(), "Value")) + "\n"); ecpp.append(" " + varName(name, "has", "Value") + " = true;\n"); ecpp.append(" " + varName(name, QString(), "RawValue") + " = input;\n"); if (Settings::settings()->isDebug()) { ecpp.append("qDebug() << \"set attribute\" << \"" + name + "\";\n"); } ecpp.append("}\n"); // default value handling, defaults in attribute are copied to attributeUse QString df; bool hasDf = false; if (hasDefault()) { hasDf = true; df = getDefault(); } // init ###, sets default if exists ehprivate.append("void " + methodName(name, "init") + "();\n"); ecpp.append( "void " + className + "::" + methodName(name, "init") + "() {\n"); // inserts initializer of model ecpp.append( " " + st->generateInit(varName(name, QString(), "Value")) + "\n"); if (hasDf) { ecpp.append(" " + methodName(name, "set") + "(\"" + df + "\");\n"); } ecpp.append("}\n"); }
XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) : m_doc(fragment->document()) , m_view(0) , m_wroteText(false) , m_currentNode(fragment) , m_currentNodeIsReferenced(fragment) , m_sawError(false) , m_sawXSLTransform(false) , m_sawFirstElement(false) , m_isXHTMLDocument(false) , m_parserPaused(false) , m_requestingScript(false) , m_finishCalled(false) , m_errorCount(0) , m_lastErrorLine(0) , m_lastErrorColumn(0) , m_pendingScript(0) , m_scriptStartLine(0) , m_parsingFragment(true) { mpXmlReader = EA::XMLWrapper::CreateXMLReaderWrapperInterface(); EAW_ASSERT(mpXmlReader); if(mpXmlReader) { mpXmlReader->SetFlag(0xffffffff, true); // Set up the decoder to be used in the callback (static so one for all xmlReaders) mpXmlReader->SetEntityNamedDecoder( (EA::Internal::XML::decode_entity_named*) WebCore::decodeNamedEntity); } if (fragment) fragment->ref(); if (m_doc) m_doc->ref(); // Add namespaces based on the parent node Vector<Element*> elemStack; while (parentElement) { elemStack.append(parentElement); Node* n = parentElement->parentNode(); if (!n || !n->isElementNode()) break; parentElement = static_cast<Element*>(n); } if (!elemStack.isEmpty()) { for (Element* element = elemStack.last(); !elemStack.isEmpty(); elemStack.removeLast()) { if (NamedAttrMap* attrs = element->attributes()) { for (unsigned i = 0; i < attrs->length(); i++) { Attribute* attr = attrs->attributeItem(i); const AtomicString& sValue = attr->value(); const AtomicString& sLocalName = attr->localName(); if (attr->localName() == "xmlns") m_defaultNamespaceURI = sValue; else if (attr->prefix() == "xmlns") { char8_t localName8[32]; EA::Internal::Strlcpy(localName8, sLocalName.characters(), sizeof(localName8), sLocalName.length()); char8_t value8[128]; EA::Internal::Strlcpy(value8, sValue.characters(), sizeof(value8), sValue.length()); mpXmlReader->AddNamespaceAlias(localName8, value8, true); } } } } // If the parent element is not in document tree, there may be no xmlns attribute; just default to the parent's namespace. if (m_defaultNamespaceURI.isNull() && !parentElement->inDocument()) m_defaultNamespaceURI = parentElement->namespaceURI(); } }
void HTMLImageElement::collectStyleForPresentationAttribute(const Attribute& attribute, StylePropertySet* style) { if (attribute.name() == widthAttr) addHTMLLengthToStyle(style, CSSPropertyWidth, attribute.value()); else if (attribute.name() == heightAttr) addHTMLLengthToStyle(style, CSSPropertyHeight, attribute.value()); else if (attribute.name() == borderAttr) applyBorderAttributeToStyle(attribute, style); else if (attribute.name() == vspaceAttr) { addHTMLLengthToStyle(style, CSSPropertyMarginTop, attribute.value()); addHTMLLengthToStyle(style, CSSPropertyMarginBottom, attribute.value()); } else if (attribute.name() == hspaceAttr) { addHTMLLengthToStyle(style, CSSPropertyMarginLeft, attribute.value()); addHTMLLengthToStyle(style, CSSPropertyMarginRight, attribute.value()); } else if (attribute.name() == alignAttr) applyAlignmentAttributeToStyle(attribute, style); else if (attribute.name() == valignAttr) addPropertyToPresentationAttributeStyle(style, CSSPropertyVerticalAlign, attribute.value()); else HTMLElement::collectStyleForPresentationAttribute(attribute, style); }
bool HTMLVideoElement::isURLAttribute(const Attribute& attribute) const { return attribute.name() == posterAttr || HTMLMediaElement::isURLAttribute(attribute); }
bool GcInfo::isFPBasedFunction(const Function *F) { Attribute Attribute = F->getFnAttribute("no-frame-pointer-elim"); return (Attribute.getValueAsString() == "true"); }
bool HTMLLinkElement::isURLAttribute(const Attribute& attribute) const { return attribute.name().localName() == hrefAttr || HTMLElement::isURLAttribute(attribute); }
void Scenario::fromFile(const std::string &fileName) throw(xmlpp::exception, invalid_argument, overflow_error) { using namespace xmlpp; clear(); DomParser parser(fileName); Document *document = parser.get_document(); Element *root = document->get_root_node(); if (root->get_name()!="game") { throw xmlpp::exception("Bad document content type: game expected"); } // getting the user interface try { Attribute *attr = root->get_attribute("interface"); if (attr != NULL) { uiInterface = stringToInterface(attr->get_value()); } else { uiInterface = uiFull; } } catch (invalid_argument) { throw xmlpp::exception("Bad user interface"); } // now loading the different parts of the game Node::NodeList node = root->get_children("scenario"); if (!node.empty()) { tScenario.fromXML(*dynamic_cast<Element*>(node.front())); } node = root->get_children("notes"); if (!node.empty()) { Element *elem = dynamic_cast<Element*>(node.front()); if (elem->has_child_text()) { sNotes = elem->get_child_text()->get_content(); } else { sNotes = ""; } } node = root->get_children("skills"); if (!node.empty()) { lSkills.fromXML(*dynamic_cast<Element*>(node.front())); } node = root->get_children("characters"); if (!node.empty()) { lCharacters.fromXML(*dynamic_cast<Element*>(node.front())); } node = root->get_children("history"); if (!node.empty()) { tHistory.fromXML(*dynamic_cast<Element*>(node.front())); } node = root->get_children("music"); if (!node.empty()) { tMusic.fromXML(*dynamic_cast<Element*>(node.front())); } node = root->get_children("effects"); if (!node.empty()) { tEffects.fromXML(*dynamic_cast<Element*>(node.front()),true); } }
// Process the file based on the format Branch TextTree::ProcessFile(vector<string> branch) { Branch result; Attribute tempAttrib; bool isChildBranch = false; bool validFile = true; // Get the parent branch for (size_t i = 0; i < branch.size(); ++i) { // Check the first char of each line if (branch[i][0] == BRANCH_START) { // Handle child branches if (isChildBranch) { // Gather everything within the child branch vector<string> childBranch; // Find the child branch's end short branchLevel = 0; // Find the number of attributes that belong to the child branch for (size_t j = i; j < branch.size(); ++j) { // a new child found if (branch[j][0] == BRANCH_START) { ++branchLevel; } else if (branch[j][0] == BRANCH_END) { --branchLevel; } // Store everything that belongs to the child if (branchLevel < 1) { for (size_t startLine = i; startLine < j; ++startLine) { childBranch.push_back(branch[startLine]); } break; } } // Skip to the next BRANCH_START i += childBranch.size(); // Pass this block in recursively and add to the top level branch /*very smart processing*/ result.childBranches.push_back(ProcessFile(childBranch)); } // First open branch else { isChildBranch = true; } } // New attribute else if (branch[i][0] == ATTRIBUTE_START) { // Store attribute name string attribName = ""; // Starts from 1 because of BRANCH_START size_t j = 1; while (branch[i][j] != ATTRIBUTE_END) { attribName += branch[i][j]; ++j; // Attribute does not have a close // Error handling if (j >= branch[i].length()) { validFile = false; break; } } // Skip the ATTRIBUTE_END ++j; // Store the attribute value string attribValue = ""; while (j < branch[i].length()) { attribValue += branch[i][j]; ++j; } // Special case attribute for "NAME" if (attribName == "NAME") { result.branchName = attribValue; } // Add attribute with value into branch else { tempAttrib.Set(attribName, attribValue); result.attributes.push_back(tempAttrib); // Reset temp storage tempAttrib.Set(); } } } return result; }
int ArfFileBase::setAttributeArray(DataTypes type, void* data, int size, String path, String name) { H5Location* loc; Group gloc; DataSet dloc; Attribute attr; DataType H5type; DataType origType; if (!opened) return -1; try { try { gloc = file->openGroup(path.toUTF8()); loc = &gloc; } catch (FileIException error) //If there is no group with that path, try a dataset { dloc = file->openDataSet(path.toUTF8()); loc = &dloc; } H5type = getH5Type(type); origType = getNativeType(type); if (size > 1) { hsize_t dims = size; H5type = ArrayType(H5type,1,&dims); origType = ArrayType(origType,1,&dims); } if (loc->attrExists(name.toUTF8())) { attr = loc->openAttribute(name.toUTF8()); } else { DataSpace attr_dataspace(H5S_SCALAR); attr = loc->createAttribute(name.toUTF8(),H5type,attr_dataspace); } attr.write(origType,data); } catch (GroupIException error) { PROCESS_ERROR; } catch (AttributeIException error) { PROCESS_ERROR; } catch (DataSetIException error) { PROCESS_ERROR; } catch (FileIException error) { PROCESS_ERROR; } return 0; }
bool SVGAElement::isURLAttribute(const Attribute& attribute) const { return attribute.name().localName() == XLinkNames::hrefAttr || SVGGraphicsElement::isURLAttribute(attribute); }
const X86Subtarget * X86TargetMachine::getSubtargetImpl(const Function &F) const { Attribute CPUAttr = F.getFnAttribute("target-cpu"); Attribute FSAttr = F.getFnAttribute("target-features"); StringRef CPU = !CPUAttr.hasAttribute(Attribute::None) ? CPUAttr.getValueAsString() : (StringRef)TargetCPU; StringRef FS = !FSAttr.hasAttribute(Attribute::None) ? FSAttr.getValueAsString() : (StringRef)TargetFS; SmallString<512> Key; Key.reserve(CPU.size() + FS.size()); Key += CPU; Key += FS; // FIXME: This is related to the code below to reset the target options, // we need to know whether or not the soft float flag is set on the // function before we can generate a subtarget. We also need to use // it as a key for the subtarget since that can be the only difference // between two functions. bool SoftFloat = F.getFnAttribute("use-soft-float").getValueAsString() == "true"; // If the soft float attribute is set on the function turn on the soft float // subtarget feature. if (SoftFloat) Key += FS.empty() ? "+soft-float" : ",+soft-float"; // Keep track of the key width after all features are added so we can extract // the feature string out later. unsigned CPUFSWidth = Key.size(); // Extract prefer-vector-width attribute. unsigned PreferVectorWidthOverride = 0; if (F.hasFnAttribute("prefer-vector-width")) { StringRef Val = F.getFnAttribute("prefer-vector-width").getValueAsString(); unsigned Width; if (!Val.getAsInteger(0, Width)) { Key += ",prefer-vector-width="; Key += Val; PreferVectorWidthOverride = Width; } } // Extract required-vector-width attribute. unsigned RequiredVectorWidth = UINT32_MAX; if (F.hasFnAttribute("required-vector-width")) { StringRef Val = F.getFnAttribute("required-vector-width").getValueAsString(); unsigned Width; if (!Val.getAsInteger(0, Width)) { Key += ",required-vector-width="; Key += Val; RequiredVectorWidth = Width; } } // Extracted here so that we make sure there is backing for the StringRef. If // we assigned earlier, its possible the SmallString reallocated leaving a // dangling StringRef. FS = Key.slice(CPU.size(), CPUFSWidth); auto &I = SubtargetMap[Key]; if (!I) { // This needs to be done before we create a new subtarget since any // creation will depend on the TM and the code generation flags on the // function that reside in TargetOptions. resetTargetOptions(F); I = llvm::make_unique<X86Subtarget>(TargetTriple, CPU, FS, *this, Options.StackAlignmentOverride, PreferVectorWidthOverride, RequiredVectorWidth); } return I.get(); }
bool HTMLBodyElement::isURLAttribute(const Attribute& attribute) const { return attribute.name() == backgroundAttr || HTMLElement::isURLAttribute(attribute); }
bool HTMLFrameElementBase::isURLAttribute(const Attribute& attribute) const { return attribute.name() == longdescAttr || attribute.name() == srcAttr || HTMLFrameOwnerElement::isURLAttribute(attribute); }
foreach(Attribute& attr, attributes) { if(triangle_mesh) attr.reserve(triangle_mesh->verts.size(), triangle_mesh->triangles.size(), triangle_mesh->motion_steps, 0, 0, true); if(curve_mesh) attr.reserve(0, 0, 0, curve_mesh->curves.size(), curve_mesh->curve_keys.size(), true); }
bool HTMLFrameElementBase::isHTMLContentAttribute(const Attribute& attribute) const { return attribute.name() == srcdocAttr || HTMLFrameOwnerElement::isHTMLContentAttribute(attribute); }
bool HTMLObjectElement::isURLAttribute(const Attribute& attribute) const { return attribute.name() == dataAttr || (attribute.name() == usemapAttr && attribute.value().string()[0] != '#') || HTMLPlugInImageElement::isURLAttribute(attribute); }
bool HTMLSourceElement::isURLAttribute(const Attribute& attribute) const { return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute); }
bool HTMLButtonElement::isURLAttribute(const Attribute& attribute) const { return attribute.name() == formactionAttr || HTMLFormControlElement::isURLAttribute(attribute); }
double Attribute::EvalCompiledNLGExpression (double const x, double const y ,double const z, double const g ) { //cout << GetPrototype()->GetName() << " ?? at pointer num " << m_cur_fp << " -> compiled = " << m_compiled.at(m_cur_fp) << endl; if (m_nlgfp == NULL && m_ginac_excomp) { //substitute all attributes with numbers in GiNaC expression, except the attribute //which serves as the free parameter for runtime compilation GiNaC::lst symlist; GiNaC::lst numlist; for (unsigned int i=0; i<m_subjects.size() ; i++) { Attribute* a = m_subjects.at(i); if (a->GetName() == "NLG_posX") continue; if (a->GetName() == "NLG_posY") continue; if (a->GetName() == "NLG_posZ") continue; if (a->GetName() == "NLG_value") continue; symlist.append( get_symbol(a->GetSymbol()) ); if (a->GetTypeID()==typeid( double*).name()) { numlist.append(a->GetMember <double>() ); continue; } if (a->GetTypeID()==typeid( int*).name()) { numlist.append(a->GetMember <int>() ); continue; } if (a->GetTypeID()==typeid( long*).name()) { numlist.append(a->GetMember <long>() ); continue; } if (a->GetTypeID()==typeid(unsigned*).name()) { numlist.append(a->GetMember<unsigned>() ); continue; } if (a->GetTypeID()==typeid( bool*).name()) { numlist.append(a->GetMember <bool>() ); continue; } } GiNaC::ex e = GiNaC::evalf((symlist.nops()==0)?m_expression:m_expression.subs(symlist,numlist)); try { compile_ex (e, get_symbol(GetPrototype()->GetAttribute("NLG_posX")->GetSymbol()), get_symbol(GetPrototype()->GetAttribute("NLG_posY")->GetSymbol()), get_symbol(GetPrototype()->GetAttribute("NLG_posZ")->GetSymbol()), get_symbol(GetPrototype()->GetAttribute("NLG_value")->GetSymbol()), m_nlgfp); //cout << " compiling attribute " << GetName() << " of module " << GetPrototype()->GetName() << endl; } catch (exception &p) { cout << " Warning: attribute " << GetName() << " of module " << GetPrototype()->GetName() << endl << endl << " function Attribute::EvalCompiledNLGExpression" << endl << " No external runtime compiler available: " << p.what() << endl << " Falling back to (slow) analytic evaluation!" << endl << endl << " Hint: if you have a shell and gcc on your system, create the one-liner " << endl << endl << " #!/bin/sh" << endl << " gcc -x c -fPIC -shared -o $1.so $1" << endl << endl << " name it \"ginac-excompiler\", and put it somewhere in your search path." << endl << endl; m_ginac_excomp = false; } } //if compilation failed, invoke slow analytic evaluation if (!m_ginac_excomp ) { *((double*) GetPrototype()->GetAttribute("NLG_posX")-> GetAddress()) = x; *((double*) GetPrototype()->GetAttribute("NLG_posY")-> GetAddress()) = y; *((double*) GetPrototype()->GetAttribute("NLG_posZ")-> GetAddress()) = z; *((double*) GetPrototype()->GetAttribute("NLG_value")-> GetAddress()) = g; EvalExpression(); return *((double*) GetAddress()); } //invoke fast runtime compiled routines if ( m_nlgfp != NULL ) return m_nlgfp(x,y,z,g); return 0.0; }