kou commented on code in PR #44591:
URL: https://github.com/apache/arrow/pull/44591#discussion_r1823678752
##########
c_glib/arrow-glib/decimal.cpp:
##########
@@ -301,16 +319,417 @@ G_BEGIN_DECLS
/**
* SECTION: decimal
* @section_id: decimal
- * @title: 128-bit and 256-bit decimal classes
+ * @title: 64-bit, 128-bit and 256-bit decimal classes
* @include: arrow-glib/arrow-glib.h
*
+ * #GArrowDecimal64 is a 64-bit decimal class.
+ *
* #GArrowDecimal128 is a 128-bit decimal class.
*
* #GArrowDecimal256 is a 256-bit decimal class.
*
* Since: 0.10.0
*/
+typedef struct GArrowDecimal64Private_
+{
+ std::shared_ptr<arrow::Decimal64> decimal64;
+} GArrowDecimal64Private;
+
+enum {
+ PROP_DECIMAL64 = 1
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(GArrowDecimal64, garrow_decimal64, G_TYPE_OBJECT)
+
+#define GARROW_DECIMAL64_GET_PRIVATE(obj)
\
+ static_cast<GArrowDecimal64Private *>(
\
+ garrow_decimal64_get_instance_private(GARROW_DECIMAL64(obj)))
+
+static void
+garrow_decimal64_finalize(GObject *object)
+{
+ auto priv = GARROW_DECIMAL64_GET_PRIVATE(object);
+
+ priv->decimal64.~shared_ptr();
+
+ G_OBJECT_CLASS(garrow_decimal64_parent_class)->finalize(object);
+}
+
+static void
+garrow_decimal64_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GARROW_DECIMAL64_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_DECIMAL64:
+ priv->decimal64 =
+ *static_cast<std::shared_ptr<arrow::Decimal64>
*>(g_value_get_pointer(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+garrow_decimal64_init(GArrowDecimal64 *object)
+{
+ auto priv = GARROW_DECIMAL64_GET_PRIVATE(object);
+ new (&priv->decimal64) std::shared_ptr<arrow::Decimal64>;
+}
+
+static void
+garrow_decimal64_class_init(GArrowDecimal64Class *klass)
+{
+ GParamSpec *spec;
+
+ auto gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->finalize = garrow_decimal64_finalize;
+ gobject_class->set_property = garrow_decimal64_set_property;
+
Review Comment:
Could you move `spec` declaration?
In general, we should declare a variable just before (or when) we use.
```suggestion
auto gobject_class = G_OBJECT_CLASS(klass);
gobject_class->finalize = garrow_decimal64_finalize;
gobject_class->set_property = garrow_decimal64_set_property;
GParamSpec *spec;
```
##########
c_glib/test/test-decimal64.rb:
##########
@@ -0,0 +1,231 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestDecimal64 < Test::Unit::TestCase
+ include Helper::Omittable
+
Review Comment:
Could you remove this and `require_gi_bindings` because we require
gobject-introspection gem 4.2.3 or later?
https://github.com/apache/arrow/blob/5b68eca6cb7ec167cb55d7bdfd6be1850ece963c/c_glib/Gemfile#L23
--
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]