Exemplo n.º 1
0
static int create_accessor(grib_section* p, grib_action* act,grib_loader *h)
{
	grib_action_put* a = ( grib_action_put*)act;

	grib_section* ts = NULL;

	grib_accessor* ga = NULL;

	ga = grib_find_accessor(p->h, grib_arguments_get_name(p->h,a->args,1));
	if(ga)
		ts = ga->sub_section;
		/* ts = grib_get_sub_section(ga); */
	else  return GRIB_BUFFER_TOO_SMALL;

	if(ts){
		ga = grib_accessor_factory( ts, act,0,a->args);
		if(ga)grib_push_accessor(ga,ts->block);
		else  return GRIB_BUFFER_TOO_SMALL;

	}
	else{
		grib_context_log(act->context, GRIB_LOG_ERROR, "Action_class_put  : create_accessor_buffer : No Section named %s to export %s ", grib_arguments_get_name(p->h,a->args,1), grib_arguments_get_name(p->h,a->args,0));
	}
	return GRIB_SUCCESS; 
}
Exemplo n.º 2
0
static int  create_accessor(grib_section* p, grib_action* act, grib_loader *h )
{
	int ret = GRIB_SUCCESS;
	grib_action_trigger* a = ( grib_action_trigger*)act;
	grib_action* next = NULL;
	grib_accessor* as = NULL;
	grib_section*         gs = NULL;


	as = grib_accessor_factory(p, act,0,NULL);  

	if(!as) return GRIB_INTERNAL_ERROR;

	gs = as->sub_section;
	gs->branch = 0; /* Force a reparse each time */

	grib_push_accessor(as,p->block);
	grib_dependency_observe_arguments(as,a->trigger_on);

	next = a->block;

	while(next){
		ret = grib_create_accessor(gs, next,h);
		if(ret != GRIB_SUCCESS) return ret;
		next= next->next;
	}

	return GRIB_SUCCESS;

}
Exemplo n.º 3
0
static int  create_accessor(grib_section* p, grib_action* act, grib_loader *h ){
  int ret = GRIB_SUCCESS;
  grib_action_template* a = ( grib_action_template*)act;
  grib_action* la = NULL;
  grib_action* next = NULL;
  grib_accessor* as = NULL;
  grib_section*         gs = NULL;

  char fname[1024]={0,};
  char *fpath=0;

  as = grib_accessor_factory(p, act,0,NULL);

  if(!as) return GRIB_INTERNAL_ERROR;
  if(a->arg){
    ret = grib_recompose_name(p->h,as,a->arg,fname,1);

	if ((fpath=grib_context_full_defs_path(p->h->context,fname))==NULL) {
      if (!a->nofail) {
        grib_context_log(p->h->context,GRIB_LOG_ERROR,
                         "Unable to find template %s from %s ",act->name,fname);
        return GRIB_FILE_NOT_FOUND;
      }
	  la = get_empty_template(p->h->context,&ret);
	  if (ret) return ret;
    } else 
      la = grib_parse_file(p->h->context, fpath);
  }
  as->flags |= GRIB_ACCESSOR_FLAG_HIDDEN;
  gs = as->sub_section;
  gs->branch = la; /* Will be used to prevent unecessary reparse */

  grib_push_accessor(as,p->block);

  if(la){
    next = la;

    while(next){
      ret = grib_create_accessor(gs, next,h);
      if(ret != GRIB_SUCCESS) {
      if(p->h->context->debug)
    {
      grib_context_log(p->h->context,GRIB_LOG_ERROR,
      "Error processing template %s: %s [%s] %04lx",
      fname,grib_get_error_message(ret),next->name,next->flags);
    }
      return ret;
    }
      next= next->next;
    }
  }
  return GRIB_SUCCESS;
}
Exemplo n.º 4
0
static int create_accessor( grib_section* p, grib_action* act, grib_loader *loader)
{
    grib_action_gen* a = ( grib_action_gen*)act;
    grib_accessor* ga = NULL;

    ga = grib_accessor_factory( p, act,a->len,a->params);
    if(!ga) return GRIB_INTERNAL_ERROR;

    grib_push_accessor(ga,p->block);

    if(ga->flags & GRIB_ACCESSOR_FLAG_CONSTRAINT)
        grib_dependency_observe_arguments(ga,act->default_value);

    if(loader == NULL)
        return GRIB_SUCCESS;
    else
        return loader->init_accessor(loader,ga,act->default_value);
}
Exemplo n.º 5
0
static int create_accessor( grib_section* p, grib_action* act, grib_loader *h)
{
    grib_action_if* a = (grib_action_if*)act;
    grib_action* next = NULL;
    int ret = 0;
    long lres=0;

    grib_accessor* as = NULL;
    grib_section*  gs = NULL;

    as = grib_accessor_factory(p, act,0,NULL);
    if(!as)return GRIB_INTERNAL_ERROR;
    gs = as->sub_section;
    grib_push_accessor(as,p->block);

    if ((ret=grib_expression_evaluate_long(p->h,a->expression,&lres)) != GRIB_SUCCESS)
        return ret;

    if(lres)
        next = a->block_true;
    else
        next = a->block_false;

    if(p->h->context->debug > 1)
    {
        printf("EVALUATE create_accessor_handle ");
        grib_expression_print(p->h->context,a->expression,p->h);
        printf(" [%s][_if%p]\n", (next == a->block_true ? "true":"false"), (void*)a);

        /*grib_dump_action_branch(stdout,next,5);*/
    }

    gs->branch = next;
    grib_dependency_observe_expression(as,a->expression);

    while(next){

        ret = grib_create_accessor(gs, next, h);
        if(ret != GRIB_SUCCESS) return ret;
        next= next->next;
    }

    return GRIB_SUCCESS;
}