Changeset 333 for trunk/zoo-project


Ignore:
Timestamp:
Sep 9, 2011, 4:43:47 AM (13 years ago)
Author:
djay
Message:

Small update to support similar outputs for JavaScript? services as Python ones. Still support old format.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/service_internal_js.c

    r329 r333  
    329329  jsint oi=0;
    330330  JSObject* tt=JSVAL_TO_OBJECT(t);
    331 #ifdef JS_DEBUG
    332   fprintf(stderr,"Is finally an array ?\n");
    333331  if(JS_IsArrayObject(cx,tt)){
     332#ifdef JS_DEBUG
    334333    fprintf(stderr,"Is finally an array !\n");
    335   }
    336   else
     334#endif
     335  }
     336  else{
     337#ifdef JS_DEBUG
    337338    fprintf(stderr,"Is not an array !\n");
    338339#endif
     340    JSIdArray *idp=JS_Enumerate(cx,tt);
     341    if(idp!=NULL) {
     342      int index;
     343      jsdouble argNum;
     344#ifdef JS_DEBUG
     345      fprintf(stderr,"Properties length :  %d \n",idp->length);
     346#endif
     347     
     348      for (index=0,argNum=idp->length;index<argNum;index++) {
     349        jsval id = idp->vector[index];
     350        jsval vp;
     351        JSString* str;
     352        JS_IdToValue(cx,id,&vp);
     353        char *c, *tmp;
     354        JSString *jsmsg;
     355        size_t len1;
     356        jsmsg = JS_ValueToString(cx,vp);
     357        len1 = JS_GetStringLength(jsmsg);
     358
     359        tres=(maps*)malloc(MAPS_SIZE);
     360        tres->name=strdup(JS_EncodeString(cx,jsmsg));
     361        tres->content=NULL;
     362        tres->next=NULL;
     363
     364        jsval nvp=JSVAL_NULL;
     365        if((JS_GetProperty(cx, JSVAL_TO_OBJECT(tt), JS_EncodeString(cx,jsmsg), &nvp)==JS_FALSE)){
     366#ifdef JS_DEBUG
     367          fprintf(stderr,"Enumerate id : %d => %s => No more value\n",oi,JS_EncodeString(cx,jsmsg));
     368#endif
     369        }
     370       
     371        JSObject *nvp1=JSVAL_NULL;
     372        JS_ValueToObject(cx,nvp,&nvp1);
     373        jsval nvp1j=OBJECT_TO_JSVAL(nvp1);
     374        if(JSVAL_IS_OBJECT(nvp1j)){
     375          tres->content=mapFromJSObject(cx,nvp1j);
     376        }
     377
     378        if(res==NULL)
     379          res=dupMaps(&tres);
     380        else
     381          addMapsToMaps(&res,tres);
     382        freeMaps(&tres);
     383        free(tres);
     384        tres=NULL;
     385       
     386       
     387      }
     388    }
     389  }
     390
    339391  jsint len;
    340392  JSBool hasLen=JS_GetArrayLength(cx, tt, &len);
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png