GithubHelp home page GithubHelp logo

gtkd-developers / gir-to-d Goto Github PK

View Code? Open in Web Editor NEW
23.0 5.0 13.0 2.19 MB

Create D bindings from GObject introspection files

License: GNU Lesser General Public License v3.0

Makefile 0.57% D 98.91% Meson 0.51%
dlang gobject-introspection binding-generator

gir-to-d's People

Contributors

baedert avatar barcharcraz avatar deviator avatar dhasenan avatar gnunn1 avatar justabanana avatar lunathefoxgirl avatar mikewey avatar russel avatar seeschloss avatar ximion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gir-to-d's Issues

Fails to generate valid code for GLibD

Hi!
At the moment, the GLibD build at Debian fails after the gir-to-d update with

[1/327] ldc2 -Iglibd-2.0@sha -I. -I.. -Igenerated -I../generated -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -enable-color -O -g -release -wi -relocation-model=pic   -of 'glibd-2.0@sha/obj-x86_64-linux-gnu_generated_glib_c_functions.d.o' -c ../obj-x86_64-linux-gnu/generated/glib/c/functions.d
FAILED: glibd-2.0@sha/obj-x86_64-linux-gnu_generated_glib_c_functions.d.o 
ldc2 -Iglibd-2.0@sha -I. -I.. -Igenerated -I../generated -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -enable-color -O -g -release -wi -relocation-model=pic   -of 'glibd-2.0@sha/obj-x86_64-linux-gnu_generated_glib_c_functions.d.o' -c ../obj-x86_64-linux-gnu/generated/glib/c/functions.d
../obj-x86_64-linux-gnu/generated/glib/c/functions.d(1163): Error: found `const` when expecting `)`
../obj-x86_64-linux-gnu/generated/glib/c/functions.d(1163): Error: semicolon expected following function declaration
../obj-x86_64-linux-gnu/generated/glib/c/functions.d(1163): Error: declaration expected, not `*`
../obj-x86_64-linux-gnu/generated/glib/c/functions.d(1187): Error: found `const` when expecting `)`
../obj-x86_64-linux-gnu/generated/glib/c/functions.d(1187): Error: semicolon expected following function declaration
../obj-x86_64-linux-gnu/generated/glib/c/functions.d(1187): Error: declaration expected, not `*`
[2/327] ldc2 -Iglibd-2.0@sha -I. -I.. -Igenerated -I../generated -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -enable-color -O -g -release -wi -relocation-model=pic   -of 'glibd-2.0@sha/obj-x86_64-linux-gnu_generated_gtkd_paths.d.o' -c ../obj-x86_64-linux-gnu/generated/gtkd/paths.d
[3/327] ldc2 -Iglibd-2.0@sha -I. -I.. -Igenerated -I../generated -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -enable-color -O -g -release -wi -relocation-model=pic   -of 'glibd-2.0@sha/obj-x86_64-linux-gnu_generated_gtkd_Implement.d.o' -c ../obj-x86_64-linux-gnu/generated/gtkd/Implement.d
[4/327] ldc2 -Iglibd-2.0@sha -I. -I.. -Igenerated -I../generated -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -enable-color -O -g -release -wi -relocation-model=pic   -of 'glibd-2.0@sha/obj-x86_64-linux-gnu_generated_gtkd_Loader.d.o' -c ../obj-x86_64-linux-gnu/generated/gtkd/Loader.d
ninja: build stopped: subcommand failed.

See https://buildd.debian.org/status/fetch.php?pkg=glib-d&arch=amd64&ver=2.0.0-1%2Bb1&stamp=1536513253&raw=0 for a full build log.
I assume this is actually an issue in gir-to-d, that's why I am reporting it here (but it could also be a problem in GLibD's wrap files, I didn't have the time yet to reproduce the issue locally).

See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=908671 for the respective bug report at Debian.

Cannot build on Fedora Rawhide

I just tried building on Fedora Rawhide (fully up to date as at 2018-10-17T07:10+01:00)

