Changeset 360 for trunk/zoo-project/zoo-kernel/service_internal_js.c
- Timestamp:
- Jun 7, 2012, 10:54:31 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service_internal_js.c
r348 r360 2 2 * Author : Gérald FENOY 3 3 * 4 * Copyright (c) 2009-201 0GeoLabs SARL4 * Copyright (c) 2009-2012 GeoLabs SARL 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a copy … … 352 352 jsval resf = OBJECT_TO_JSVAL(res); 353 353 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 } 354 366 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 } 360 375 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); 361 400 } 362 401 return res;
Note: See TracChangeset
for help on using the changeset viewer.