package obus

  1. Overview
  2. Docs
Pure Ocaml implementation of the D-Bus protocol

Install

Dune Dependency

Authors

Maintainers

Sources

obus-1.2.5.tar.gz
md5=81eb1034c6ef4421a2368a9b352199de
sha512=4b540497188a7d78f4f14f94c6b7fdff47dd06436a34e650ff378dd77bb3e2acb7afd45cd72daf4ddba06e732e9944d560c2882dc37862f1b1f1bb6df37e6205

doc/src/obus/oBus_member.ml.html

Source file oBus_member.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
(*
 * oBus_member.ml
 * --------------
 * Copyright : (c) 2010, Jeremie Dimino <jeremie@dimino.org>
 * Licence   : BSD3
 *
 * This file is a part of obus, an ocaml implementation of D-Bus.
 *)

open OBus_introspect

let introspect_arguments args =
  List.map2
    (fun name typ -> (name, typ))
    (OBus_value.arg_names args)
    (OBus_value.C.type_sequence (OBus_value.arg_types args))

module Method =
struct
  type ('a, 'b) t = {
    interface : OBus_name.interface;
    member : OBus_name.member;
    i_args : 'a OBus_value.arguments;
    o_args : 'b OBus_value.arguments;
    annotations : OBus_introspect.annotation list;
  }

  let make ~interface ~member ~i_args ~o_args ~annotations = {
    interface = interface;
    member = member;
    i_args = i_args;
    o_args = o_args;
    annotations = annotations;
  }

  let interface m = m.interface
  let member m = m.member
  let i_args m = m.i_args
  let o_args m = m.o_args
  let annotations m = m.annotations

  let introspect m =
    Method(m.member, introspect_arguments m.i_args, introspect_arguments m.o_args, m.annotations)
end

module Signal =
struct
  type 'a t = {
    interface : OBus_name.interface;
    member : OBus_name.member;
    args : 'a OBus_value.arguments;
    annotations : OBus_introspect.annotation list;
  }

  let make ~interface ~member ~args ~annotations = {
    interface = interface;
    member = member;
    args = args;
    annotations = annotations;
  }

  let interface s = s.interface
  let member s = s.member
  let args s = s.args
  let annotations s = s.annotations

  let introspect s =
    Signal(s.member, introspect_arguments s.args, s.annotations)
end

module Property =
struct
  type 'a access =
    | Readable
    | Writable
    | Readable_writable

  let readable = Readable
  let writable = Writable
  let readable_writable = Readable_writable

  type ('a, 'access) t = {
    interface : OBus_name.interface;
    member : OBus_name.member;
    typ : 'a OBus_value.C.single;
    access : 'access access;
    annotations : OBus_introspect.annotation list;
  }

  let make ~interface ~member ~typ ~access ~annotations = {
    interface = interface;
    member = member;
    typ = typ;
    access = access;
    annotations = annotations;
  }

  let interface p = p.interface
  let member p = p.member
  let typ p = p.typ
  let access p = p.access
  let annotations p = p.annotations

  let introspect p =
    Property(p.member, OBus_value.C.type_single p.typ,
             (match p.access with
                | Readable -> Read
                | Writable -> Write
                | Readable_writable -> Read_write),
             p.annotations)
end
OCaml

Innovation. Community. Security.