joachifm / cl-webkit

A binding to WebKitGTK+ for Common Lisp
MIT License
53 stars 16 forks source link

Generate binding via gobject-introspection #33

Open joachifm opened 8 years ago

joachifm commented 8 years ago

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.

hendursaga commented 1 year ago

Is there an idea of what (presumably 3rd-party) CL generator library we could use?

aartaka commented 1 year ago

Claw (https://github.com/atlas-engineer/cl-webengine/issues/5) or cl-autowrap are the worthy ones.