Repository: apache/arrow
File: c_glib/arrow-glib/compute.cpp (C++)

Code before:
              GARROW_TYPE_FUNCTION_OPTIONS)

static void
garrow_make_struct_options_init(GArrowMakeStructOptions *object)
{
  auto priv = GARROW_FUNCTION_OPTIONS_GET_PRIVATE(object);
  priv->options = static_cast<arrow::compute::FunctionOptions *>(
    new arrow::compute::MakeStructOptions());
}

static void
garrow_make_struct_options_class_init(GArrowMakeStructOptionsClass *klass)
{
}

/**
 * garrow_make_struct_options_new:
 *
 * Returns: A newly created #GArrowMakeStructOptions.
 *
 * Since: 23.0.0
 */
GArrowMakeStructOptions *
garrow_make_struct_options_new(void)
{
  auto options = g_object_new(GARROW_TYPE_MAKE_STRUCT_OPTIONS, NULL);
  return GARROW_MAKE_STRUCT_OPTIONS(options);
}

/**
 * garrow_make_struct_options_add_field:
 * @options: A #GArrowMakeStructOptions.
 * @name: The name of the field to add.
 * @nullability: Whether the field is nullable.
 * @metadata: (nullable) (element-type utf8 utf8): A #GHashTable for the field's
 *   metadata, or %NULL.
 *
 * Adds a field to the struct options with the specified name, nullability,
 * and optional metadata.
 *
 * Since: 23.0.0
 */
void
garrow_make_struct_options_add_field(GArrowMakeStructOptions *options,
                                     const char *name,
                                     gboolean nullability,
                                     GHashTable *metadata)
{
  auto arrow_options = static_cast<arrow::compute::MakeStructOptions *>(
    garrow_function_options_get_raw(GARROW_FUNCTION_OPTIONS(options)));
  arrow_options->field_names.emplace_back(name);

Review comment (bug):
```suggestion
  auto options = g_object_new(GARROW_TYPE_MAKE_STRUCT_OPTIONS, nullptr);
```

Code after:
GArrowWeekOptions *
garrow_week_options_new(void)
{
  return GARROW_WEEK_OPTIONS(g_object_new(GARROW_TYPE_WEEK_OPTIONS, nullptr));
}

enum {
  PROP_WINSORIZE_OPTIONS_LOWER_LIMIT = 1,
  PROP_WINSORIZE_OPTIONS_UPPER_LIMIT,
};

G_DEFINE_TYPE(GArrowWinsorizeOptions,
              garrow_winsorize_options,
              GARROW_TYPE_FUNCTION_OPTIONS)

static void
garrow_winsorize_options_set_property(GObject *object,
                                      guint prop_id,
                                      const GValue *value,
                                      GParamSpec *pspec)
{
  auto options = garrow_winsorize_options_get_raw(GARROW_WINSORIZE_OPTIONS(object));

  switch (prop_id) {
  case PROP_WINSORIZE_OPTIONS_LOWER_LIMIT:
    options->lower_limit = g_value_get_double(value);
    break;
  case PROP_WINSORIZE_OPTIONS_UPPER_LIMIT:
    options->upper_limit = g_value_get_double(value);
    break;
  default:
    G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
    break;
  }
}

static void
garrow_winsorize_options_get_property(GObject *object,
                                      guint prop_id,
                                      GValue *value,
                                      GParamSpec *pspec)
{
  auto options = garrow_winsorize_options_get_raw(GARROW_WINSORIZE_OPTIONS(object));

  switch (prop_id) {
  case PROP_WINSORIZE_OPTIONS_LOWER_LIMIT:
    g_value_set_double(value, options->lower_limit);
    break;
  case PROP_WINSORIZE_OPTIONS_UPPER_LIMIT:
    g_value_set_double(value, options->upper_limit);
    break;