summaryrefslogtreecommitdiffstats
path: root/vapi/erl_interface.vapi
blob: 55b89c20ed00e05f88247630916cec97c9d5ee2f (plain)
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
[CCode (cheader_filename = "ei.h", cprefix = "ei_", lower_case_cprefix = "ei_")]
namespace Erl {
  /*public int errno;
  
  [CCode (cname = "ei_cnode")]
  [Compact]
  public struct Node {
    [CCode (cname = "ei_connect_init")]
    public Node(string this_node_name, string cookie, short creation);
    
    public Connection connect(string nodename);
    
    public Pid* self();
  }
  
  [CCode (cname="int", cprefix="ERL_")]
  public enum ReceiveType {
    ERROR, TICK, MSG
  }
  [CCode (cname="int", cprefix="E")]
  public enum Error {
    TIMEDOUT
  }
  
  [CCode (cname = "int")]
  [Compact]
  public struct Connection : int {
    public bool is_valid() {
      return (this >= 0);
    }
    
    private ReceiveType xreceive_msg_tmo(Msg msg, Buffer buffer, uint timeout);
    
    [CCode (cname = "erl_receive_vala")]
    public ReceiveType receive(out Buffer buffer, uint timeout = 0) {
      buffer = Buffer();
      Msg msg;
      ReceiveType ret = xreceive_msg_tmo(msg, buffer, timeout);
      return ret;
    }
    }*/
  
  
  [CCode (cname="MAXATOMLEN")]
  public const int MAXATOMLEN;
  
  [CCode (cname="char")]
  public enum TermType {
    [CCode (cname="ERL_SMALL_INTEGER_EXT")]
    SMALL_INTEGER,
    [CCode (cname="ERL_INTEGER_EXT")]
    INTEGER,
    [CCode (cname="ERL_FLOAT_EXT")]
    FLOAT,
    [CCode (cname="ERL_ATOM_EXT")]
    ATOM,
    [CCode (cname="ERL_REFERENCE_EXT")]
    REFERENCE,
    [CCode (cname="ERL_NEW_REFERENCE_EXT")]
    NEW_REFERENCE,
    [CCode (cname="ERL_PORT_EXT")]
    PORT,
    [CCode (cname="ERL_PID_EXT")]
    PID,
    [CCode (cname="ERL_SMALL_TUPLE_EXT")]
    SMALL_TUPLE,
    [CCode (cname="ERL_LARGE_TUPLE_EXT")]
    LARGE_TUPLE,
    [CCode (cname="ERL_NIL_EXT")]
    NIL,
    [CCode (cname="ERL_STRING_EXT")]
    STRING,
    [CCode (cname="ERL_LIST_EXT")]
    LIST,
    [CCode (cname="ERL_BINARY_EXT")]
    BINARY,
    [CCode (cname="ERL_SMALL_BIG_EXT")]
    SMALL_BIG,
    [CCode (cname="ERL_LARGE_BIG_EXT")]
    LARGE_BIG,
    [CCode (cname="ERL_NEW_FUN_EXT")]
    NEW_FUN,
    [CCode (cname="ERL_FUN_EXT")]
    FUN
  }
  
  public int get_type(char *buf, ref int index, out int type, out int size);
  
  public int decode_version(char *buf, ref int index, out int version);
  public int decode_char(char *buf, ref int index, out char value);
  public int decode_long(char *buf, ref int index, out long value);
  public int decode_double(char *buf, ref int index, out double value);
  public int decode_atom(char *buf, ref int index, char *p);
  public int decode_tuple_header(char *buf, ref int index, out int arity);
  public int decode_list_header(char *buf, ref int index, out int arity);
  public int decode_string(char *buf, ref int index, char *p);
  public int decode_binary(char *buf, ref int index, char *p, out long len);
  public int decode_pid(char *buf, ref int index, out Pid pid);
  public int decode_port(char *buf, ref int index, out Port port);
  public int decode_ref(char *buf, ref int index, out Ref reference);
  
  
  [CCode (cname = "ei_x_buff", cprefix = "ei_x_", destroy_function = "ei_x_free")]
  [Compact]
  public struct Buffer {
    [CCode (array_length_cname = "index", array_length_type = "int")]
    public char[] buff;
    
    [CCode (cname = "ei_x_new")]
    public Buffer();
    
    [CCode (cname = "ei_x_new_with_version")]
    public Buffer.with_version();
    
    public int encode_long(long p);
    public int encode_ulong(ulong p);
    public int encode_double(double p);
    [CCode (cname = "ei_x_encode_atom_len")]
    public int encode_atom(char[] p);
    public int encode_tuple_header(int arity);
    public int encode_list_header(int arity);
    public int encode_empty_list();
    [CCode (cname = "ei_x_encode_string_len")]
    public int encode_string(char[] p);
    public int encode_binary(char* p, long len);
    public int encode_pid(Pid pid);
    public int encode_port(Port port);
    public int encode_ref(Ref reference);
  }
  
  [CCode (cname = "erlang_pid", destroy_function = "")]
  [Compact]
  public struct Pid {
    public char[] node;
    public uint num;
    public uint serial;
    public uint creation;
  }
  
  [CCode (cname = "erlang_port", destroy_function = "")]
  [Compact]
  public struct Port {
    public char[] node;
    public uint id;
    public uint creation;
  }
  
  [CCode (cname = "erlang_ref", destroy_function = "")]
  [Compact]
  public struct Ref {
    public char[] node;
    public int len;
    public uint* n;
    public uint creation;
  }
  
  /*[CCode (cname = "erlang_msg", destroy_function = "")]
  [Compact]
  private struct Msg {
    public Pid from;
    }*/
}