Changeset 336


Ignore:
Timestamp:
Sep 22, 2011, 2:59:40 PM (13 years ago)
Author:
djay
Message:

Add support for importScript javascript function

Location:
trunk/zoo-project
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/HISTORY.txt

    r328 r336  
    33  * Support for dataInputs URLEncoded and xlink:href (ticket #62)
    44  * Use the same object structure for JavaScript arguments than for Python
     5  * Add the Normalized Difference Vegetation Index service
     6  * Add importScripts function to JavaScript support (ticket #66)
    57
    68Version 1.2.0-rc3
  • trunk/zoo-project/zoo-kernel/service_internal_js.c

    r333 r336  
    4242}
    4343
     44JSBool
     45JSLoadScripts(JSContext *cx, uintN argc, jsval *argv1)
     46{
     47  map* request = JS_GetContextPrivate(cx);
     48  map* tmpm1=getMap(request,"metapath");
     49  JS_MaybeGC(cx);
     50
     51  char ntmp[1024];
     52  getcwd(ntmp,1024);
     53
     54  jsval *argv = JS_ARGV(cx,argv1);
     55  int i=0;
     56  JS_MaybeGC(cx);
     57  for(i=0;i<argc;i++){
     58    JSString* jsmsg = JS_ValueToString(cx,argv[i]);
     59    char *filename = JSValToChar(cx,&argv[i]);
     60    char api0[strlen(tmpm1->value)+strlen(ntmp)+strlen(filename)+2];
     61    sprintf(api0,"%s/%s/%s",ntmp,tmpm1->value,filename);
     62#ifdef JS_DEBUG
     63    fprintf(stderr,"Trying to load %s\n",api0);
     64#endif
     65    JSObject *api_script1=loadZooApiFile(cx,JS_GetGlobalObject(cx),api0);
     66    fflush(stderr);
     67  }
     68  JS_MaybeGC(cx);
     69  JS_SET_RVAL(cx, argv1, JSVAL_VOID);
     70 
     71  return JS_TRUE;
     72}
     73
     74
    4475int zoo_js_support(maps** main_conf,map* request,service* s,
    4576                   maps **inputs,maps **outputs)
     
    94125    return 1;
    95126  if (!JS_DefineFunction(cx, global, "alert", JSAlert, 2, 0))
     127    return 1; 
     128  if (!JS_DefineFunction(cx, global, "importScripts", JSLoadScripts, 1, 0))
    96129    return 1;
    97130
     131  /**
     132   * Add private context object
     133   */
     134  void* cxPrivate = request;
     135  JS_SetContextPrivate(cx,cxPrivate);
     136   
    98137  map* tmpm1=getMap(request,"metapath");
    99138  char ntmp[1024];
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