Skip to content

Commit

Permalink
ARROW-15671: [GLib] Add support for Vala
Browse files Browse the repository at this point in the history
Closes #12993 from kou/glib-vapi

Lead-authored-by: Sutou Kouhei <kou@clear-code.com>
Co-authored-by: Tao Zuhong <taozuhong@users.noreply.github.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
  • Loading branch information
kou and taozuhong committed May 9, 2022
1 parent d8173f7 commit 953a6de
Show file tree
Hide file tree
Showing 58 changed files with 1,152 additions and 164 deletions.
7 changes: 4 additions & 3 deletions .dir-locals.el
Expand Up @@ -15,8 +15,9 @@
;;; specific language governing permissions and limitations
;;; under the License.

((sh-mode . ((indent-tabs-mode . nil)
((cmake-mode . ((indent-tabs-mode . nil)))
(powershell-mode . ((indent-tabs-mode . nil)))
(sh-mode . ((indent-tabs-mode . nil)
(sh-indentation . 2)
(sh-basic-offset . 2)))
(cmake-mode . ((indent-tabs-mode . nil)))
(powershell-mode . ((indent-tabs-mode . nil))))
(vala-mode . ((indent-tabs-mode . nil))))
1 change: 1 addition & 0 deletions c_glib/Brewfile
Expand Up @@ -20,3 +20,4 @@ brew "gobject-introspection"
brew "gtk-doc"
brew "libtool"
brew "meson"
brew "vala"
39 changes: 26 additions & 13 deletions c_glib/arrow-cuda-glib/meson.build
Expand Up @@ -65,17 +65,30 @@ if have_gi
'--warn-all',
'--include-uninstalled=./arrow-glib/Arrow-1.0.gir',
]
arrow_cuda_glib_gir = gnome.generate_gir(libarrow_cuda_glib,
dependencies: gir_dependencies,
sources: sources + c_headers,
namespace: 'ArrowCUDA',
nsversion: api_version,
identifier_prefix: 'GArrowCUDA',
symbol_prefix: 'garrow_cuda',
export_packages: 'arrow-cuda-glib',
includes: [
'Arrow-1.0',
],
install: true,
extra_args: gir_extra_args)
arrow_cuda_glib_gir = \
gnome.generate_gir(libarrow_cuda_glib,
dependencies: gir_dependencies,
export_packages: 'arrow-cuda-glib',
extra_args: gir_extra_args,
header: 'arrow-cuda-glib/arrow-cuda-glib.h',
identifier_prefix: 'GArrowCUDA',
includes: [
'Arrow-1.0',
],
install: true,
namespace: 'ArrowCUDA',
nsversion: api_version,
sources: sources + c_headers,
symbol_prefix: 'garrow_cuda')

if generate_vapi
arrow_cuda_glib_vapi = \
gnome.generate_vapi('arrow-cuda-glib',
install: true,
packages: [
arrow_glib_vapi,
'gio-2.0',
],
sources: [arrow_cuda_glib_gir[0]])
endif
endif
44 changes: 28 additions & 16 deletions c_glib/arrow-dataset-glib/meson.build
Expand Up @@ -85,20 +85,32 @@ pkgconfig.generate(libarrow_dataset_glib,
requires: ['arrow-glib', 'arrow-dataset'])

if have_gi
gnome.generate_gir(libarrow_dataset_glib,
dependencies: declare_dependency(sources: arrow_glib_gir),
sources: sources + c_headers + enums,
namespace: 'ArrowDataset',
nsversion: api_version,
identifier_prefix: 'GADataset',
symbol_prefix: 'gadataset',
export_packages: 'arrow-dataset-glib',
includes: [
'Arrow-1.0',
],
install: true,
extra_args: [
'--warn-all',
'--include-uninstalled=./arrow-glib/Arrow-1.0.gir',
])
dataset_glib_gir = \
gnome.generate_gir(libarrow_dataset_glib,
dependencies: declare_dependency(sources: arrow_glib_gir),
export_packages: 'arrow-dataset-glib',
extra_args: [
'--warn-all',
'--include-uninstalled=./arrow-glib/Arrow-1.0.gir',
],
header: 'arrow-dataset-glib/arrow-dataset-glib.h',
identifier_prefix: 'GADataset',
includes: [
'Arrow-1.0',
],
install: true,
namespace: 'ArrowDataset',
nsversion: api_version,
sources: sources + c_headers + enums,
symbol_prefix: 'gadataset')

if generate_vapi
gnome.generate_vapi('arrow-dataset-glib',
install: true,
packages: [
arrow_glib_vapi,
'gio-2.0',
],
sources: [dataset_glib_gir[0]])
endif
endif
44 changes: 28 additions & 16 deletions c_glib/arrow-flight-glib/meson.build
Expand Up @@ -63,20 +63,32 @@ pkgconfig.generate(libarrow_flight_glib,
requires: ['arrow-glib', 'arrow-flight'])

if have_gi
gnome.generate_gir(libarrow_flight_glib,
dependencies: declare_dependency(sources: arrow_glib_gir),
sources: sources + c_headers,
namespace: 'ArrowFlight',
nsversion: api_version,
identifier_prefix: 'GAFlight',
symbol_prefix: 'gaflight',
export_packages: 'arrow-flight-glib',
includes: [
'Arrow-1.0',
],
install: true,
extra_args: [
'--warn-all',
'--include-uninstalled=./arrow-glib/Arrow-1.0.gir',
])
flight_glib_gir = \
gnome.generate_gir(libarrow_flight_glib,
dependencies: declare_dependency(sources: arrow_glib_gir),
export_packages: 'arrow-flight-glib',
extra_args: [
'--warn-all',
'--include-uninstalled=./arrow-glib/Arrow-1.0.gir',
],
header: 'arrow-flight-glib/arrow-flight-glib.h',
identifier_prefix: 'GAFlight',
includes: [
'Arrow-1.0',
],
install: true,
namespace: 'ArrowFlight',
nsversion: api_version,
sources: sources + c_headers,
symbol_prefix: 'gaflight')

if generate_vapi
gnome.generate_vapi('arrow-flight-glib',
install: true,
packages: [
arrow_glib_vapi,
'gio-2.0',
],
sources: [flight_glib_gir[0]])
endif
endif
20 changes: 20 additions & 0 deletions c_glib/arrow-glib/Arrow-1.0.metadata
@@ -0,0 +1,20 @@
// 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.

DecimalDataType.new skip
// SourceNodeOptions.record_batch#property name="get_record_batch"
SourceNodeOptions.record_batch#property skip
24 changes: 16 additions & 8 deletions c_glib/arrow-glib/meson.build
Expand Up @@ -266,18 +266,26 @@ endif

if have_gi
arrow_glib_gir = gnome.generate_gir(libarrow_glib,
sources: sources + c_headers + enums,
namespace: 'Arrow',
nsversion: api_version,
identifier_prefix: 'GArrow',
symbol_prefix: 'garrow',
export_packages: 'arrow-glib',
extra_args: [
'--warn-all',
],
header: 'arrow-glib/arrow-glib.h',
identifier_prefix: 'GArrow',
includes: [
'GObject-2.0',
'Gio-2.0',
],
install: true,
extra_args: [
'--warn-all',
])
namespace: 'Arrow',
nsversion: api_version,
sources: sources + c_headers + enums,
symbol_prefix: 'garrow')