|> meson --prefix=$HOME/Built /home/users/russel/Repositories/Git/Forks/Gir_to_D
The Meson build system
Version: 0.48.0
Source dir: /home/users/russel/Repositories/Git/Forks/Gir_to_D
Build dir: /home/russel/BuildArea/Gir_to_D
Build type: native build
Project name: GIR-to-D
Project version: 0.16.0
Native D compiler: ldc2 (llvm 1.12.0 "LDC - the LLVM D compiler (1.12.0):")
Build machine cpu family: x86_64
Build machine cpu: x86_64
Build targets in project: 2
Found ninja-1.8.2 at /home/russel/Built/bin/ninja

So far so good. However:

|> ninja
[2/20] Compiling D object 'girtod@exe/source_gtd_GlibTypes.d.o'.
FAILED: girtod@exe/source_gtd_GlibTypes.d.o 
ldc2 -I=girtod@exe -I=. -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/ -I= -enable-color -wi -g -J/home/russel/BuildArea/Gir_to_D   -of='girtod@exe/source_gtd_GlibTypes.d.o' -c ../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/gtd/GlibTypes.d
Error: Expected argument to '-I'
[3/20] Compiling D object 'girtod@exe/source_gtd_DefReader.d.o'.
FAILED: girtod@exe/source_gtd_DefReader.d.o 
ldc2 -I=girtod@exe -I=. -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/ -I= -enable-color -wi -g -J/home/russel/BuildArea/Gir_to_D   -of='girtod@exe/source_gtd_DefReader.d.o' -c ../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/gtd/DefReader.d
Error: Expected argument to '-I'
[4/20] Compiling D object 'girtod@exe/source_girtod.d.o'.
FAILED: girtod@exe/source_girtod.d.o 
ldc2 -I=girtod@exe -I=. -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/ -I= -enable-color -wi -g -J/home/russel/BuildArea/Gir_to_D   -of='girtod@exe/source_girtod.d.o' -c ../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/girtod.d
Error: Expected argument to '-I'
[5/20] Compiling D object 'girtod@exe/source_gtd_GirConstant.d.o'.
FAILED: girtod@exe/source_gtd_GirConstant.d.o 
ldc2 -I=girtod@exe -I=. -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/ -I= -enable-color -wi -g -J/home/russel/BuildArea/Gir_to_D   -of='girtod@exe/source_gtd_GirConstant.d.o' -c ../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/gtd/GirConstant.d
Error: Expected argument to '-I'
[6/20] Compiling D object 'girtod@exe/source_gtd_GirField.d.o'.
FAILED: girtod@exe/source_gtd_GirField.d.o 
ldc2 -I=girtod@exe -I=. -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/ -I= -enable-color -wi -g -J/home/russel/BuildArea/Gir_to_D   -of='girtod@exe/source_gtd_GirField.d.o' -c ../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/gtd/GirField.d
Error: Expected argument to '-I'
[7/20] Compiling D object 'girtod@exe/source_gtd_GirEnum.d.o'.
FAILED: girtod@exe/source_gtd_GirEnum.d.o 
ldc2 -I=girtod@exe -I=. -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/ -I= -enable-color -wi -g -J/home/russel/BuildArea/Gir_to_D   -of='girtod@exe/source_gtd_GirEnum.d.o' -c ../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/gtd/GirEnum.d
Error: Expected argument to '-I'
[8/20] Compiling D object 'girtod@exe/source_gtd_GirAlias.d.o'.
FAILED: girtod@exe/source_gtd_GirAlias.d.o 
ldc2 -I=girtod@exe -I=. -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/ -I= -enable-color -wi -g -J/home/russel/BuildArea/Gir_to_D   -of='girtod@exe/source_gtd_GirAlias.d.o' -c ../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/gtd/GirAlias.d
Error: Expected argument to '-I'
[9/20] Compiling D object 'girtod@exe/source_gtd_GirStruct.d.o'.
FAILED: girtod@exe/source_gtd_GirStruct.d.o 
ldc2 -I=girtod@exe -I=. -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/ -I= -enable-color -wi -g -J/home/russel/BuildArea/Gir_to_D   -of='girtod@exe/source_gtd_GirStruct.d.o' -c ../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/gtd/GirStruct.d
Error: Expected argument to '-I'
[10/20] Compiling D object 'girtod@exe/source_gtd_GirFunction.d.o'.
FAILED: girtod@exe/source_gtd_GirFunction.d.o 
ldc2 -I=girtod@exe -I=. -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/ -I= -enable-color -wi -g -J/home/russel/BuildArea/Gir_to_D   -of='girtod@exe/source_gtd_GirFunction.d.o' -c ../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/gtd/GirFunction.d
Error: Expected argument to '-I'
[11/20] Compiling D object 'girtod@exe/source_gtd_GirPackage.d.o'.
FAILED: girtod@exe/source_gtd_GirPackage.d.o 
ldc2 -I=girtod@exe -I=. -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D -I=../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/ -I= -enable-color -wi -g -J/home/russel/BuildArea/Gir_to_D   -of='girtod@exe/source_gtd_GirPackage.d.o' -c ../../../users/russel/Repositories/Git/Forks/Gir_to_D/source/gtd/GirPackage.d
Error: Expected argument to '-I'
ninja: build stopped: subcommand failed.

