Code Monkey home page Code Monkey logo

goo's Introduction

Goo: Cross-runtime object interface generation

Goo is experimental.

Goo is a tool for writing high-level bindings. GUI toolkits are a natural use-case, but it is suitable for other libraries managing complex state and control flow, especially if they have an object-oriented interface.

Ctypes is effective for low-level FFI and fine grained manipulation of memory. However tracking objects lifetimes and relations is hard.

Goo focus on this part of the problem: while losing some of the flexibility and efficiency of low-level bindings, it tracks and restrict the shape of the heap graph to offer cheap, type-safe and memory-safe bindings.

Approach

The core of Goo is an object model that is well suited for describing the structure of object graphs (e.g. relations of widgets in a window). It has a simple feature set that maps well to mainstream object languages.

A binding starts with a description (see libui example) of an object graph. This graph is consumed by two code generators: one for the interface, one for the implementation. A C API is used as the "rendez-vous" point between both generators.

Right now the interface generator produces OCaml code and the implementation generator a subset of C that encodes some more guarantees than usual C code, but it still compatible with a normal C compiler.

Examples

For quick'n'dirty results, a Goo description of libui was written to illustrate the workflow:

Libui bindings running on Gtk Libui bindings running on OS X

TODO

  • implement multiple return values
  • should exception management be part of event definitions ? (... yes)
  • ctypes integration

Future work

There is nothing OCaml specific in Goo semantics. Adding backends for other languages should be a reasonable amount of work.

goo's People

Contributors

let-def 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

goo's Issues

Cool Project, Cant find `ui.h`

I wanted to run this to see how it works. Im getting an error maybe you can help with?

goo on  master [!?]
 [I] ➜ cd src/

goo/src on  master [!?]
 [I] ➜ make
make: Nothing to be done for `all'.

goo/src on  master [!?]
 [I] ➜ make install
ocamlfind install goo-gen META goo_gen.cma goo_gen.cmxa goo_c.cmi goo_id.cmi goo_ml.cmi goo_model.cmi
Installed /Volumes/SSD/.opam/reason/lib/goo-gen/goo_model.cmi
Installed /Volumes/SSD/.opam/reason/lib/goo-gen/goo_ml.cmi
Installed /Volumes/SSD/.opam/reason/lib/goo-gen/goo_id.cmi
Installed /Volumes/SSD/.opam/reason/lib/goo-gen/goo_c.cmi
Installed /Volumes/SSD/.opam/reason/lib/goo-gen/goo_gen.cmxa
Installed /Volumes/SSD/.opam/reason/lib/goo-gen/goo_gen.cma
Installed /Volumes/SSD/.opam/reason/lib/goo-gen/META

goo/src on  master [!?]
 [I] ➜ cd ../lib/

goo/lib on  master [!?]
 [I] ➜ make install
ocamlfind install goo-lib META goo_lib.cma goo_lib.cmxa \
		goo_lib.a libgoo.a \
		goo.cmi goo_ref.cmi goo.cmx goo_ref.cmx goo_system.h ml_goo.h
Installed /Volumes/SSD/.opam/reason/lib/goo-lib/ml_goo.h
Installed /Volumes/SSD/.opam/reason/lib/goo-lib/goo_system.h
Installed /Volumes/SSD/.opam/reason/lib/goo-lib/goo_ref.cmx
Installed /Volumes/SSD/.opam/reason/lib/goo-lib/goo.cmx
Installed /Volumes/SSD/.opam/reason/lib/goo-lib/goo_ref.cmi
Installed /Volumes/SSD/.opam/reason/lib/goo-lib/goo.cmi
Installed /Volumes/SSD/.opam/reason/lib/goo-lib/libgoo.a
Installed /Volumes/SSD/.opam/reason/lib/goo-lib/goo_lib.a
Installed /Volumes/SSD/.opam/reason/lib/goo-lib/goo_lib.cmxa
Installed /Volumes/SSD/.opam/reason/lib/goo-lib/goo_lib.cma
Installed /Volumes/SSD/.opam/reason/lib/goo-lib/META

goo/lib on  master [!?]
 [I] ➜ ../examples/libui/

goo/examples/libui on  master [!?]
 [I] ➜ make
ocaml desc.ml
ocamlc -c -ccopt "-g -I /Volumes/SSD/.opam/reason/lib/goo-lib" -c -g libui_box.c
In file included from libui_box.c:1:
In file included from ./libui_box.h:1:
./libui.h:45:10: fatal error: 'ui.h' file not found
#include "ui.h"
         ^~~~~~
1 error generated.
make: *** [libui_box.o] Error 2

goo/examples/libui on  master [!?]
 [I] ➜ make libui_stubs.c libui.h
ocaml desc.ml
make: Nothing to be done for `libui.h'.

goo/examples/libui on  master [!?]
 [I] ➜ make test
ocaml desc.ml
ocamlc -c -ccopt "-g -I /Volumes/SSD/.opam/reason/lib/goo-lib" -c -g libui_box.c
In file included from libui_box.c:1:
In file included from ./libui_box.h:1:
./libui.h:45:10: fatal error: 'ui.h' file not found
#include "ui.h"
         ^~~~~~
1 error generated.
make: *** [libui_box.o] Error 2

goo/examples/libui on  master [!?]
 [I] ➜

Am I supposed to create ui.h?

Also, for some reason, running make in root is not creating/installing the src and lib files. Thanks for sharing this.

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.