Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 0 additions & 14 deletions .appveyor.yml

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Main workflow

on:
pull_request:
push:
schedule:
# Prime the caches every Monday
- cron: 0 1 * * MON

jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
ocaml-compiler:
- 4.14
- 5

runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Use OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}

- run: opam install . --deps-only --with-test

- run: opam exec -- dune build

- run: opam exec -- dune runtest
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
_build
_opam
*.install
.merlin
.merlin
1 change: 1 addition & 0 deletions .ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = 0.26.2
74 changes: 0 additions & 74 deletions .travis.yml

This file was deleted.

28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,41 @@
[![Build Status](https://travis-ci.org/cedlemo/OCaml-GObject-Introspection.svg?branch=master)](https://travis-ci.org/cedlemo/OCaml-GObject-Introspection)
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)

[![Build Status](https://github.com/cedlemo/OCaml-GObject-Introspection/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/cedlemo/OCaml-GObject-Introspection/actions)
[![License: GPL-3.0-or-later](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)

# gobject-introspection OCaml package

The OCaml bindings to the [GObject-Introspection](https://gi.readthedocs.io/en/latest/index.html) library based on Ctypes.

## Installation

the package gobject-introspection is now published and available in the opam-repository:
The package gobject-introspection is now published and available in the opam-repository:

```
opam install gobject-introspection
```

## API:
## API

https://cedlemo.github.io/OCaml-GObject-Introspection/
<https://cedlemo.github.io/OCaml-GObject-Introspection/>

## Usage

Two ideas to explore:

- Create a generic Ctypes bindings generator, based on ocaml-gobject-introspection,
for the GNOME libraries : https://github.com/cedlemo/OCaml-GI-ctypes-bindings-generator
for the GNOME libraries: <https://github.com/cedlemo/OCaml-GI-ctypes-bindings-generator>.

- Create a generic FFI bindings generator for bucklescript in order to be able to
use the javascript bindings to the GNOME libraries. (I am not sure if it is
faisable).
feasible).

- https://devdocs.baznga.org/
- https://bucklescript.github.io/bucklescript/Manual.html#_ffi
- https://github.com/glennsl/bucklescript-ffi-cheatsheet
- https://github.com/Place1/node-gir
- <https://devdocs.baznga.org/>
- <https://bucklescript.github.io/bucklescript/Manual.html#_ffi>
- <https://github.com/glennsl/bucklescript-ffi-cheatsheet>
- <https://github.com/Place1/node-gir>

## Wiki :
## Manual

https://github.com/cedlemo/OCaml-GObject-Introspection/wiki#introduction
<https://github.com/cedlemo/OCaml-GObject-Introspection/wiki#introduction>

### table of content.

Expand All @@ -48,4 +47,3 @@ https://github.com/cedlemo/OCaml-GObject-Introspection/wiki#introduction
- [Finished](https://github.com/cedlemo/OCaml-GObject-Introspection/wiki/#finished)
- [Remains](https://github.com/cedlemo/OCaml-GObject-Introspection/wiki/#remains)
- [Resources](https://github.com/cedlemo/OCaml-GObject-Introspection/wiki/#resources)

129 changes: 72 additions & 57 deletions bindings/Arg_info.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

(** The direction of a Arg_info. *)
type direction =
| In (** in argument. *)
| Out (** out argument. *)
| InOut (** in and out argument. *)
| In (** in argument. *)
| Out (** out argument. *)
| InOut (** in and out argument. *)

let string_of_direction = function
| In -> "In"
Expand All @@ -35,23 +35,25 @@ let string_of_direction = function
complete. In case of a containing type such as a list, an array or a hash
table the container itself is specified differently from the items within
the container itself. Each container is freed differently, check the
documentation for the types themselves for information on how to free them.*)
documentation for the types themselves for information on how to free them. *)

type transfer =
| Nothing (** transfer nothing from the callee (function or the type
instance the property belongs to) to the caller. The callee
retains the ownership of the transfer and the caller doesn't
need to do anything to free up the resources of this transfer. *)
| Container (** transfer the container (list, array, hash table) from the
callee to the caller. The callee retains the ownership of
the individual items in the container and the caller has to
free up the container resources (g_list_free()/
g_hash_table_destroy() etc) of this transfer. *)
| Everything (** transfer everything, eg the container and its contents from
the callee to the caller. This is the case when the callee
creates a copy of all the data it returns. The caller is
responsible for cleaning up the container and item resources
of this transfer. *)
| Nothing
(** transfer nothing from the callee (function or the type instance
the property belongs to) to the caller. The callee retains the
ownership of the transfer and the caller doesn't need to do
anything to free up the resources of this transfer. *)
| Container
(** transfer the container (list, array, hash table) from the callee
to the caller. The callee retains the ownership of the individual
items in the container and the caller has to free up the
container resources (g_list_free()/ g_hash_table_destroy() etc)
of this transfer. *)
| Everything
(** transfer everything, eg the container and its contents from the
callee to the caller. This is the case when the callee creates a
copy of all the data it returns. The caller is responsible for
cleaning up the container and item resources of this transfer. *)

let string_of_transfert = function
| Nothing -> "Nothing"
Expand All @@ -62,54 +64,67 @@ let string_of_transfert = function
callback is invoked and is used to decided when the invoke structs can be
freed. *)
type scope_type =
| Invalid (** The argument is not of callback type. *)
| Call (** The callback and associated user_data is only used during the
call to this function. *)
| Async (** The callback and associated user_data is only used until the
callback is invoked, and the callback. is invoked always
exactly once. *)
| Notified (** The callback and and associated user_data is used until the
caller is notfied via the destroy_notify. *)
| Invalid (** The argument is not of callback type. *)
| Call
(** The callback and associated user_data is only used during the
call to this function. *)
| Async
(** The callback and associated user_data is only used until the
callback is invoked, and the callback. is invoked always exactly
once. *)
| Notified
(** The callback and and associated user_data is used until the
caller is notfied via the destroy_notify. *)

let string_of_scope_type = function
| Invalid -> "Invalid"
| Call -> "Call"
| Async -> "Async"
| Notified -> "Notified"

module Enums = functor (T : Cstubs.Types.TYPE) -> struct
let gi_direction_in = T.constant "GI_DIRECTION_IN" T.int64_t
let gi_direction_out = T.constant "GI_DIRECTION_OUT" T.int64_t
let gi_direction_inout = T.constant "GI_DIRECTION_INOUT" T.int64_t
module Enums =
functor
(T : Cstubs.Types.TYPE)
->
struct
let gi_direction_in = T.constant "GI_DIRECTION_IN" T.int64_t
let gi_direction_out = T.constant "GI_DIRECTION_OUT" T.int64_t
let gi_direction_inout = T.constant "GI_DIRECTION_INOUT" T.int64_t

let direction = T.enum "GIDirection" ~typedef:true [
In, gi_direction_in;
Out, gi_direction_out;
InOut, gi_direction_inout;
]
~unexpected:(Utils.unexpected_value_for "GIDirection")
let direction =
T.enum "GIDirection" ~typedef:true
[
(In, gi_direction_in);
(Out, gi_direction_out);
(InOut, gi_direction_inout);
]
~unexpected:(Utils.unexpected_value_for "GIDirection")

let gi_transfer_nothing = T.constant "GI_TRANSFER_NOTHING" T.int64_t
let gi_transfer_container = T.constant "GI_TRANSFER_CONTAINER" T.int64_t
let gi_transfer_everything = T.constant "GI_TRANSFER_EVERYTHING" T.int64_t
let gi_transfer_nothing = T.constant "GI_TRANSFER_NOTHING" T.int64_t
let gi_transfer_container = T.constant "GI_TRANSFER_CONTAINER" T.int64_t
let gi_transfer_everything = T.constant "GI_TRANSFER_EVERYTHING" T.int64_t

let transfer = T.enum "GITransfer" ~typedef:true [
Nothing, gi_transfer_nothing;
Container, gi_transfer_container;
Everything, gi_transfer_everything;
]
~unexpected:(Utils.unexpected_value_for "GITransfer")
let transfer =
T.enum "GITransfer" ~typedef:true
[
(Nothing, gi_transfer_nothing);
(Container, gi_transfer_container);
(Everything, gi_transfer_everything);
]
~unexpected:(Utils.unexpected_value_for "GITransfer")

let gi_scope_type_invalid = T.constant "GI_SCOPE_TYPE_INVALID" T.int64_t
let gi_scope_type_call = T.constant "GI_SCOPE_TYPE_CALL" T.int64_t
let gi_scope_type_async = T.constant "GI_SCOPE_TYPE_ASYNC" T.int64_t
let gi_scope_type_notified = T.constant "GI_SCOPE_TYPE_NOTIFIED" T.int64_t
let gi_scope_type_invalid = T.constant "GI_SCOPE_TYPE_INVALID" T.int64_t
let gi_scope_type_call = T.constant "GI_SCOPE_TYPE_CALL" T.int64_t
let gi_scope_type_async = T.constant "GI_SCOPE_TYPE_ASYNC" T.int64_t
let gi_scope_type_notified = T.constant "GI_SCOPE_TYPE_NOTIFIED" T.int64_t

let scope_type = T.enum "GIScopeType" ~typedef:true [
Invalid, gi_scope_type_invalid;
Call, gi_scope_type_call;
Async, gi_scope_type_async;
Notified, gi_scope_type_notified;
]
~unexpected:(Utils.unexpected_value_for "GIScopeType")
end
let scope_type =
T.enum "GIScopeType" ~typedef:true
[
(Invalid, gi_scope_type_invalid);
(Call, gi_scope_type_call);
(Async, gi_scope_type_async);
(Notified, gi_scope_type_notified);
]
~unexpected:(Utils.unexpected_value_for "GIScopeType")
end
Loading