kou commented on code in PR #48521:
URL: https://github.com/apache/arrow/pull/48521#discussion_r2646433760
##########
c_glib/arrow-glib/compute.cpp:
##########
@@ -7091,6 +7094,188 @@ garrow_extract_regex_options_new(void)
return GARROW_EXTRACT_REGEX_OPTIONS(options);
}
+enum {
+ PROP_REPLACE_SLICE_OPTIONS_START = 1,
+ PROP_REPLACE_SLICE_OPTIONS_STOP,
+ PROP_REPLACE_SLICE_OPTIONS_REPLACEMENT,
+};
+
+typedef struct _GArrowReplaceSliceOptionsPrivate
GArrowReplaceSliceOptionsPrivate;
+struct _GArrowReplaceSliceOptionsPrivate
+{
+ gchar *replacement;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(GArrowReplaceSliceOptions,
+ garrow_replace_slice_options,
+ GARROW_TYPE_FUNCTION_OPTIONS)
+
+#define GARROW_REPLACE_SLICE_OPTIONS_GET_PRIVATE(object)
\
+ static_cast<GArrowReplaceSliceOptionsPrivate *>(
\
+ garrow_replace_slice_options_get_instance_private(
\
+ GARROW_REPLACE_SLICE_OPTIONS(object)))
+
+static void
+garrow_replace_slice_options_dispose(GObject *object)
+{
+ auto priv = GARROW_REPLACE_SLICE_OPTIONS_GET_PRIVATE(object);
+ if (priv->replacement) {
+ g_free(priv->replacement);
+ priv->replacement = nullptr;
+ }
+ G_OBJECT_CLASS(garrow_replace_slice_options_parent_class)->dispose(object);
+}
+
+static void
+garrow_replace_slice_options_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ auto options =
+ garrow_replace_slice_options_get_raw(GARROW_REPLACE_SLICE_OPTIONS(object));
+ auto priv = GARROW_REPLACE_SLICE_OPTIONS_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_REPLACE_SLICE_OPTIONS_START:
+ options->start = g_value_get_int64(value);
+ break;
+ case PROP_REPLACE_SLICE_OPTIONS_STOP:
+ options->stop = g_value_get_int64(value);
+ break;
+ case PROP_REPLACE_SLICE_OPTIONS_REPLACEMENT:
+ {
+ const gchar *replacement = g_value_get_string(value);
+ if (priv->replacement) {
+ g_free(priv->replacement);
+ }
+ priv->replacement = g_strdup(replacement);
+ options->replacement = replacement ? replacement : "";
Review Comment:
Why do we need `priv->replacement`?
It seems that we can just use `options->replacement =
g_value_get_string(value)`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]