You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2022/07/05 06:22:21 UTC
[arrow] branch master updated: ARROW-16974: [GLib] Make C99 compatible (#13512)
This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new a90a09a4f0 ARROW-16974: [GLib] Make C99 compatible (#13512)
a90a09a4f0 is described below
commit a90a09a4f0e75b8542f8f866d6f2bf7bcdc22ee2
Author: Sutou Kouhei <ko...@clear-code.com>
AuthorDate: Tue Jul 5 15:22:14 2022 +0900
ARROW-16974: [GLib] Make C99 compatible (#13512)
We can't use multiple "typedef struct _XXX XXX" in C99.
Authored-by: Sutou Kouhei <ko...@clear-code.com>
Signed-off-by: Sutou Kouhei <ko...@clear-code.com>
---
c_glib/arrow-dataset-glib/dataset-definition.h | 37 +++++++++++++++++++
c_glib/arrow-dataset-glib/dataset.h | 16 ++-------
c_glib/arrow-dataset-glib/meson.build | 1 +
c_glib/arrow-dataset-glib/scanner.h | 2 +-
c_glib/arrow-glib/basic-array-definition.h | 48 +++++++++++++++++++++++++
c_glib/arrow-glib/basic-array.h | 22 +-----------
c_glib/arrow-glib/basic-data-type.h | 7 ++--
c_glib/arrow-glib/chunked-array-definition.h | 38 ++++++++++++++++++++
c_glib/arrow-glib/chunked-array.h | 12 +------
c_glib/arrow-glib/compute-definition.h | 50 ++++++++++++++++++++++++++
c_glib/arrow-glib/compute.h | 23 +-----------
c_glib/arrow-glib/meson.build | 3 ++
c_glib/arrow-glib/scalar.cpp | 1 +
c_glib/arrow-glib/scalar.h | 3 +-
c_glib/example/meson.build | 12 ++++---
c_glib/meson.build | 1 +
16 files changed, 196 insertions(+), 80 deletions(-)
diff --git a/c_glib/arrow-dataset-glib/dataset-definition.h b/c_glib/arrow-dataset-glib/dataset-definition.h
new file mode 100644
index 0000000000..d0e71b7fbd
--- /dev/null
+++ b/c_glib/arrow-dataset-glib/dataset-definition.h
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <arrow-glib/arrow-glib.h>
+
+G_BEGIN_DECLS
+
+#define GADATASET_TYPE_DATASET (gadataset_dataset_get_type())
+G_DECLARE_DERIVABLE_TYPE(GADatasetDataset,
+ gadataset_dataset,
+ GADATASET,
+ DATASET,
+ GObject)
+struct _GADatasetDatasetClass
+{
+ GObjectClass parent_class;
+};
+
+G_END_DECLS
diff --git a/c_glib/arrow-dataset-glib/dataset.h b/c_glib/arrow-dataset-glib/dataset.h
index 86d077caa9..6c003ca82c 100644
--- a/c_glib/arrow-dataset-glib/dataset.h
+++ b/c_glib/arrow-dataset-glib/dataset.h
@@ -19,24 +19,12 @@
#pragma once
+#include <arrow-dataset-glib/dataset-definition.h>
#include <arrow-dataset-glib/file-format.h>
+#include <arrow-dataset-glib/scanner.h>
G_BEGIN_DECLS
-typedef struct _GADatasetScannerBuilder GADatasetScannerBuilder;
-typedef struct _GADatasetScanner GADatasetScanner;
-
-#define GADATASET_TYPE_DATASET (gadataset_dataset_get_type())
-G_DECLARE_DERIVABLE_TYPE(GADatasetDataset,
- gadataset_dataset,
- GADATASET,
- DATASET,
- GObject)
-struct _GADatasetDatasetClass
-{
- GObjectClass parent_class;
-};
-
GARROW_AVAILABLE_IN_5_0
GADatasetScannerBuilder *
gadataset_dataset_begin_scan(GADatasetDataset *dataset,
diff --git a/c_glib/arrow-dataset-glib/meson.build b/c_glib/arrow-dataset-glib/meson.build
index a88030c43d..3d4521678d 100644
--- a/c_glib/arrow-dataset-glib/meson.build
+++ b/c_glib/arrow-dataset-glib/meson.build
@@ -28,6 +28,7 @@ sources = files(
c_headers = files(
'arrow-dataset-glib.h',
+ 'dataset-definition.h',
'dataset-factory.h',
'dataset.h',
'file-format.h',
diff --git a/c_glib/arrow-dataset-glib/scanner.h b/c_glib/arrow-dataset-glib/scanner.h
index 59da2577d7..464661c9d0 100644
--- a/c_glib/arrow-dataset-glib/scanner.h
+++ b/c_glib/arrow-dataset-glib/scanner.h
@@ -19,7 +19,7 @@
#pragma once
-#include <arrow-dataset-glib/dataset.h>
+#include <arrow-dataset-glib/dataset-definition.h>
#include <arrow-dataset-glib/fragment.h>
G_BEGIN_DECLS
diff --git a/c_glib/arrow-glib/basic-array-definition.h b/c_glib/arrow-glib/basic-array-definition.h
new file mode 100644
index 0000000000..d504422b66
--- /dev/null
+++ b/c_glib/arrow-glib/basic-array-definition.h
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <arrow-glib/gobject-type.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_ARRAY (garrow_array_get_type())
+G_DECLARE_DERIVABLE_TYPE(GArrowArray,
+ garrow_array,
+ GARROW,
+ ARRAY,
+ GObject)
+struct _GArrowArrayClass
+{
+ GObjectClass parent_class;
+};
+
+#define GARROW_TYPE_EXTENSION_ARRAY (garrow_extension_array_get_type())
+G_DECLARE_DERIVABLE_TYPE(GArrowExtensionArray,
+ garrow_extension_array,
+ GARROW,
+ EXTENSION_ARRAY,
+ GArrowArray)
+struct _GArrowExtensionArrayClass
+{
+ GArrowArrayClass parent_class;
+};
+
+G_END_DECLS
diff --git a/c_glib/arrow-glib/basic-array.h b/c_glib/arrow-glib/basic-array.h
index ea5ca18e53..d8104ddb24 100644
--- a/c_glib/arrow-glib/basic-array.h
+++ b/c_glib/arrow-glib/basic-array.h
@@ -19,6 +19,7 @@
#pragma once
+#include <arrow-glib/basic-array-definition.h>
#include <arrow-glib/basic-data-type.h>
#include <arrow-glib/buffer.h>
#include <arrow-glib/interval.h>
@@ -44,17 +45,6 @@ gboolean
garrow_equal_options_is_approx(GArrowEqualOptions *options);
-#define GARROW_TYPE_ARRAY (garrow_array_get_type())
-G_DECLARE_DERIVABLE_TYPE(GArrowArray,
- garrow_array,
- GARROW,
- ARRAY,
- GObject)
-struct _GArrowArrayClass
-{
- GObjectClass parent_class;
-};
-
GARROW_AVAILABLE_IN_6_0
GArrowArray *
garrow_array_import(gpointer c_abi_array,
@@ -764,16 +754,6 @@ gchar *garrow_decimal256_array_format_value(GArrowDecimal256Array *array,
GArrowDecimal256 *garrow_decimal256_array_get_value(GArrowDecimal256Array *array,
gint64 i);
-#define GARROW_TYPE_EXTENSION_ARRAY (garrow_extension_array_get_type())
-G_DECLARE_DERIVABLE_TYPE(GArrowExtensionArray,
- garrow_extension_array,
- GARROW,
- EXTENSION_ARRAY,
- GArrowArray)
-struct _GArrowExtensionArrayClass
-{
- GArrowArrayClass parent_class;
-};
GARROW_AVAILABLE_IN_3_0
GArrowArray *
diff --git a/c_glib/arrow-glib/basic-data-type.h b/c_glib/arrow-glib/basic-data-type.h
index 60412f0bbd..82fe251d31 100644
--- a/c_glib/arrow-glib/basic-data-type.h
+++ b/c_glib/arrow-glib/basic-data-type.h
@@ -19,6 +19,8 @@
#pragma once
+#include <arrow-glib/basic-array-definition.h>
+#include <arrow-glib/chunked-array-definition.h>
#include <arrow-glib/decimal.h>
#include <arrow-glib/type.h>
#include <arrow-glib/version.h>
@@ -619,16 +621,11 @@ GARROW_AVAILABLE_IN_3_0
gchar *
garrow_extension_data_type_get_extension_name(GArrowExtensionDataType *data_type);
-typedef struct _GArrowArray GArrowArray;
-typedef struct _GArrowExtensionArray GArrowExtensionArray;
-
GARROW_AVAILABLE_IN_3_0
GArrowExtensionArray *
garrow_extension_data_type_wrap_array(GArrowExtensionDataType *data_type,
GArrowArray *storage);
-typedef struct _GArrowChunkedArray GArrowChunkedArray;
-
GARROW_AVAILABLE_IN_3_0
GArrowChunkedArray *
garrow_extension_data_type_wrap_chunked_array(GArrowExtensionDataType *data_type,
diff --git a/c_glib/arrow-glib/chunked-array-definition.h b/c_glib/arrow-glib/chunked-array-definition.h
new file mode 100644
index 0000000000..539a4848e8
--- /dev/null
+++ b/c_glib/arrow-glib/chunked-array-definition.h
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <arrow-glib/gobject-type.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_CHUNKED_ARRAY (garrow_chunked_array_get_type())
+G_DECLARE_DERIVABLE_TYPE(GArrowChunkedArray,
+ garrow_chunked_array,
+ GARROW,
+ CHUNKED_ARRAY,
+ GObject)
+struct _GArrowChunkedArrayClass
+{
+ GObjectClass parent_class;
+};
+
+
+G_END_DECLS
diff --git a/c_glib/arrow-glib/chunked-array.h b/c_glib/arrow-glib/chunked-array.h
index 8e721f0bf9..528be28ad3 100644
--- a/c_glib/arrow-glib/chunked-array.h
+++ b/c_glib/arrow-glib/chunked-array.h
@@ -20,20 +20,10 @@
#pragma once
#include <arrow-glib/array.h>
+#include <arrow-glib/chunked-array-definition.h>
G_BEGIN_DECLS
-#define GARROW_TYPE_CHUNKED_ARRAY (garrow_chunked_array_get_type())
-G_DECLARE_DERIVABLE_TYPE(GArrowChunkedArray,
- garrow_chunked_array,
- GARROW,
- CHUNKED_ARRAY,
- GObject)
-struct _GArrowChunkedArrayClass
-{
- GObjectClass parent_class;
-};
-
GArrowChunkedArray *garrow_chunked_array_new(GList *chunks);
gboolean garrow_chunked_array_equal(GArrowChunkedArray *chunked_array,
diff --git a/c_glib/arrow-glib/compute-definition.h b/c_glib/arrow-glib/compute-definition.h
new file mode 100644
index 0000000000..ba0e9da989
--- /dev/null
+++ b/c_glib/arrow-glib/compute-definition.h
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <arrow-glib/gobject-type.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_FUNCTION_OPTIONS (garrow_function_options_get_type())
+G_DECLARE_DERIVABLE_TYPE(GArrowFunctionOptions,
+ garrow_function_options,
+ GARROW,
+ FUNCTION_OPTIONS,
+ GObject)
+struct _GArrowFunctionOptionsClass
+{
+ GObjectClass parent_class;
+};
+
+
+#define GARROW_TYPE_CAST_OPTIONS (garrow_cast_options_get_type())
+G_DECLARE_DERIVABLE_TYPE(GArrowCastOptions,
+ garrow_cast_options,
+ GARROW,
+ CAST_OPTIONS,
+ GArrowFunctionOptions)
+struct _GArrowCastOptionsClass
+{
+ GArrowFunctionOptionsClass parent_class;
+};
+
+
+G_END_DECLS
diff --git a/c_glib/arrow-glib/compute.h b/c_glib/arrow-glib/compute.h
index 32db15be8b..a9ba6c2af9 100644
--- a/c_glib/arrow-glib/compute.h
+++ b/c_glib/arrow-glib/compute.h
@@ -19,6 +19,7 @@
#pragma once
+#include <arrow-glib/compute-definition.h>
#include <arrow-glib/datum.h>
#include <arrow-glib/reader.h>
@@ -39,17 +40,6 @@ GARROW_AVAILABLE_IN_1_0
GArrowExecuteContext *garrow_execute_context_new(void);
-#define GARROW_TYPE_FUNCTION_OPTIONS (garrow_function_options_get_type())
-G_DECLARE_DERIVABLE_TYPE(GArrowFunctionOptions,
- garrow_function_options,
- GARROW,
- FUNCTION_OPTIONS,
- GObject)
-struct _GArrowFunctionOptionsClass
-{
- GObjectClass parent_class;
-};
-
GARROW_AVAILABLE_IN_7_0
gboolean
garrow_function_options_equal(GArrowFunctionOptions *options,
@@ -366,17 +356,6 @@ void
garrow_execute_plan_wait(GArrowExecutePlan *plan);
-#define GARROW_TYPE_CAST_OPTIONS (garrow_cast_options_get_type())
-G_DECLARE_DERIVABLE_TYPE(GArrowCastOptions,
- garrow_cast_options,
- GARROW,
- CAST_OPTIONS,
- GArrowFunctionOptions)
-struct _GArrowCastOptionsClass
-{
- GArrowFunctionOptionsClass parent_class;
-};
-
GArrowCastOptions *garrow_cast_options_new(void);
diff --git a/c_glib/arrow-glib/meson.build b/c_glib/arrow-glib/meson.build
index 69c74bf824..82ae52691d 100644
--- a/c_glib/arrow-glib/meson.build
+++ b/c_glib/arrow-glib/meson.build
@@ -78,9 +78,11 @@ c_headers = files(
'array.h',
'array-builder.h',
'arrow-glib.h',
+ 'basic-array-definition.h',
'basic-array.h',
'basic-data-type.h',
'buffer.h',
+ 'chunked-array-definition.h',
'chunked-array.h',
'codec.h',
'composite-array.h',
@@ -122,6 +124,7 @@ c_headers += files(
)
c_headers += files(
+ 'compute-definition.h',
'compute.h',
)
diff --git a/c_glib/arrow-glib/scalar.cpp b/c_glib/arrow-glib/scalar.cpp
index bb4941bbbb..cef11578e1 100644
--- a/c_glib/arrow-glib/scalar.cpp
+++ b/c_glib/arrow-glib/scalar.cpp
@@ -19,6 +19,7 @@
#include <arrow-glib/basic-array.hpp>
#include <arrow-glib/buffer.hpp>
+#include <arrow-glib/compute.h>
#include <arrow-glib/data-type.hpp>
#include <arrow-glib/decimal.hpp>
#include <arrow-glib/error.hpp>
diff --git a/c_glib/arrow-glib/scalar.h b/c_glib/arrow-glib/scalar.h
index 863028f854..3fa00597ca 100644
--- a/c_glib/arrow-glib/scalar.h
+++ b/c_glib/arrow-glib/scalar.h
@@ -20,11 +20,10 @@
#pragma once
#include <arrow-glib/array.h>
+#include <arrow-glib/compute-definition.h>
G_BEGIN_DECLS
-typedef struct _GArrowCastOptions GArrowCastOptions;
-
#define GARROW_TYPE_SCALAR (garrow_scalar_get_type())
G_DECLARE_DERIVABLE_TYPE(GArrowScalar,
garrow_scalar,
diff --git a/c_glib/example/meson.build b/c_glib/example/meson.build
index b863ea7c9d..e43f1553dd 100644
--- a/c_glib/example/meson.build
+++ b/c_glib/example/meson.build
@@ -18,13 +18,17 @@
# under the License.
executable('build', 'build.c',
- dependencies: [arrow_glib])
+ dependencies: [arrow_glib],
+ link_language: 'c')
executable('extension-type', 'extension-type.c',
- dependencies: [arrow_glib])
+ dependencies: [arrow_glib],
+ link_language: 'c')
executable('read-file', 'read-file.c',
- dependencies: [arrow_glib])
+ dependencies: [arrow_glib],
+ link_language: 'c')
executable('read-stream', 'read-stream.c',
- dependencies: [arrow_glib])
+ dependencies: [arrow_glib],
+ link_language: 'c')
install_data('README.md',
'build.c',
diff --git a/c_glib/meson.build b/c_glib/meson.build
index 7405f05172..7c5a1e9b6a 100644
--- a/c_glib/meson.build
+++ b/c_glib/meson.build
@@ -20,6 +20,7 @@
project('arrow-glib', 'c', 'cpp',
license: 'Apache-2.0',
default_options: [
+ 'c_std=c99',
'cpp_std=c++11',
])