summaryrefslogtreecommitdiff
path: root/src/bindings/js/eldbus_js/eldbus_js_core.cc
blob: e9a8c3344dc3466f13f0c320d1bea2ca0a446901 (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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <Eldbus_Js.hh>

namespace efl { namespace eldbus { namespace js {

namespace {

void register_init(v8::Isolate *isolate, v8::Handle<v8::Object> global,
                   v8::Handle<v8::String> name)
{
    using v8::Integer;
    using v8::FunctionTemplate;

    auto init = [](compatibility_callback_info_type args)
        -> compatibility_return_type {
        if (args.Length() != 0)
            return compatibility_return();

        auto isolate = args.GetIsolate();
        auto ret = eldbus_init();
        return compatibility_return(compatibility_new<Integer>(isolate, ret),
                                    args);
    };

    global->Set(name,
                compatibility_new<FunctionTemplate>(isolate, init)
                ->GetFunction());
}

void register_shutdown(v8::Isolate *isolate, v8::Handle<v8::Object> global,
                       v8::Handle<v8::String> name)
{
    using v8::Integer;
    using v8::FunctionTemplate;

    auto shutdown = [](compatibility_callback_info_type args)
        -> compatibility_return_type {
        if (args.Length() != 0)
            return compatibility_return();

        auto isolate = args.GetIsolate();
        auto ret = eldbus_shutdown();
        return compatibility_return(compatibility_new<Integer>(isolate, ret),
                                    args);
    };

    global->Set(name,
                compatibility_new<FunctionTemplate>(isolate, shutdown)
                ->GetFunction());
}

void register_fdo_bus(v8::Isolate *isolate, v8::Handle<v8::Object> global,
                      v8::Handle<v8::String> name)
{
    using v8::String;
    global->Set(name, compatibility_new<String>(isolate, ELDBUS_FDO_BUS));
}

void register_fdo_path(v8::Isolate *isolate, v8::Handle<v8::Object> global,
                       v8::Handle<v8::String> name)
{
    using v8::String;
    global->Set(name, compatibility_new<String>(isolate, ELDBUS_FDO_PATH));
}

void register_fdo_interface(v8::Isolate *isolate, v8::Handle<v8::Object> global,
                            v8::Handle<v8::String> name)
{
    using v8::String;
    global->Set(name, compatibility_new<String>(isolate, ELDBUS_FDO_INTERFACE));
}

void register_fdo_interface_properties(v8::Isolate *isolate,
                                       v8::Handle<v8::Object> global,
                                       v8::Handle<v8::String> name)
{
    using v8::String;
    global->Set(name,
                compatibility_new<String>(isolate,
                                          ELDBUS_FDO_INTERFACE_PROPERTIES));
}

void register_fdo_interface_object_manager(v8::Isolate *isolate,
                                           v8::Handle<v8::Object> global,
                                           v8::Handle<v8::String> name)
{
    using v8::String;
    global->Set(name,
                compatibility_new<String>(isolate,
                                          ELDBUS_FDO_INTERFACE_OBJECT_MANAGER));
}

void register_fdo_interface_introspectable(v8::Isolate *isolate,
                                           v8::Handle<v8::Object> global,
                                           v8::Handle<v8::String> name)
{
    using v8::String;
    global->Set(name,
                compatibility_new<String>(isolate,
                                          ELDBUS_FDO_INTERFACE_INTROSPECTABLE));
}

void register_fdo_inteface_peer(v8::Isolate *isolate,
                                v8::Handle<v8::Object> global,
                                v8::Handle<v8::String> name)
{
    using v8::String;
    global->Set(name,
                compatibility_new<String>(isolate, ELDBUS_FDO_INTEFACE_PEER));
}

void register_error_pending_canceled(v8::Isolate *isolate,
                                     v8::Handle<v8::Object> global,
                                     v8::Handle<v8::String> name)
{
    using v8::String;
    global->Set(name,
                compatibility_new<String>(isolate,
                                          ELDBUS_ERROR_PENDING_CANCELED));
}

void register_error_pending_timeout(v8::Isolate *isolate,
                                    v8::Handle<v8::Object> global,
                                    v8::Handle<v8::String> name)
{
    using v8::String;
    global->Set(name,
                compatibility_new<String>(isolate,
                                          ELDBUS_ERROR_PENDING_TIMEOUT));
}

}

EAPI
void register_eldbus_core(v8::Isolate* isolate, v8::Handle<v8::Object> exports)
{
   using v8::String;
   register_init(isolate, exports,
                 compatibility_new<String>(isolate, "eldbus_init"));
   register_shutdown(isolate, exports,
                     compatibility_new<String>(isolate, "eldbus_shutdown"));
   register_fdo_bus(isolate, exports,
                    compatibility_new<String>(isolate, "ELDBUS_FDO_BUS"));
   register_fdo_path(isolate, exports,
                     compatibility_new<String>(isolate, "ELDBUS_FDO_PATH"));
   register_fdo_interface(isolate, exports,
                          compatibility_new<String>(isolate,
                                                    "ELDBUS_FDO_INTERFACE"));
   register_fdo_interface_properties(isolate, exports,
                                     compatibility_new<String>
                                     (isolate,
                                      "ELDBUS_FDO_INTERFACE_PROPERTIES"));
   register_fdo_interface_object_manager(isolate, exports,
                                         compatibility_new<String>
                                         (isolate, "ELDBUS_FDO_INTERFACE_OBJECT_MANAGER"));
   
   register_fdo_interface_introspectable
     (isolate, exports,
      compatibility_new<String>(isolate,
                                "ELDBUS_FDO_INTERFACE_INTROSPECTABLE"));
   register_fdo_inteface_peer(isolate, exports,
                              compatibility_new<String>
                              (isolate, "ELDBUS_FDO_INTEFACE_PEER"));
   register_error_pending_canceled
     (isolate, exports,
      compatibility_new<String>(isolate, "ELDBUS_ERROR_PENDING_CANCELED"));
   register_error_pending_timeout
     (isolate, exports,
      compatibility_new<String>(isolate, "ELDBUS_ERROR_PENDING_TIMEOUT"));
}

EAPI void register_eldbus(v8::Isolate* isolate, v8::Handle<v8::Object> exports)
{
  register_eldbus_connection(isolate, exports);
  register_eldbus_core(isolate, exports);
  register_eldbus_message(isolate, exports);
  register_eldbus_object_mapper(isolate, exports);
}
      
} } } // namespace efl { namespace eldbus { namespace js {