/*
 * this code is auto generated. do not edit. change the sources in tools/introspection/ instead.
 *
 * the parse tree:
 *
 * typedef
 *   struct dt_iop_grain_params_t
 *     enum _dt_iop_grain_channel_t
 *       DT_GRAIN_CHANNEL_HUE
 *       DT_GRAIN_CHANNEL_SATURATION
 *       DT_GRAIN_CHANNEL_LIGHTNESS
 *       DT_GRAIN_CHANNEL_RGB
 *     channel 
 *       default: DT_GRAIN_CHANNEL_LIGHTNESS
 * 
 *     float
 *     scale 
 *       description: coarseness
 *       default: 1600.0/GRAIN_SCALE_FACTOR
 *       range: 20.0/GRAIN_SCALE_FACTOR .. 6400.0/GRAIN_SCALE_FACTOR
 * 
 *     float
 *     strength 
 *       default: 25.0
 *       range: 0.0 .. 100.0
 * 
 *     float
 *     midtones_bias 
 *       description: mid-tones bias
 *       default: 100.0
 *       range: 0.0 .. 100.0
 * 
 * dt_iop_grain_params_t
 *
 */

#include "/build/darktable/src/darktable-4.0.1/src/iop/grain.c"

#ifdef __cplusplus
extern "C"
{
#endif

#include <string.h>
#include "common/introspection.h"

static dt_introspection_field_t introspection_linear[5+1]
#if !( defined(__cplusplus) && !defined(__clang__) && defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) <= 406) )
= {
{
  .Enum = {
    { DT_INTROSPECTION_TYPE_ENUM, (char*)"_dt_iop_grain_channel_t", (char*)"channel", (char*)"channel", (char*)"", sizeof(((dt_iop_grain_params_t*)NULL)->channel), G_STRUCT_OFFSET(dt_iop_grain_params_t, channel), NULL },
    /*entries*/ 4, /*values*/ NULL, /*Default*/ DT_GRAIN_CHANNEL_LIGHTNESS
  }
},
{
  .Float = {
    { DT_INTROSPECTION_TYPE_FLOAT, (char*)"float", (char*)"scale", (char*)"scale", N_((char*)"coarseness"), sizeof(((dt_iop_grain_params_t*)NULL)->scale), G_STRUCT_OFFSET(dt_iop_grain_params_t, scale), NULL },
    /*Min*/ 20.0/GRAIN_SCALE_FACTOR, /*Max*/ 6400.0/GRAIN_SCALE_FACTOR, /*Default*/ 1600.0/GRAIN_SCALE_FACTOR
  }
},
{
  .Float = {
    { DT_INTROSPECTION_TYPE_FLOAT, (char*)"float", (char*)"strength", (char*)"strength", (char*)"", sizeof(((dt_iop_grain_params_t*)NULL)->strength), G_STRUCT_OFFSET(dt_iop_grain_params_t, strength), NULL },
    /*Min*/ 0.0, /*Max*/ 100.0, /*Default*/ 25.0
  }
},
{
  .Float = {
    { DT_INTROSPECTION_TYPE_FLOAT, (char*)"float", (char*)"midtones_bias", (char*)"midtones_bias", N_((char*)"mid-tones bias"), sizeof(((dt_iop_grain_params_t*)NULL)->midtones_bias), G_STRUCT_OFFSET(dt_iop_grain_params_t, midtones_bias), NULL },
    /*Min*/ 0.0, /*Max*/ 100.0, /*Default*/ 100.0
  }
},
{
  .Struct = {
    { DT_INTROSPECTION_TYPE_STRUCT, (char*)"dt_iop_grain_params_t", (char*)"", (char*)"", (char*)"", sizeof(dt_iop_grain_params_t), 0, NULL },
    /*entries*/ 4, /*fields*/ NULL
  }
},
  { .header = {DT_INTROSPECTION_TYPE_NONE, NULL, NULL, NULL, NULL, 0, 0, NULL} }
}
#endif
;

static dt_introspection_t introspection = {
  8,
  2,
  "dt_iop_grain_params_t",
  sizeof(dt_iop_grain_params_t),
  &introspection_linear[5-1],
  sizeof(dt_iop_module_t),
  G_STRUCT_OFFSET(dt_iop_module_t, default_params)
};

dt_introspection_field_t* get_introspection_linear()
{
  return introspection_linear;
}

dt_introspection_t* get_introspection()
{
  return &introspection;
}

int introspection_init(struct dt_iop_module_so_t *self, int api_version)
{
  // here we check that the generated code matches the api at compile time and also at runtime
  if(introspection.api_version != DT_INTROSPECTION_VERSION || api_version != DT_INTROSPECTION_VERSION)
    return 1;

#if defined(__cplusplus) && !defined(__clang__) && defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) <= 406)
  introspection_linear[0].Enum = {
    { DT_INTROSPECTION_TYPE_ENUM, (char*)"_dt_iop_grain_channel_t", (char*)"channel", (char*)"channel", (char*)"", sizeof(((dt_iop_grain_params_t*)NULL)->channel), G_STRUCT_OFFSET(dt_iop_grain_params_t, channel), NULL },
    /*entries*/ 4, /*values*/ NULL, /*Default*/ DT_GRAIN_CHANNEL_LIGHTNESS
  };
  introspection_linear[1].Float = {
    { DT_INTROSPECTION_TYPE_FLOAT, (char*)"float", (char*)"scale", (char*)"scale", N_((char*)"coarseness"), sizeof(((dt_iop_grain_params_t*)NULL)->scale), G_STRUCT_OFFSET(dt_iop_grain_params_t, scale), NULL },
    /*Min*/ 20.0/GRAIN_SCALE_FACTOR, /*Max*/ 6400.0/GRAIN_SCALE_FACTOR, /*Default*/ 1600.0/GRAIN_SCALE_FACTOR
  };
  introspection_linear[2].Float = {
    { DT_INTROSPECTION_TYPE_FLOAT, (char*)"float", (char*)"strength", (char*)"strength", (char*)"", sizeof(((dt_iop_grain_params_t*)NULL)->strength), G_STRUCT_OFFSET(dt_iop_grain_params_t, strength), NULL },
    /*Min*/ 0.0, /*Max*/ 100.0, /*Default*/ 25.0
  };
  introspection_linear[3].Float = {
    { DT_INTROSPECTION_TYPE_FLOAT, (char*)"float", (char*)"midtones_bias", (char*)"midtones_bias", N_((char*)"mid-tones bias"), sizeof(((dt_iop_grain_params_t*)NULL)->midtones_bias), G_STRUCT_OFFSET(dt_iop_grain_params_t, midtones_bias), NULL },
    /*Min*/ 0.0, /*Max*/ 100.0, /*Default*/ 100.0
  };
  introspection_linear[4].Struct = {
    { DT_INTROSPECTION_TYPE_STRUCT, (char*)"dt_iop_grain_params_t", (char*)"", (char*)"", (char*)"", sizeof(dt_iop_grain_params_t), 0, NULL },
    /*entries*/ 4, /*fields*/ NULL
  };
  introspection_linear[5].header = {DT_INTROSPECTION_TYPE_NONE, NULL, NULL, NULL, NULL, 0, 0, NULL};
#endif

  for(int i = 0; i <= 5; i++)
    introspection_linear[i].header.so = self;

  static dt_introspection_type_enum_tuple_t f0[] = { 
    { "DT_GRAIN_CHANNEL_HUE", DT_GRAIN_CHANNEL_HUE, (char*)"" },
    { "DT_GRAIN_CHANNEL_SATURATION", DT_GRAIN_CHANNEL_SATURATION, (char*)"" },
    { "DT_GRAIN_CHANNEL_LIGHTNESS", DT_GRAIN_CHANNEL_LIGHTNESS, (char*)"" },
    { "DT_GRAIN_CHANNEL_RGB", DT_GRAIN_CHANNEL_RGB, (char*)"" },
    { NULL, 0 },
  };
  static dt_introspection_field_t *f4[] = {
    &introspection_linear[0],
    &introspection_linear[1],
    &introspection_linear[2],
    &introspection_linear[3],
    NULL
  };

  introspection_linear[0].Enum.values = f0;
  introspection_linear[4].Struct.fields = f4;

  return 0;
}

void * get_p(const void * param, const char * name)
{
  dt_iop_grain_params_t * p = (dt_iop_grain_params_t*)param;
  if(!strcmp(name, "channel"))
    return &(p->channel);
  else if(!strcmp(name, "scale"))
    return &(p->scale);
  else if(!strcmp(name, "strength"))
    return &(p->strength);
  else if(!strcmp(name, "midtones_bias"))
    return &(p->midtones_bias);
  else
    return NULL;
}

dt_introspection_field_t * get_f(const char * name)
{
  if(!strcmp(name, "channel"))
    return &(introspection_linear[0]);
  else if(!strcmp(name, "scale"))
    return &(introspection_linear[1]);
  else if(!strcmp(name, "strength"))
    return &(introspection_linear[2]);
  else if(!strcmp(name, "midtones_bias"))
    return &(introspection_linear[3]);
  else
    return NULL;
}

#ifdef __cplusplus
}
#endif