if generate_vapi
arrow_glib_vapi = gnome.generate_vapi('arrow-glib',
install: true,
packages: ['gio-2.0'],
sources: [arrow_glib_gir[0]])
endif
endif
12 changes: 6 additions & 6 deletions c_glib/example/README.md
Expand Up @@ -32,17 +32,17 @@ Here are example codes in this directory:
* `build.c`: It shows how to create an array by array builder.

<!---
* `write-batch.c`: It shows how to write Arrow array to file in batch
mode.
* `write-file.c`: It shows how to write Arrow array to file in file
format.
-->

* `read-batch.c`: It shows how to read Arrow array from file in batch
mode.
* `read-file.c`: It shows how to read Arrow array from file in file
format.

<!---
* `write-stream.c`: It shows how to write Arrow array to file in
stream mode.
stream format.
-->

* `read-stream.c`: It shows how to read Arrow array from file in
stream mode.
stream format.
18 changes: 9 additions & 9 deletions c_glib/example/lua/README.md
Expand Up @@ -28,23 +28,23 @@ Arrow GLib based bindings.

Here are command lines to install LGI on Debian GNU/Linux and Ubuntu:

```text
% sudo apt install -y luarocks
% sudo luarocks install lgi
```console
$ sudo apt install -y luarocks
$ sudo luarocks install lgi
```

## Lua example codes

Here are example codes in this directory:

* `write-batch.lua`: It shows how to write Arrow array to file in
batch mode.
* `write-file.lua`: It shows how to write Arrow array to file in
file format.

* `read-batch.lua`: It shows how to read Arrow array from file in
batch mode.
* `read-file.lua`: It shows how to read Arrow array from file in
file format.

* `write-stream.lua`: It shows how to write Arrow array to file in
stream mode.
stream format.

* `read-stream.lua`: It shows how to read Arrow array from file in
stream mode.
stream format.
4 changes: 2 additions & 2 deletions c_glib/example/lua/meson.build
Expand Up @@ -18,9 +18,9 @@
# under the License.

install_data('README.md',
'read-batch.lua',
'read-file.lua',
'read-stream.lua',
'write-batch.lua',
'write-file.lua',
'write-stream.lua',
install_dir: join_paths(data_dir,
meson.project_name(),
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions c_glib/example/meson.build
Expand Up @@ -21,16 +21,17 @@ executable('build', 'build.c',
dependencies: [arrow_glib])
executable('extension-type', 'extension-type.c',
dependencies: [arrow_glib])
executable('read-batch', 'read-batch.c',
executable('read-file', 'read-file.c',
dependencies: [arrow_glib])
executable('read-stream', 'read-stream.c',
dependencies: [arrow_glib])

install_data('README.md',
'build.c',
'extension-type.c',
'read-batch.c',
'read-file.c',
'read-stream.c',
install_dir: join_paths(data_dir, meson.project_name(), 'example'))

subdir('lua')
subdir('vala')
2 changes: 1 addition & 1 deletion c_glib/example/read-batch.c → c_glib/example/read-file.c
Expand Up @@ -124,7 +124,7 @@ main(int argc, char **argv)
record_batch =
garrow_record_batch_file_reader_read_record_batch(reader, i, &error);
if (!record_batch) {
g_print("failed to open file reader: %s\n", error->message);
g_print("failed to read %u-th record batch: %s\n", i, error->message);
g_error_free(error);
g_object_unref(reader);
g_object_unref(input);
Expand Down
48 changes: 48 additions & 0 deletions c_glib/example/vala/README.md
@@ -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.
-->

# Arrow Vala example

There are Vala example codes in this directory.

## How to build

Here is a command line to build an example in this directory:

```console
$ valac --pkg arrow-glib --pkg posix XXX.vala
```

## Vala example codes

Here are example codes in this directory:

* `build.vala`: It shows how to create an array by array builder.

* `write-file.vala`: It shows how to write Arrow array to file in
file format.

* `read-file.vala`: It shows how to read Arrow array from file in
file format.

* `write-stream.vala`: It shows how to write Arrow array to file in
stream format.

* `read-stream.vala`: It shows how to read Arrow array from file in
stream format.

0 comments on commit 953a6de

Please sign in to comment.