//then assign each NavNode a list of file#id values //a NavPoint's range is from its contentHref until the next NavPoint's contentHref //a PageTarget's range is from its contentHref until the next PageTarget's contentHref //what is hard to tell: ranges for nav list items (so for now just give them one file#id //when we have dtbook support, this info can come from smilref attributes bool amis::dtb::nav::ResolveSmilDataVisitor::preVisit(NavNode* pNode) { if (mThreadYielder != 0) mThreadYielder->peekAndPump(); //ranges aren't supported in nav targets yet if (pNode != NULL && pNode->getTypeOfNode() == NavNode::NAV_TARGET) { addToMap(pNode->getContent(), pNode); } else { if (mpPreviousNavNode != NULL) { string c1 = mpPreviousNavNode->getContent(); string c2; if (pNode == NULL) c2 = ""; else c2 = pNode->getContent(); //this will be the range for the previous nav point StdStringList range; range = getRange(c1, c2); for (int i = 0; i<range.size(); i++) { addToMap(range[i], mpPreviousNavNode); } } mpPreviousNavNode = pNode; } return true; }
void CMStuff(char *devID, JNIEnv *env, jobject hashMap, jmethodID methPut) { DEVINST devinst; DEVINST devinstparent; unsigned long buflen; CONFIGRET ret; ret = CM_Locate_DevNodeA(&devinst, devID, NULL); if (ret != CR_SUCCESS) { return; } ret = CM_Get_Parent(&devinstparent, devinst, NULL); if (ret != CR_SUCCESS) { return; } char *has = strstr(devID, "RemovableMedia"); if (has) { CM_Get_Parent(&devinstparent, devinstparent, NULL); // if failed, devinstparent should still have previous value (I hope!) } ret = CM_Get_Device_ID_Size(&buflen, devinst, 0); if (ret != CR_SUCCESS) { return; } if (buflen < 2048) { buflen++; // add space for null, which CM_Get_Device_ID will add at end WCHAR *buffer = new WCHAR[buflen]; ret = CM_Get_Device_ID(devinst, buffer, buflen, 0); if (ret != CR_SUCCESS) { delete[] buffer; return; } addToMap(env, hashMap, methPut, "DevInst_DevID", buffer, buflen); findVID_PID(buffer, env, hashMap, methPut); delete[] buffer; } ret = CM_Get_Device_ID_Size(&buflen, devinstparent, 0); if (ret != CR_SUCCESS) { return; } if (buflen < 2048) { buflen++; // add space for null, which CM_Get_Device_ID will add at end WCHAR *buffer = new WCHAR[buflen]; ret = CM_Get_Device_ID(devinstparent, buffer, buflen, 0); if (ret != CR_SUCCESS) { delete[] buffer; return; } addToMap(env, hashMap, methPut, "DevInstParent_DevID", buffer, buflen); findVID_PID(buffer, env, hashMap, methPut); delete[] buffer; } }
void Map<KEY, T>::addToMap(Elem* root, map<KEY, Elem*> &keyElemMap){ if (root) { keyElemMap[root->key] = root; addToMap(root->left, keyElemMap); if (!root->rightThread) addToMap(root->right, keyElemMap); } }
// 填充 map,不包含 root void fillMapParentsWithoutRoot(TreeNode* root, map<TreeNode*, TreeNode*>& mapParents) { if (root == NULL) { return; } addToMap(mapParents, root->left, root); addToMap(mapParents, root->right, root); fillMapParentsWithoutRoot(root->left, mapParents); fillMapParentsWithoutRoot(root->right, mapParents); }
void findVID_PID(WCHAR *str, JNIEnv *env, jobject hashMap, jmethodID methPut) { WCHAR *vid = wcsstr(str, L"VID_"); WCHAR *pid = wcsstr(str, L"PID_"); if (vid) { vid += 4; addToMap(env, hashMap, methPut, "VID", vid, 4); } if (pid) { pid += 4; addToMap(env, hashMap, methPut, "PID", pid, 4); } }
//--------------------------------------------------------- void DocumentXML::addLocationRange(const SourceRange& R) { PresumedLoc PStartLoc = addLocation(R.getBegin()); if (R.getBegin() != R.getEnd()) { SourceManager& SM = Ctx->getSourceManager(); SourceLocation SpellingLoc = SM.getSpellingLoc(R.getEnd()); if (!SpellingLoc.isInvalid()) { PresumedLoc PLoc = SM.getPresumedLoc(SpellingLoc); if (PStartLoc.isInvalid() || strcmp(PLoc.getFilename(), PStartLoc.getFilename()) != 0) { addToMap(SourceFiles, PLoc.getFilename(), ID_FILE); addAttribute("endfile", PLoc.getFilename()); addAttribute("endline", PLoc.getLine()); addAttribute("endcol", PLoc.getColumn()); } else if (PLoc.getLine() != PStartLoc.getLine()) { addAttribute("endline", PLoc.getLine()); addAttribute("endcol", PLoc.getColumn()); } else { addAttribute("endcol", PLoc.getColumn()); } } } }
//--------------------------------------------------------- void DocumentXML::addContextsRecursively(const DeclContext *DC) { if (DC != 0 && addToMap(Contexts, DC)) { addContextsRecursively(DC->getParent()); } }
bool SPIPlugin::openOutput(quint32 output, quint32 universe) { if (output != 0) return false; m_referenceCount++; addToMap(universe, output, Output); if (m_spifd != -1) return true; m_spifd = open(SPI_DEFAULT_DEVICE, O_RDWR); if(m_spifd < 0) { qWarning() << "Cannot open SPI device !"; return false; } QSettings settings; int speed = 1000000; QVariant value = settings.value("SPIPlugin/frequency"); if (value.isValid() == true) speed = value.toUInt(); m_outThread = new SPIOutThread(); m_outThread->runThread(m_spifd, speed); return true; }
/** * @brief * * @param cl4ss * @param name */ AudioProvider::AudioProvider( const std::string &cl4ss, const std::string &name ) { mHasAudio = true; setIdentity( cl4ss, name ); addToMap(); //Info( "AudioProvider : %s + %s", mTag.c_str(), mId.c_str() ); }
bool DMXUSB::openOutput(quint32 output, quint32 universe) { if (output < quint32(m_outputs.size())) { addToMap(universe, output, Output); return m_outputs.at(output)->open(output, false); } return false; }
void* UA_memoryManager_malloc(size_t size) { if (totalMemorySize + size > memoryLimit) return NULL; void *addr = malloc(size); if (!addr) return NULL; addToMap(size, addr); return addr; }
void* UA_memoryManager_calloc(size_t num, size_t size) { if (totalMemorySize + (size * num) > memoryLimit) return NULL; void *addr = calloc(num, size); if (!addr) return NULL; addToMap(size*num, addr); return addr; }
/** * Convert a Ruby Hash to a map * * @param t the Ruby Hash to convert * @return a new map */ map* mapFromRubyHash(VALUE t){ map* res=NULL; VALUE list; list = rb_ary_new(); typedef int (*HOOK)(...); rb_hash_foreach(t,reinterpret_cast<HOOK>(keys_i), list); int nb=RHASH_TBL(t)->num_entries; int i; for(i=0;i<nb;i++){ VALUE key=rb_ary_pop(list); VALUE value=rb_hash_aref(t,key); #ifdef DEBUG fprintf(stderr,">> DEBUG VALUES : %s => %s\n", StringValueCStr(key),StringValueCStr(value)); #endif if(strcmp(StringValueCStr(key),"value")==0){ char *buffer=NULL; int size=RSTRING_LEN(value); buffer=StringValueCStr(value); if(res!=NULL){ addToMap(res,StringValueCStr(key),""); }else{ res=createMap(StringValueCStr(key),""); } map* tmpR=getMap(res,"value"); free(tmpR->value); tmpR->value=(char*)malloc((size+1)*sizeof(char)); memmove(tmpR->value,buffer,size*sizeof(char)); tmpR->value[size]=0; char sin[1024]; sprintf(sin,"%d",size); addToMap(res,"size",sin); }else{ if(res!=NULL){ addToMap(res,StringValueCStr(key),StringValueCStr(value)); } else{ res= createMap(StringValueCStr(key),StringValueCStr(value)); } } } return res; }
bool cManager::add(cFile toAdd) { // cout << DBG << "File to add: " << toAdd.getName() << endl; string hash = getHash(toAdd); if (!addToMap(hash, toAdd)) { // cout << DBG << "Can't add to map " << toAdd.getName() << endl; return false; } //displayMap(); return true; }
/** * Convert a JavaScript Object to a map * * @param cx the JavaScript context * @param t the JavaScript Object to convert * @return a new map containing the JavaScript Object */ map* mapFromJSObject(JSContext *cx,jsval t){ map *res=NULL; JSIdArray *idp=JS_Enumerate(cx,JSVAL_TO_OBJECT(t)); #ifdef JS_DEBUG fprintf(stderr,"Properties %p\n",(void*)t); #endif if(idp!=NULL) { int index; jsdouble argNum; #ifdef JS_DEBUG fprintf(stderr,"Properties length : %d \n",idp->length); #endif for (index=0,argNum=idp->length;index<argNum;index++) { jsval id = idp->vector[index]; jsval vp; JS_IdToValue(cx,id,&vp); char *tmp, *tmp1; JSString *jsmsg,*jsmsg1; size_t len,len1; jsmsg = JS_ValueToString(cx,vp); len = JS_GetStringLength(jsmsg); jsval nvp; tmp=JS_EncodeString(cx,jsmsg); JS_GetProperty(cx, JSVAL_TO_OBJECT(t), tmp, &nvp); jsmsg1 = JS_ValueToString(cx,nvp); len1 = JS_GetStringLength(jsmsg1); tmp1=JS_EncodeString(cx,jsmsg1); #ifdef JS_DEBUG fprintf(stderr,"Enumerate id : %d [ %s => %s ]\n",index,tmp,tmp1); #endif if(strcasecmp(tmp,"child")!=0){ if(res!=NULL){ #ifdef JS_DEBUG fprintf(stderr,"%s - %s\n",tmp,tmp1); #endif addToMap(res,tmp,tmp1); } else{ res=createMap(tmp,tmp1); res->next=NULL; } } free(tmp); free(tmp1); #ifdef JS_DEBUG dumpMap(res); #endif } JS_DestroyIdArray(cx,idp); } #ifdef JS_DEBUG dumpMap(res); #endif return res; }
bool GPIOPlugin::openOutput(quint32 output, quint32 universe) { if (output != 0) return false; m_outputUniverse = universe; addToMap(universe, output, Output); return true; }
void CompPinStruct::setRefDes(const CString& refDes) { if (m_refDes != refDes) { removeFromMap(); m_refDes = refDes; addToMap(); } }
void CompPinStruct::setPinName(const CString& pinName) { if (m_pinName != pinName) { removeFromMap(); m_pinName = pinName; addToMap(); } }
/** * Convert a php Array to a map * * @param t the php Array to convert * @return the created map */ map* php_map_from_HasTable(HashTable* t){ #ifdef DEBUG fprintf(stderr,"mapsFromPHPArray start\n"); #endif map* final_res=(map*)malloc(MAP_SIZE); final_res=NULL; char key[1024]; for(zend_hash_internal_pointer_reset(t); zend_hash_has_more_elements(t) == SUCCESS; zend_hash_move_forward(t)) { char *key; uint keylen; ulong idx; int type; int len; zval **ppzval, tmpcopy; type = zend_hash_get_current_key_ex(t, &key, &keylen, &idx, 0, NULL); if (zend_hash_get_current_data(t, (void**)&ppzval) == FAILURE) { /* Should never actually fail * since the key is known to exist. */ continue; } /** * Duplicate the zval so that * the orignal’s contents are not destroyed */ tmpcopy = **ppzval; zval_copy_ctor(&tmpcopy); /** * Reset refcount & Convert */ INIT_PZVAL(&tmpcopy); convert_to_string(&tmpcopy); if(strncmp(key,"value",5)==0){ len=Z_STRLEN_P(&tmpcopy); final_res = addToMapWithSize(final_res,key,Z_STRVAL_P(&tmpcopy),len); } else{ if(final_res==NULL){ #ifdef DEBUG fprintf(stderr,"%s => %s\n",key,Z_STRVAL(tmpcopy)); #endif final_res=createMap(key,Z_STRVAL(tmpcopy)); } else{ #ifdef DEBUG fprintf(stderr,"%s => %s\n",key,Z_STRVAL(tmpcopy)); #endif addToMap(final_res,key,Z_STRVAL(tmpcopy)); } } /* Toss out old copy */ zval_dtor(&tmpcopy); } return final_res; }
void* UA_memoryManager_realloc(void *ptr, size_t new_size) { removeFromMap(ptr); if (totalMemorySize + new_size > memoryLimit) return NULL; void *addr = realloc(ptr, new_size); if (!addr) return NULL; addToMap(new_size, addr); return addr; }
/********************************************************************* * Outputs *********************************************************************/ bool HIDPlugin::openOutput(quint32 output, quint32 universe) { HIDDevice* dev = deviceOutput(output); if (dev != NULL) { addToMap(universe, output, Output); return dev->openOutput(); } else qDebug() << name() << "has no output number:" << output; return false; }
//--------------------------------------------------------- void DocumentXML::addTypeRecursively(const QualType& pType) { if (addToMap(Types, pType)) { addTypeRecursively(pType.getTypePtr()); // beautifier: a non-qualified type shall be transparent if (!pType.hasLocalQualifiers()) { Types[pType] = BasicTypes[pType.getTypePtr()]; } } }
void Map<KEY, T>::copyThread(Elem* &newRoot, Elem* origRoot){ // construct the key-element map for new and orig tree map<KEY, Elem*> newKeyElemMap; map<KEY, Elem*> origKeyElemMap; addToMap(newRoot->left, newKeyElemMap); addToMap(origRoot->left, origKeyElemMap); // start at the last element in the tree, which threads to root typename std::map<KEY, Elem*>::reverse_iterator it = origKeyElemMap.rbegin(); newKeyElemMap[it->first] -> rightThread = true; newKeyElemMap[it->first] -> right = newRoot; // then thread the rest of the tree backwardly it++; while(it != origKeyElemMap.rend()){ if (it->second->rightThread){ newKeyElemMap[it->first] -> rightThread = true; newKeyElemMap[it->first] -> right = newKeyElemMap[ origKeyElemMap[it->first]->right->key ]; } it++; } }
//--------------------------------------------------------- void DocumentXML::addPtrAttribute(const char* pAttributeName, const NamedDecl* D) { if (const DeclContext* DC = dyn_cast<DeclContext>(D)) { addContextsRecursively(DC); addAttribute(pAttributeName, getPrefixedId(Contexts[DC], ID_NORMAL)); } else { addToMap(Decls, D); addAttribute(pAttributeName, getPrefixedId(Decls[D], ID_NORMAL)); } }
bool OS2LPlugin::openInput(quint32 input, quint32 universe) { if (input != 0) return false; m_inputUniverse = universe; addToMap(universe, input, Input); enableTCPServer(true); return true; }
bool HIDPlugin::openInput(quint32 input, quint32 universe) { HIDDevice* dev = device(input); if (dev != NULL) { connect(dev, SIGNAL(valueChanged(quint32,quint32,quint32,uchar)), this, SIGNAL(valueChanged(quint32,quint32,quint32,uchar))); addToMap(universe, input, Input); return dev->openInput(); } else qDebug() << name() << "has no input number:" << input; return false; }
Definition::Definition(const char *df,int dl, const char *name,const char *b, const char *d,bool isSymbol) { m_name = name; m_impl = new DefinitionImpl; m_impl->init(df,dl,name); m_isSymbol = isSymbol; if (isSymbol) addToMap(name,this); _setBriefDescription(b,df,dl); _setDocumentation(d,df,dl,TRUE,FALSE); if (matchExcludedSymbols(name)) { m_impl->hidden = TRUE; } }
//--------------------------------------------------------- void DocumentXML::addTypeRecursively(const Type* pType) { if (addToMap(BasicTypes, pType)) { addParentTypes(pType); /* // FIXME: doesn't work in the immediate streaming approach if (const VariableArrayType *VAT = dyn_cast<VariableArrayType>(pType)) { addSubNode("VariableArraySizeExpression"); PrintStmt(VAT->getSizeExpr()); toParent(); } */ } }
bool DMXUSB::openInput(quint32 input, quint32 universe) { if (input < quint32(m_inputs.size())) { DMXUSBWidget *widget = m_inputs.at(input); if (widget->type() == DMXUSBWidget::ProRXTX || widget->type() == DMXUSBWidget::ProMk2 || widget->type() == DMXUSBWidget::UltraPro) { EnttecDMXUSBPro *pro = static_cast<EnttecDMXUSBPro*>(widget); connect(pro, SIGNAL(valueChanged(quint32,quint32,quint32,uchar)), this, SIGNAL(valueChanged(quint32,quint32,quint32,uchar))); } addToMap(universe, input, Input); return widget->open(input, true); } return false; }
//_____________________________________________________________________________ CompPinStruct::CompPinStruct(CCompPinList& parentCompPinList,const CString& refDes,const CString& pinName,int entityNumber) : m_parentCompPinList(parentCompPinList) , m_refDes(refDes) , m_pinName(pinName) , m_entityNumber(entityNumber) , m_attributes(NULL) , m_x(0.) , m_y(0.) , m_rotationRadians(0.) , m_mirror(0) , m_pinCoordinatesComplete(0) , m_visible(visibleNone) , m_padstackBlockNumber(-1) { getCamCadData().allocateEntityNumber(m_entityNumber); addToMap(); }