Skip to content

Generate binding via gobject-introspection #33

Description

@joachifm

Writing low-level bindings is error prone, boring, and generally a waste of time. Use gobject-introspection instead.

For example, to iterate over all the properties of WebKitSettings, do something like

#include <girepository.h>

int main(void) {
  GError* err;
  GITypelib* WebKit2 = g_irepository_require(NULL, "WebKit2", NULL, 0, &err);
  if (!WebKit2) g_error("fatal: %s\n", err->message);

  GBaseInfo* info = g_irepository_find_by_name(NULL, "WebKit2", "Settings");
  if (!info) g_error("fatal: Settings not found in the WebKit2 namespace!\n");
  GIPropertyInfo* prop;
  for (int i = 0; i < g_object_info_get_n_properties(info); ++i) {
    prop = g_object_info_get_property(info, i);
    g_print("%s  %s  %d\n", g_base_info_get_name(prop),
      g_type_tag_to_string(g_type_info_get_tag(g_property_info_get_type(prop))),
      g_property_info_get_flags(prop));
  }
}

From this one might generate a suitable lisp class, preferably via a generator program to avoid run-time overhead from introspection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions