Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions c_glib/arrow-glib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ libarrow_glib_la_headers = \
data-type.h \
error.h \
field.h \
gobject-type.h \
record-batch.h \
schema.h \
table.h \
Expand Down
2 changes: 2 additions & 0 deletions c_glib/arrow-glib/arrow-glib.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#pragma once

#include <arrow-glib/gobject-type.h>

#include <arrow-glib/array.h>
#include <arrow-glib/array-builder.h>
#include <arrow-glib/chunked-array.h>
Expand Down
16 changes: 6 additions & 10 deletions c_glib/arrow-glib/compute.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,16 @@

#pragma once

#include <glib-object.h>
#include <arrow-glib/gobject-type.h>

G_BEGIN_DECLS

#define GARROW_TYPE_CAST_OPTIONS (garrow_cast_options_get_type())
G_DECLARE_DERIVABLE_TYPE(GArrowCastOptions,
garrow_cast_options,
GARROW,
CAST_OPTIONS,
GObject)
struct _GArrowCastOptionsClass
{
GObjectClass parent_class;
};
GARROW_DECLARE_TYPE(GArrowCastOptions,
garrow_cast_options,
GARROW,
CAST_OPTIONS,
GObject)

GArrowCastOptions *garrow_cast_options_new(void);

Expand Down
97 changes: 97 additions & 0 deletions c_glib/arrow-glib/gobject-type.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* 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 <glib-object.h>

#ifdef G_DECLARE_DERIVABLE_TYPE
# define GARROW_DECLARE_TYPE(ObjectName, \
object_name, \
MODULE_NAME, \
OBJECT_NAME, \
ParentName) \
G_DECLARE_DERIVABLE_TYPE(ObjectName, \
object_name, \
MODULE_NAME, \
OBJECT_NAME, \
ParentName) \
struct _ ## ObjectName ## Class \
{ \
ParentName ## Class parent_class; \
};
#else
# define GARROW_DECLARE_TYPE(ObjectName, \
object_name, \
MODULE_NAME, \
OBJECT_NAME, \
ParentName) \
typedef struct _ ## ObjectName ObjectName; \
typedef struct _ ## ObjectName ## Class ObjectName ## Class; \
\
struct _ ## ObjectName \
{ \
ParentName parent_instance; \
}; \
\
struct _ ## ObjectName ## Class \
{ \
ParentName ## Class parent_class; \
}; \
\
GType object_name ## _get_type(void) G_GNUC_CONST; \
\
static inline ObjectName * \
MODULE_NAME ## _ ## OBJECT_NAME(gpointer object) \
{ \
return G_TYPE_CHECK_INSTANCE_CAST(object, \
object_name ## _get_type(), \
ObjectName); \
} \
\
static inline ObjectName ## Class * \
MODULE_NAME ## _ ## OBJECT_NAME ## _CLASS(gpointer klass) \
{ \
return G_TYPE_CHECK_CLASS_CAST(klass, \
object_name ## _get_type(), \
ObjectName ## Class); \
} \
\
static inline gboolean \
MODULE_NAME ## _IS_ ## OBJECT_NAME(gpointer object) \
{ \
return G_TYPE_CHECK_INSTANCE_TYPE(object, \
object_name ## _get_type()); \
} \
\
static inline gboolean \
MODULE_NAME ## _IS_ ## OBJECT_NAME ## _CLASS(gpointer klass) \
{ \
return G_TYPE_CHECK_CLASS_TYPE(klass, \
object_name ## _get_type()); \
} \
\
static inline ObjectName ## Class * \
MODULE_NAME ## _ ## ObjectName ## _GET_CLASS(gpointer object) \
{ \
return G_TYPE_INSTANCE_GET_CLASS(object, \
object_name ## _get_type(), \
ObjectName ## Class); \
}
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since GLib is LGPL (which is Category X) I wanted to check that this code did not come from that codebase

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GLib's implementation is here: https://git.gnome.org/browse/glib/tree/gobject/gtype.h#n1395

This implementation generates codes based on

#define GARROW_TYPE_ARRAY \
(garrow_array_get_type())
#define GARROW_ARRAY(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), GARROW_TYPE_ARRAY, GArrowArray))
#define GARROW_ARRAY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), GARROW_TYPE_ARRAY, GArrowArrayClass))
#define GARROW_IS_ARRAY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GARROW_TYPE_ARRAY))
#define GARROW_IS_ARRAY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GARROW_TYPE_ARRAY))
#define GARROW_ARRAY_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), GARROW_TYPE_ARRAY, GArrowArrayClass))
typedef struct _GArrowArray GArrowArray;
typedef struct _GArrowArrayClass GArrowArrayClass;
/**
* GArrowArray:
*
* It wraps `arrow::Array`.
*/
struct _GArrowArray
{
/*< private >*/
GObject parent_instance;
};
struct _GArrowArrayClass
{
GObjectClass parent_class;
};
GType garrow_array_get_type (void) G_GNUC_CONST;

Defining macros such as GARROW_ARRAY() by "static inline" function idea is taken from GLib's implementation. Others aren't taken.

It seems that the idea (implementing convenient functions by "static inline" function instead of macro) is a generic C technique. I know that Ruby is also uses the technique such as https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L307-L320 .

So I think that this code isn't LGPL-ed work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, thank you. Since this was feature backporting issue I just wanted to check. Reusing implementation ideas is no problem so long as actual lines of Category X code are not being redistributed or otherwise directly ported

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking license issue!

4 changes: 0 additions & 4 deletions ci/travis_before_script_c_glib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ if [ $TRAVIS_OS_NAME == "osx" ]; then
brew outdated || brew upgrade libtool

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opt/libffi/lib/pkgconfig
else
sudo apt-add-repository -y ppa:jonathonf/gtk3.18
sudo apt-get update
sudo apt-get install -V -y libglib2.0-dev
fi

gem install test-unit gobject-introspection
Expand Down
14 changes: 0 additions & 14 deletions dev/release/verify-release-candidate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,6 @@ test_python() {


test_glib() {
# Build and test GLib, requires GLib >= 2.44 , so install that
# here
GLIB_VERSION=glib-2.53.7
GLIB_URL=https://gensho.ftp.acc.umu.se/pub/gnome/sources/glib/2.53/$GLIB_VERSION.tar.xz
curl -f -O $GLIB_URL
tar xf $GLIB_VERSION.tar.xz
pushd $GLIB_VERSION

./configure --disable-libelf --enable-libmount=no --prefix=$ARROW_HOME
make -j$NPROC
make install

popd

pushd c_glib

./configure --prefix=$ARROW_HOME
Expand Down