/** * Convert a Ruby Hash to a maps * * @param t the Ruby Hash to convert * @return a new maps */ maps* mapsFromRubyHash(VALUE t){ maps* res=NULL; maps* cursor=res; VALUE list; list = rb_ary_new(); typedef int (*HOOK)(...); rb_hash_foreach(t, reinterpret_cast<HOOK>(keys_i), list); int nb=rb_hash_size(t); int i; for(i=0;i<FIX2INT(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 cursor=createMaps(StringValueCStr(key)); cursor->content=mapFromRubyHash(value); if(res==NULL) res=dupMaps(&cursor); else addMapsToMaps(&res,cursor); freeMaps(&cursor); free(cursor); } return res; }
TransverseCurveSearchWidget::TransverseCurveSearchWidget(balazs::SepSegmentDatabase &ssDatabase, QWidget *parent) : QWidget(parent), sepSegmentDatabase(ssDatabase) { tcTreeWidget = new QTreeWidget; tcTreeWidget->setFont(QFont("Times", 12)); // tcTreeWidget->setColumnCount(4); QStringList list; list << tr("Length") << tr("Lengths/twist") << tr("N. lengths/twist") << tr("Permutation") << tr("Transition matrix") << tr("Inverse matrix"); for(std::size_t i = 0; i <= sepSegmentDatabase.foliation().numIntervals(); i++){ list << tr("Eigenvector %1").arg(i); } for(std::size_t i = 0; i <= sepSegmentDatabase.foliation().numIntervals(); i++){ list << tr("Eigenvector %1").arg(i); } tcTreeWidget->setHeaderLabels(list); for(std::size_t i = 0; i <= sepSegmentDatabase.foliation().numIntervals(); i++){ tcTreeWidget->setColumnWidth(6 + i, 130); } connect(tcTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(onCurrentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*))); createMaps(); modeLabel = new QLabel(tr("Mode:")); modeComboBox = new QComboBox; foreach(const QString& s, relevantStrings){ modeComboBox->addItem(s); }
/** * Add a request in the download queue * * @param m the maps containing the settings of the main.cfg file * @param url the url to add to the queue */ void addRequestToQueue(maps** m,HINTERNET* hInternet,const char* url,bool req){ hInternet->waitingRequests[hInternet->nb]=strdup(url); if(req) InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0); maps *oreq=getMaps(*m,"orequests"); if(oreq==NULL){ oreq=createMaps("orequests"); oreq->content=createMap("value",url); addMapsToMaps(m,oreq); freeMaps(&oreq); free(oreq); }else{ setMapArray(oreq->content,"value",hInternet->nb-1,url); } }
S3DModel::S3DModel(const S3DModel& model) { mRootJoint = new Joint(*(model.mRootJoint)); mId = -2; mNbJoints = -1; mPartitionNumber = 0; mIsVisible = model.mIsVisible; createMaps(); createOrientationVec(); createOffsetVec(); createNameVec(); createConstraintVecs(); createDefaultVecs(); createPartitionMultimaps(); //std::cout << "S3DModel : model index successfully created !" << std::endl; }
S3DModel::S3DModel(const Joint* jt, unsigned int id) { mRootJoint = new Joint(*jt); mId = id; mNbJoints = -1; mPartitionNumber = 0; mIsVisible = true; createMaps(); createOrientationVec(); createOffsetVec(); createNameVec(); createConstraintVecs(); createDefaultVecs(); createPartitionMultimaps(); //std::cout << "S3DModel : model index successfully created !" << std::endl; }
void S3DModel::createMaps(vector<Joint*>& jts) { if (jts.size() > 0) { for (int i=0 ; i < jts.size() ; i++) { mNbJoints++; mStringToJoint[jts[i]->getName()] = jts[i]; mIntToJoint[mNbJoints] = jts[i]; mStringToInt[jts[i]->getName()] = mNbJoints; if (jts[i]->hasChildren()) { vector<Joint*> children = jts[i]->getChildren(); createMaps(children); } } } }
void S3DModel::createMaps() { mStringToJoint.clear(); mIntToJoint.clear(); mStringToInt.clear(); if (mRootJoint != NULL) { mNbJoints++; mStringToJoint[mRootJoint->getName()] = mRootJoint; mIntToJoint[mNbJoints] = mRootJoint; mStringToInt[mRootJoint->getName()] = mNbJoints; if (mRootJoint->hasChildren()) { vector<Joint*> children = mRootJoint->getChildren(); createMaps(children); } } }
GenericEpetraProblem::GenericEpetraProblem(const Epetra_Comm& comm, int numGlobalNodes, string name_) : myId(0), myName(name_), OverlapMap(0), Importer(0), Comm(&comm), StandardMap(0), NumGlobalNodes(numGlobalNodes) { // Commonly used variables MyPID = Comm->MyPID(); // Process ID NumProc = Comm->NumProc(); // Total number of processes // Construct data layout createMaps(); // Construction and initialization of mesh and solution vectors are // left to the derived problem class. }
/** * Convert a JavaScript Object to a maps * * @param cx the JavaScript context * @param t the JavaScript Object to convert * @return a new maps containing the JavaScript Object */ maps* mapsFromJSObject(JSContext *cx,jsval t){ maps *res=NULL; maps *tres=NULL; jsint oi=0; JSObject* tt=JSVAL_TO_OBJECT(t); if(JS_IsArrayObject(cx,tt)){ #ifdef JS_DEBUG fprintf(stderr,"Is finally an array !\n"); #endif } else{ #ifdef JS_DEBUG fprintf(stderr,"Is not an array !\n"); #endif JSIdArray *idp=JS_Enumerate(cx,tt); 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; JSString *jsmsg; size_t len1; jsmsg = JS_ValueToString(cx,vp); len1 = JS_GetStringLength(jsmsg); tmp=JS_EncodeString(cx,jsmsg); tres=createMaps(tmp); jsval nvp=JSVAL_NULL; if((JS_GetProperty(cx, tt, tmp, &nvp)==JS_FALSE)){ #ifdef JS_DEBUG fprintf(stderr,"Enumerate id : %d => %s => No more value\n",oi,tmp); #endif } free(tmp); JSObject *nvp1=JSVAL_TO_OBJECT(JSVAL_NULL); JS_ValueToObject(cx,nvp,&nvp1); jsval nvp1j=OBJECT_TO_JSVAL(nvp1); if(JSVAL_IS_OBJECT(nvp1j)){ tres->content=mapFromJSObject(cx,nvp1j); } jsval nvp0=JSVAL_NULL; JSObject *nvp01=JSVAL_TO_OBJECT(JSVAL_NULL); if((JS_GetProperty(cx, nvp1, "child", &nvp0)==JS_FALSE)){ #ifdef JS_DEBUG fprintf(stderr,"Enumerate id : %d => %s => No more value\n",oi,tmp); #endif } JS_ValueToObject(cx,nvp0,&nvp01); jsval nvp01j=OBJECT_TO_JSVAL(nvp01); if(!JSVAL_IS_NULL(nvp01j)){ tres->child=mapsFromJSObject(cx,nvp01j); } if(res==NULL) res=dupMaps(&tres); else addMapsToMaps(&res,tres); freeMaps(&tres); free(tres); tres=NULL; } JS_DestroyIdArray(cx,idp); } } jsuint len; JSBool hasLen=JS_GetArrayLength(cx, tt, &len); #ifdef JS_DEBUG if(hasLen==JS_FALSE){ fprintf(stderr,"outputs array is empty\n"); } fprintf(stderr,"outputs array length : %d\n",len); #endif for(oi=0;hasLen && oi < len;oi++){ #ifdef JS_DEBUG fprintf(stderr,"outputs array length : %d step %d \n",len,oi); #endif jsval tmp1; JSBool hasElement=JS_GetElement(cx,tt,oi,&tmp1); JSObject *otmp1=JSVAL_TO_OBJECT(tmp1); JSIdArray *idp=JS_Enumerate(cx,otmp1); if(idp!=NULL) { int index; jsdouble argNum; #ifdef JS_DEBUG fprintf(stderr,"Properties length : %d \n",idp->length); #endif tres=(maps*)malloc(MAPS_SIZE); tres->name=NULL; tres->content=NULL; tres->next=NULL; for (index=0,argNum=idp->length;index<argNum;index++) { jsval id = idp->vector[index]; jsval vp; JS_IdToValue(cx,id,&vp); char *tmp; JSString *jsmsg; size_t len1; jsmsg = JS_ValueToString(cx,vp); len1 = JS_GetStringLength(jsmsg); tmp=JS_EncodeString(cx,jsmsg); #ifdef JS_DEBUG fprintf(stderr,"Enumerate id : %d => %s\n",oi,tmp); #endif jsval nvp=JSVAL_NULL; if((JS_GetProperty(cx, JSVAL_TO_OBJECT(tmp1), tmp, &nvp)==JS_FALSE)){ #ifdef JS_DEBUG fprintf(stderr,"Enumerate id : %d => %s => No more value\n",oi,tmp); #endif } free(tmp); if(JSVAL_IS_OBJECT(nvp)){ #ifdef JS_DEBUG fprintf(stderr,"JSVAL NVP IS OBJECT\n"); #endif } JSObject *nvp1=JSVAL_TO_OBJECT(JSVAL_NULL); JS_ValueToObject(cx,nvp,&nvp1); jsval nvp1j=OBJECT_TO_JSVAL(nvp1); if(JSVAL_IS_OBJECT(nvp1j)){ JSString *jsmsg1; char *tmp1, *tmp2; JSObject *nvp2=JSVAL_TO_OBJECT(JSVAL_NULL); jsmsg1 = JS_ValueToString(cx,nvp1j); len1 = JS_GetStringLength(jsmsg1); tmp1=JS_EncodeString(cx,jsmsg1); tmp2=JS_EncodeString(cx,jsmsg); #ifdef JS_DEBUG fprintf(stderr,"JSVAL NVP1J IS OBJECT %s = %s\n",JS_EncodeString(cx,jsmsg),tmp1); #endif if(strcasecmp(tmp1,"[object Object]")==0){ tres->name=zStrdup(tmp2); tres->content=mapFromJSObject(cx,nvp1j); } else if(strcasecmp(tmp2,"name")==0){ tres->name=zStrdup(tmp1); } else{ if(tres->content==NULL) tres->content=createMap(tmp2,tmp1); else addToMap(tres->content,tmp2,tmp1); } free(tmp1); free(tmp2); } #ifdef JS_DEBUG else fprintf(stderr,"JSVAL NVP1J IS NOT OBJECT !!\n"); #endif } #ifdef JS_DEBUG dumpMaps(tres); #endif if(res==NULL) res=dupMaps(&tres); else addMapsToMaps(&res,tres); freeMaps(&tres); free(tres); tres=NULL; JS_DestroyIdArray(cx,idp); } } #ifdef JS_DEBUG dumpMaps(res); #endif return res; }
/** * Convert a php Array to a maps * * @param t the php Array to convert * @return the created maps */ maps* php_maps_from_Array(HashTable *t){ maps* final_res=NULL; maps* cursor=final_res; 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; 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; #ifdef DEBUG fprintf(stderr,"key : %s\n",key); #endif zval_copy_ctor(&tmpcopy); #ifdef DEBUG fprintf(stderr,"key : %s\n",key); #endif /** * Reset refcount & Convert */ INIT_PZVAL(&tmpcopy); //convert_to_string(&tmpcopy); if (type == HASH_KEY_IS_STRING) { /** * String Key / Associative */ cursor=createMaps(key); #ifdef DEBUG fprintf(stderr,"key : %s\n",key); #endif HashTable* t=HASH_OF(*ppzval); #ifdef DEBUG fprintf(stderr,"key : %s\n",key); #endif cursor->content=php_map_from_HasTable(t); cursor->next=NULL; if(final_res==NULL) final_res=dupMaps(&cursor); else{ addMapsToMaps(&final_res,cursor); } freeMaps(&cursor); free(cursor); } #ifdef DEBUG fprintf(stderr,"key : %s\n",key); #endif /** * Toss out old copy */ zval_dtor(&tmpcopy); } return final_res; }