Look for gir files in XDG_DATA_DIRS by default

Currently gir-to-d looks for gir files only in /usr/share but according to the XDG base directory spec it's supposed to look in /usr/share and /usr/local/share if the XDG_DATA_DIRS variable is unset and in whatever directories are in the XDG_DATA_DIRS envvar.

This would make it possible to use gir-to-d on nixos and would fix some libraries that install the gir files to /usr/local/share(for example libshumate)

functions from handy/c/functions.d are "not defined"

Hi, I was testing the bindings for libhandy and I started getting some errors when the generated classes call the C-functions constructors. I imported handy.c.functions and called a simple function from it like this:

import handy.c.functions;

void main()
{
	auto a = hdy_window_new();
}

and this fails due to this:

undefined reference to `hdy_window_new'
collect2: error: ld returned 1 exit status

It seems that for some reason it can't call the functions definied in the c/functions.d file. Do you know what is the problem?
Thanks!

Option to rename types

JavaScriptCore-4.0.gir defines a class named Exception. This is not allowed in D. In order for gir-to-d to wrap this library, we need a way to rename a type. The docs don't record a way to do this.

Always use fully qualified names for imported types

I'm trying to create bindings for webkit2gtk and friends. There's a type called Socket in there that wraps a gio Socket. This is a naming conflict currently, but if gir-to-d used qualified names by default, there would be no conflict.

Please search the same paths for GIR XML that GObject-Introspection does

It looks as though cppgir searches for GIR XML (.gir files) in these locations (on Unix), highest-priority first:

  1. directories explicitly given as command-line options
  2. d + /gir-1.0 for each colon-delimited d in $XDG_DATA_DIRS, with fallback as per the XDG basedir spec

with some alternatives to (2) on Windows and macOS.

GObject-Introspection since 1.78.x (https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/258) searches more directories than that:

  1. directories explicitly given as command-line options
  2. each colon-delimited path in $GI_GIR_PATH (semicolon-delimited on Windows)
  3. g_get_user_data_dir() + /gir-1.0 as per the XDG basedir spec
  4. d + /gir-1.0 for each colon-delimited d in g_get_system_data_dirs() as per the XDG basedir spec
  5. a path specified when GObject-Introspection was compiled, which defaults to $datadir/gir-1.0 but is something architecture-dependent like $libdir/gir-1.0 in some OS distributions
  6. $datadir/gir-1.0
  7. on Unix only, a hard-coded fallback to /usr/share/gir-1.0

All the tools in the GObject-Introspection ecosystem should agree on which directories to search, so I think gir-to-d should match GObject-Introspection's behaviour (although it would be fine to continue to implement the XDG basedir spec locally).

For (5), the way I would do it in C/C++ code would be to have a compile-time option that defaults to either ${datadir}/gir-1.0 or $($PKG_CONFIG --variable=girdir gobject-introspection-1.0), and then pass that into the build of the C/C++ code via -D - but I don't know the D language, so I don't know what is its equivalent, if any. Some distributions will want to override this path at build-time, so it's important for that to be possible.

If it's difficult to implement some of these search paths, then the next best thing would be for gir-to-d to implement some of them, and leave the others (for example (5)) for distributions to patch in if they find that they need to.

References:

Atk-1.0.gir has content that is not valid for gir-to-d

I got an error today when generating gtk files, there is on line 8814 from atk-1.0 a hex value ¨ For which gir-to-d gives an error.

Error: /usr/local/share/gir-1.0/Atk-1.0.gir(8814): Unregonized escape secuence make: *** [Makefile:59: generate-runtime] Error 1

Generating @safe bindings

Hello,

it'd be nice if gir-to-d could generate @safe bindings so users of it could use it in a @safe manner.

Bare functions are not generated

Looks like <function>s directly in a <namespace> are ignored right now..

GIR file example
<?xml version="1.0"?>
<!-- This file was automatically generated from C sources - DO NOT EDIT!
To affect the contents of this file, edit the original C definitions,
and/or use gtk-doc annotations.  -->
<repository version="1.2"
            xmlns="http://www.gtk.org/introspection/core/1.0"
            xmlns:c="http://www.gtk.org/introspection/c/1.0"
            xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
  <include name="Gtk" version="3.0"/>
  <package name="gtk-layer-shell"/>
  <c:include name="gtk-layer-shell/gtk-layer-shell.h"/>
  <namespace name="GtkLayerShell"
             version="0.1"
             shared-library="libgtk-layer-shell.so"
             c:identifier-prefixes="GtkLayerShell"
             c:symbol-prefixes="gtk_layer">
    <enumeration name="Edge" c:type="GtkLayerShellEdge">
      <source-position filename="../include/gtk-layer-shell.h" line="22"/>
      <member name="left" value="0" c:identifier="GTK_LAYER_SHELL_EDGE_LEFT">
      </member>
      <member name="right" value="1" c:identifier="GTK_LAYER_SHELL_EDGE_RIGHT">
      </member>
      <member name="top" value="2" c:identifier="GTK_LAYER_SHELL_EDGE_TOP">
      </member>
      <member name="bottom"
              value="3"
              c:identifier="GTK_LAYER_SHELL_EDGE_BOTTOM">
      </member>
      <member name="entry_number"
              value="4"
              c:identifier="GTK_LAYER_SHELL_EDGE_ENTRY_NUMBER">
      </member>
    </enumeration>
    <enumeration name="Layer" c:type="GtkLayerShellLayer">
      <source-position filename="../include/gtk-layer-shell.h" line="14"/>
      <member name="background"
              value="0"
              c:identifier="GTK_LAYER_SHELL_LAYER_BACKGROUND">
      </member>
      <member name="bottom"
              value="1"
              c:identifier="GTK_LAYER_SHELL_LAYER_BOTTOM">
      </member>
      <member name="top" value="2" c:identifier="GTK_LAYER_SHELL_LAYER_TOP">
      </member>
      <member name="overlay"
              value="3"
              c:identifier="GTK_LAYER_SHELL_LAYER_OVERLAY">
      </member>
      <member name="entry_number"
              value="4"
              c:identifier="GTK_LAYER_SHELL_LAYER_ENTRY_NUMBER">
      </member>
    </enumeration>
    <function name="auto_exclusive_zone_enable"
              c:identifier="gtk_layer_auto_exclusive_zone_enable">
      <source-position filename="../include/gtk-layer-shell.h" line="61"/>
      <return-value transfer-ownership="none">
        <type name="none" c:type="void"/>
      </return-value>
      <parameters>
        <parameter name="window" transfer-ownership="none">
          <type name="Gtk.Window" c:type="GtkWindow*"/>
        </parameter>
      </parameters>
    </function>
    <function name="init_for_window" c:identifier="gtk_layer_init_for_window">
      <source-position filename="../include/gtk-layer-shell.h" line="27"/>
      <return-value transfer-ownership="none">
        <type name="none" c:type="void"/>
      </return-value>
      <parameters>
        <parameter name="window" transfer-ownership="none">
          <type name="Gtk.Window" c:type="GtkWindow*"/>
        </parameter>
      </parameters>
    </function>
    <function name="set_anchor" c:identifier="gtk_layer_set_anchor">
      <source-position filename="../include/gtk-layer-shell.h" line="50"/>
      <return-value transfer-ownership="none">
        <type name="none" c:type="void"/>
      </return-value>
      <parameters>
        <parameter name="window" transfer-ownership="none">
          <type name="Gtk.Window" c:type="GtkWindow*"/>
        </parameter>
        <parameter name="edge" transfer-ownership="none">
          <type name="Edge" c:type="GtkLayerShellEdge"/>
        </parameter>
        <parameter name="anchor_to_edge" transfer-ownership="none">
          <type name="gboolean" c:type="gboolean"/>
        </parameter>
      </parameters>
    </function>
    <function name="set_exclusive_zone"
              c:identifier="gtk_layer_set_exclusive_zone">
      <source-position filename="../include/gtk-layer-shell.h" line="60"/>
      <return-value transfer-ownership="none">
        <type name="none" c:type="void"/>
      </return-value>
      <parameters>
        <parameter name="window" transfer-ownership="none">
          <type name="Gtk.Window" c:type="GtkWindow*"/>
        </parameter>
        <parameter name="exclusive_zone" transfer-ownership="none">
          <type name="gint" c:type="int"/>
        </parameter>
      </parameters>
    </function>
    <function name="set_keyboard_interactivity"
              c:identifier="gtk_layer_set_keyboard_interactivity">
      <source-position filename="../include/gtk-layer-shell.h" line="65"/>
      <return-value transfer-ownership="none">
        <type name="none" c:type="void"/>
      </return-value>
      <parameters>
        <parameter name="window" transfer-ownership="none">
          <type name="Gtk.Window" c:type="GtkWindow*"/>
        </parameter>
        <parameter name="interacitvity" transfer-ownership="none">
          <type name="gboolean" c:type="gboolean"/>
        </parameter>
      </parameters>
    </function>
    <function name="set_layer" c:identifier="gtk_layer_set_layer">
      <source-position filename="../include/gtk-layer-shell.h" line="39"/>
      <return-value transfer-ownership="none">
        <type name="none" c:type="void"/>
      </return-value>
      <parameters>
        <parameter name="window" transfer-ownership="none">
          <type name="Gtk.Window" c:type="GtkWindow*"/>
        </parameter>
        <parameter name="layer" transfer-ownership="none">
          <type name="Layer" c:type="GtkLayerShellLayer"/>
        </parameter>
      </parameters>
    </function>
    <function name="set_margin" c:identifier="gtk_layer_set_margin">
      <source-position filename="../include/gtk-layer-shell.h" line="55"/>
      <return-value transfer-ownership="none">
        <type name="none" c:type="void"/>
      </return-value>
      <parameters>
        <parameter name="window" transfer-ownership="none">
          <type name="Gtk.Window" c:type="GtkWindow*"/>
        </parameter>
        <parameter name="edge" transfer-ownership="none">
          <type name="Edge" c:type="GtkLayerShellEdge"/>
        </parameter>
        <parameter name="margin_size" transfer-ownership="none">
          <type name="gint" c:type="int"/>
        </parameter>
      </parameters>
    </function>
    <function name="set_monitor" c:identifier="gtk_layer_set_monitor">
      <source-position filename="../include/gtk-layer-shell.h" line="44"/>
      <return-value transfer-ownership="none">
        <type name="none" c:type="void"/>
      </return-value>
      <parameters>
        <parameter name="window" transfer-ownership="none">
          <type name="Gtk.Window" c:type="GtkWindow*"/>
        </parameter>
        <parameter name="monitor" transfer-ownership="none">
          <type name="Gdk.Monitor" c:type="GdkMonitor*"/>
        </parameter>
      </parameters>
    </function>
    <function name="set_namespace" c:identifier="gtk_layer_set_namespace">
      <source-position filename="../include/gtk-layer-shell.h" line="34"/>
      <return-value transfer-ownership="none">
        <type name="none" c:type="void"/>
      </return-value>
      <parameters>
        <parameter name="window" transfer-ownership="none">
          <type name="Gtk.Window" c:type="GtkWindow*"/>
        </parameter>
        <parameter name="name_space" transfer-ownership="none">
          <type name="utf8" c:type="const char*"/>
        </parameter>
      </parameters>
    </function>
  </namespace>
</repository>

gst_adapter_map in gstreamer 1.14 tries to use .length on void*

This is new, used to work fine in the past:

      <method name="map" c:identifier="gst_adapter_map">
        <return-value transfer-ownership="none" nullable="1">
          <array length="0" zero-terminated="0" c:type="gconstpointer">
            <type name="guint8"/>
          </array>
        </return-value>
      …
      </method>
	public ubyte[] map(size_t size)
	{
		auto __p = gst_adapter_map(gstAdapter, size);

		return cast(ubyte[])__p[0 .. cast(size_t)__p.length];
	}
work/generated/gstreamer/gst/base/c/functions.d
55:     void* gst_adapter_map(GstAdapter* adapter, size_t size);
generated/gstreamer/gst/base/Adapter.d(445): Error: no property length for type void*                                                             
generated/gstreamer/gst/base/Adapter.d(686): Error: no property length for type void*

Missing support for function-macro

When compiling glibd-2.1.0 with host version glib 2.62.0 it fails due to missing support for function-macro in GirPackage.

The Meson build system
Version: 0.51.2
Source dir: /build/glibd/src/GlibD-2.1.0
Build dir: /build/glibd/src/GlibD-2.1.0/build
Build type: native build
Project name: GlibD
Project version: 2.1.0
Appending LDFLAGS from environment: '-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'
Appending LDFLAGS from environment: '-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'
D compiler for the host machine: ldc (llvm 1.17.0 "LDC - the LLVM D compiler (1.17.0):")
Build machine cpu family: x86_64
Build machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (1.6.3)
Run-time dependency glib-2.0 found: YES 2.62.0
Run-time dependency gmodule-2.0 found: YES 2.62.0
Run-time dependency gobject-2.0 found: YES 2.62.0
Run-time dependency gio-2.0 found: YES 2.62.0
Run-time dependency gobject-introspection-1.0 found: YES 1.62.0
Program girtod found: YES (/usr/bin/girtod)
Message: Generating D interfaces from GIR...

meson.build:37:4: ERROR: Problem encountered: Unable to build D intefaces from GIR:
Error /usr/share/gir-1.0/GLib-2.0.gir(143): Unexpected tag: function-macro in GirPackage: glib

The part of the .gir file it fails on:

    <function-macro name="ALIGNOF"
                    c:identifier="G_ALIGNOF"
                    version="2.60"
                    introspectable="0">
      <doc xml:space="preserve"
           filename="gmacros.h"
           line="873">Return the minimal alignment required by the platform ABI for values of >
type. The address of a variable or struct member of the given type must always be
a multiple of this alignment. For example, most platforms require int variables
to be aligned at a 4-byte boundary, so `G_ALIGNOF (int)` is 4 on most platforms.

Note this is not necessarily the same as the value returned by GCC’s
`__alignof__` operator, which returns the preferred alignment for a type.
The preferred alignment may be a stricter alignment than the minimal
alignment.</doc>
      <source-position filename="gmacros.h" line="870"/>
      <parameters>
        <parameter name="type">
          <doc xml:space="preserve"
               filename="gmacros.h"
               line="875">a type-name</doc>
        </parameter>
      </parameters>
    </function-macro>

Errors in output for WebKit2Extension.gir: cast(*); missing getStruct()

In ContextMenu.d:

public this()
{
	auto p = webkit_context_menu_new();
	if(p is null)
	{
		throw new ConstructionException("null returned by new");
	}
	this(cast(*) p, true);
}

Not sure what cast(*) p is supposed to be.

Also:

webkit_context_menu_append(cast(WebKitContextMenu*), (item is null) ? null : cast(WebKitContextMenuItem*)item.getContextMenuItemStruct());

The instance-parameter parameters only for a small number of types have getStruct() omitted.

New release?

Hi!
Current Git master contains quite a few bugfixes that would be nice to have in a released version - can we expect a gir-to-d release soon?
Cheers,
Matthias

Library regex not flexible enough, results in crashes

Hi!
The regexes introduced in commit 88dc63a are not flexible enough.
For example, a GIR file may contain library names like libappstream.so.4 which makes girtod crash instantly with an error like

core.exception.AssertError@/usr/lib/ldc/x86_64-linux-gnu/include/d/std/regex/package.d(473): wrong match: 17..0

Wrong method signature generated

For the project https://github.com/apache/arrow/tree/master/c_glib (Release 0.15.0 zip file) I generated the gir files Arrow-1.0.gir and Parquet-1.0.gir.

APILookup.txt

outputRoot: generated

lookup: APILookupArrow.txt
lookup: APILookupArrowParquet.txt

APILookupArrow.txt

wrap: arrow
file: Arrow-1.0.gir

APILookupArrowParquet.txt

wrap: parquet
file: Parquet-1.0.gir

A D source file arrow/Array.d is genererated with a method signature like this:

        /**
	 *
	 * Params:
	 *     targetDataType = A #GArrowDataType of cast target data.
	 *     options = A #GArrowCastOptions.
	 * Returns: A newly created casted array on success, %NULL on error.
	 *
	 * Since: 0.7.0
	 *
	 * Throws: GException on failure.
	 */
	public Array cast(DataType targetDataType, CastOptions options)
	{
		GError* err = null;

This causes syntax errors

Gir files:
gir.zip

AssertError with JavaScriptCore-4.0.gir

When trying to use gir-to-d to create bindings for libjavascriptcoregtk-4.0 (a part of WebKitGTK), I get an AssertError when trying to determine the library name:

core.exception.AssertError@/usr/include/dmd/phobos/std/regex/package.d(607): wrong match: 21..0
----------------
??:? _d_assert_msg [0x6dc576]
/usr/include/dmd/phobos/std/regex/package.d:608 inout pure nothrow @trusted inout(immutable(char)[]) std.regex.Captures!(immutable(char)[], ulong).Captures.opIndex!().opIndex(ulong) [0x6a46e2]
source/gtd/GirPackage.d:585 immutable(char)[] gtd.GirPackage.GirPackage.getDllNames() [0x6952a8]
source/gtd/GirPackage.d:539 immutable(char)[] gtd.GirPackage.GirPackage.getLibraries() [0x694f76]
source/gtd/GirPackage.d:510 void gtd.GirPackage.GirPackage.writeExternalFunctions() [0x694b44]
source/girtod.d:93 int girtod.main(immutable(char)[][]).__foreachbody3(ref gtd.GirPackage.GirPackage) [0x651792]
??:? _aaApply [0x6dda19]
source/girtod.d:85 _Dmain [0x6516aa]

The input gir file defines its shared library as javascriptcoregtk-4.0 instead of the expected libjavascriptcoregtk-4.0.so. I don't know if this is incorrect or not, but that's in the gir file that comes with Ubuntu 16.04.

D-to-gir?

Did you considered writing a D to gir generator?

Dmd should output all needed information about extern C definitions and data structures to generate gir files.

Therefore it would be easy to generate wrappers for multiple languages for a D library.

What do you think?

Per file licence statements need updating?

The per file licence statements mention an address for FSF, but the FSF wording no longer mentions an address, should the comments be updated to use the FSF normal LGPLv3 wording?

Provide simple example

I am not familiar with all this and would like to try using third-party GObject libraries from D (other than gtkd).

It would be useful to have a simple example here using an GObject(from C or Vala) with multiple properties and functions from D GObject.

Ninja build in repository

I am surprised that there are ninja build files in the repository, I think they should be removed since they are specific to the location of build.

Fails to link: undefined symbol _D6object__T8opEqualsTxC3gtd11GirFunctionQnTxQwZQBkFxQBexQBiZb

Trying to build gir-to-d 0.23.1 on an OpenMandriva Cooker system (ldc 1.33.0-beta2, glib 2.76.3, LLVM 16.0.4) results in

[20/20] Linking target girtod
FAILED: girtod 
ldc2  -of=girtod girtod.p/source_girtod.d.o girtod.p/source_gtd_DefReader.d.o girtod.p/source_gtd_GlibTypes.d.o girtod.p/source_gtd_GirAlias.d.o girtod.p/source_gtd_GirConstant.d.o girtod.p/source_gtd_GirEnum.d.o girtod.p/source_gtd_GirField.d.o girtod.p/source_gtd_GirFunction.d.o girtod.p/source_gtd_GirPackage.d.o girtod.p/source_gtd_GirStruct.d.o girtod.p/source_gtd_GirType.d.o girtod.p/source_gtd_GirVersion.d.o girtod.p/source_gtd_GirWrapper.d.o girtod.p/source_gtd_IndentedStringBuilder.d.o girtod.p/source_gtd_Log.d.o girtod.p/source_gtd_LinkedHasMap.d.o girtod.p/source_gtd_WrapException.d.o girtod.p/source_gtd_XMLReader.d.o -L=--allow-shlib-undefined -link-defaultlib-shared -O2 -L=-O2 -L=--no-undefined
ld.lld: error: undefined symbol: _D6object__T8opEqualsTxC3gtd11GirFunctionQnTxQwZQBkFxQBexQBiZb
>>> referenced by GirPackage.d
>>>               girtod.p/source_gtd_GirPackage.d.o:(_D3gtd12LinkedHasMap__T13LinkedHashMapTAyaTCQBq11GirFunctionQnZQBo4Node11__xopEqualsMxFKxSQDkQDj__TQCyTQCmTQCmZQDkQBwZb)
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

Crash when running with Meta-2.gir

Hello. Thank you for this library!

I experienced a crash when running on Meta-2.gir (Mutter):
girtod -i /usr/lib/mutter/Meta-2.gir -g /usr/lib/mutter/

I tracked it down to file GirStruct.d line 740 because parentStruct is null and fixed this temporarily by adding right before:

if ( !parentStruct )
    return false;

I did not track down the root cause yet.

Version: girtod 0.15.0+commit.11.gaa7149e (git clone from 8/8/2018)
Compiler: LDC - the LLVM D compiler (1.10.0)

Best Regards
Jan

Cannot build on OSX

I tried a build on OSX 'El Capitan' using meson, ninja, and ldc from Homebrew:

 |> meson --prefix=$HOME/Built /home/users/russel/Repositories/Git/Forks/Gir_to_D
The Meson build system
Version: 0.47.2
Source dir: /home/users/russel/Repositories/Git/Forks/Gir_to_D
Build dir: /Users/russel/BuildArea/Gir_to_D
Build type: native build
Project name: GIR-to-D
Project version: 0.16.0
Native D compiler: ldc2 (llvm 1.11.0 "LDC - the LLVM D compiler (1.11.0):")
Build machine cpu family: x86_64
Build machine cpu: x86_64
Build targets in project: 2
Found ninja-1.8.2 at /usr/local/bin/ninja

|> ninja
[11/20] Compiling D object 'girtod@exe/source_gtd_GirPackage.d.o'.
FAILED: girtod@exe/source_gtd_GirPackage.d.o 
ldc2 -Igirtod@exe -I. -I../../../../home/users/russel/Repositories/Git/Forks/Gir_to_D -I../../../../home/users/russel/Repositories/Git/Forks/Gir_to_D/source/ -I -enable-color -wi -g -O0 -J/Users/russel/BuildArea/Gir_to_D   -of 'girtod@exe/source_gtd_GirPackage.d.o' -c ../../../../home/users/russel/Repositories/Git/Forks/Gir_to_D/source/gtd/GirPackage.d
../../../../home/users/russel/Repositories/Git/Forks/Gir_to_D/source/gtd/GirPackage.d(127): Error: no property `baseName` for type `string`
../../../../home/users/russel/Repositories/Git/Forks/Gir_to_D/source/gtd/GirPackage.d(127): Error: no property `baseName` for type `string`
../../../../home/users/russel/Repositories/Git/Forks/Gir_to_D/source/gtd/GirPackage.d(127): Error: no property `baseName` for type `string`
/usr/local/Cellar/ldc/1.11.0/include/dlang/ldc/std/algorithm/iteration.d(499):        instantiated from here: `MapResult!(__lambda3, string[])`
../../../../home/users/russel/Repositories/Git/Forks/Gir_to_D/source/gtd/GirPackage.d(127):        instantiated from here: `map!(string[])`
[13/20] Compiling D object 'girtod@exe/source_gtd_GirVersion.d.o'.
ninja: build stopped: subcommand failed.

gtkc backward compatibility change breaks other projects

Hi!
Travis notified me that this change: 21142a8 breaks the appstream-generator project and possible others. Reason is that there simply is to "gtkc" package anywhere, yet, girtod inserts it into everything it processes.

What kind of problem was this patch trying to solve? (I can't see how applying it helps backwards compatibility...) In case the patch is necessary, can we maybe make it a config option somewhere, that you have to opt into?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.