Ignore:
Timestamp:
Jun 7, 2012, 10:54:31 PM (12 years ago)
Author:
djay
Message:

Add support for multiple inputs values for the same identifier.

File:
1 edited

Legend:

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

    r348 r360  
    22 * Author : Gérald FENOY
    33 *
    4  * Copyright (c) 2009-2010 GeoLabs SARL
     4 * Copyright (c) 2009-2012 GeoLabs SARL
    55 *
    66 * Permission is hereby granted, free of charge, to any person obtaining a copy
     
    352352  jsval resf =  OBJECT_TO_JSVAL(res);
    353353  map* tmpm=t;
     354  map* isArray=getMap(t,"isArray");
     355  map* isBinary=getMap(t,"size");
     356  map* tmap=getMapType(t);
     357  if(tmap==NULL)
     358    fprintf(stderr,"tmap is null !\n");
     359  else
     360    fprintf(stderr,"tmap is not null ! (%s = %s)\n",tmap->name,tmap->value);
     361
     362  /* Avoid gesture of binary content which failed due to strlen function use */
     363  if(isBinary!=NULL){
     364    return res;
     365  }
    354366  while(tmpm!=NULL){
    355     jsval jsstr = STRING_TO_JSVAL(JS_NewStringCopyN(cx,tmpm->value,strlen(tmpm->value)));
    356     JS_SetProperty(cx, res, tmpm->name,&jsstr);
    357 #ifdef JS_DEBUG
    358     fprintf(stderr,"%s => %s\n",tmpm->name,tmpm->value);
    359 #endif
     367    if(isArray==NULL || strncasecmp(tmpm->name,"value",5)!=0 ||
     368       (tmap!=NULL && strncasecmp(tmpm->name,tmap->name,strlen(tmap->name))!=0)){
     369      jsval jsstr = STRING_TO_JSVAL(JS_NewStringCopyN(cx,tmpm->value,strlen(tmpm->value)));
     370      JS_SetProperty(cx, res, tmpm->name,&jsstr);
     371#ifdef JS_DEBUG
     372      fprintf(stderr,"%s => %s\n",tmpm->name,tmpm->value);
     373#endif
     374    }
    360375    tmpm=tmpm->next;
     376  }
     377  if(isArray!=NULL){
     378    map* len=getMap(t,"length");
     379    int cnt=atoi(len->value);
     380    JSObject* values=JS_NewArrayObject( cx, cnt, NULL );
     381    JSObject* mvalues=JS_NewArrayObject( cx, cnt, NULL );
     382    map *tmpm1,*tmpm2;
     383    int i=0;
     384    for(i=0;i<cnt;i++){
     385      tmpm1=getMapArray(t,"value",i);
     386      tmpm2=getMapArray(t,tmap->name,i);
     387      if(tmpm1!=NULL){
     388        jsval jsstr = STRING_TO_JSVAL(JS_NewStringCopyN(cx,tmpm1->value,strlen(tmpm1->value)));
     389        JS_SetElement( cx, values, i, &jsstr );
     390      }
     391      if(tmpm2!=NULL){
     392        jsval jsstr = STRING_TO_JSVAL(JS_NewStringCopyN(cx,tmpm2->value,strlen(tmpm2->value)));
     393        JS_SetElement( cx, mvalues, i, &jsstr );
     394      }
     395    }
     396    jsval jvalues=OBJECT_TO_JSVAL(values);
     397    jsval jmvalues=OBJECT_TO_JSVAL(mvalues);
     398    JS_SetProperty(cx, res,"value",&jvalues);
     399    JS_SetProperty(cx, res,tmap->name,&jmvalues);
    361400  }
    362401  return res;
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