summaryrefslogtreecommitdiff
path: root/src/bindings
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2019-04-12 15:48:36 +0200
committerDaniel Kolesa <d.kolesa@samsung.com>2019-04-12 15:53:26 +0200
commit37eee70d56aeff8649822cab62f736512cebf5d0 (patch)
treef6b736f2b0bd3f298b2ef3139c70545b930e3d6f /src/bindings
parentae77e5836634d59ab576878fb3e2577e4e5c3e78 (diff)
elua: add all missing eolian api bindings
Diffstat (limited to 'src/bindings')
-rw-r--r--src/bindings/luajit/eolian.lua140
1 files changed, 140 insertions, 0 deletions
diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua
index 4d17e4790d..0b99715ed9 100644
--- a/src/bindings/luajit/eolian.lua
+++ b/src/bindings/luajit/eolian.lua
@@ -17,6 +17,7 @@ ffi.cdef [[
17 typedef struct _Eolian_Object Eolian_Object; 17 typedef struct _Eolian_Object Eolian_Object;
18 typedef struct _Eolian_Class Eolian_Class; 18 typedef struct _Eolian_Class Eolian_Class;
19 typedef struct _Eolian_Function Eolian_Function; 19 typedef struct _Eolian_Function Eolian_Function;
20 typedef struct _Eolian_Part Eolian_Part;
20 typedef struct _Eolian_Type Eolian_Type; 21 typedef struct _Eolian_Type Eolian_Type;
21 typedef struct _Eolian_Typedecl Eolian_Typedecl; 22 typedef struct _Eolian_Typedecl Eolian_Typedecl;
22 typedef struct _Eolian_Function_Parameter Eolian_Function_Parameter; 23 typedef struct _Eolian_Function_Parameter Eolian_Function_Parameter;
@@ -31,6 +32,9 @@ ffi.cdef [[
31 typedef struct _Eolian_Value Eolian_Value; 32 typedef struct _Eolian_Value Eolian_Value;
32 typedef struct _Eolian_Unit Eolian_Unit; 33 typedef struct _Eolian_Unit Eolian_Unit;
33 34
35 typedef void (*Eolian_Panic_Cb)(const Eolian_State *state, const char *msg);
36 typedef void (*Eolian_Error_Cb)(const Eolian_Object *obj, const char *msg, void *data);
37
34 typedef enum { 38 typedef enum {
35 EOLIAN_OBJECT_UNKNOWN = 0, 39 EOLIAN_OBJECT_UNKNOWN = 0,
36 EOLIAN_OBJECT_CLASS, 40 EOLIAN_OBJECT_CLASS,
@@ -288,7 +292,11 @@ ffi.cdef [[
288 int eolian_shutdown(void); 292 int eolian_shutdown(void);
289 Eolian_State *eolian_state_new(void); 293 Eolian_State *eolian_state_new(void);
290 void eolian_state_free(Eolian_State *state); 294 void eolian_state_free(Eolian_State *state);
295 Eolian_Panic_Cb eolian_state_panic_cb_set(Eolian_State *state, Eolian_Panic_Cb cb);
296 Eolian_Error_Cb eolian_state_error_cb_set(Eolian_State *state, Eolian_Error_Cb cb);
297 void *eolian_state_error_data_set(Eolian_State *state, void *data);
291 Eolian_Object_Type eolian_object_type_get(const Eolian_Object *obj); 298 Eolian_Object_Type eolian_object_type_get(const Eolian_Object *obj);
299 const Eolian_Unit *eolian_object_unit_get(const Eolian_Object *obj);
292 const char *eolian_object_file_get(const Eolian_Object *obj); 300 const char *eolian_object_file_get(const Eolian_Object *obj);
293 int eolian_object_line_get(const Eolian_Object *obj); 301 int eolian_object_line_get(const Eolian_Object *obj);
294 int eolian_object_column_get(const Eolian_Object *obj); 302 int eolian_object_column_get(const Eolian_Object *obj);
@@ -309,8 +317,10 @@ ffi.cdef [[
309 const Eolian_Unit *eolian_state_unit_by_file_get(const Eolian_State *state, const char *file_name); 317 const Eolian_Unit *eolian_state_unit_by_file_get(const Eolian_State *state, const char *file_name);
310 Eina_Iterator *eolian_state_units_get(const Eolian_State *state); 318 Eina_Iterator *eolian_state_units_get(const Eolian_State *state);
311 319
320 const Eolian_State *eolian_unit_state_get(const Eolian_Unit *unit);
312 Eina_Iterator *eolian_unit_children_get(const Eolian_Unit *unit); 321 Eina_Iterator *eolian_unit_children_get(const Eolian_Unit *unit);
313 const char *eolian_unit_file_get(const Eolian_Unit *unit); 322 const char *eolian_unit_file_get(const Eolian_Unit *unit);
323 const char *eolian_unit_file_path_get(const Eolian_Unit *unit);
314 const Eolian_Object *eolian_unit_object_by_name_get(const Eolian_Unit *unit, const char *name); 324 const Eolian_Object *eolian_unit_object_by_name_get(const Eolian_Unit *unit, const char *name);
315 Eina_Iterator *eolian_unit_objects_get(const Eolian_Unit *unit); 325 Eina_Iterator *eolian_unit_objects_get(const Eolian_Unit *unit);
316 const Eolian_Class *eolian_unit_class_by_name_get(const Eolian_Unit *unit, const char *class_name); 326 const Eolian_Class *eolian_unit_class_by_name_get(const Eolian_Unit *unit, const char *class_name);
@@ -336,8 +346,10 @@ ffi.cdef [[
336 Eolian_Class_Type eolian_class_type_get(const Eolian_Class *klass); 346 Eolian_Class_Type eolian_class_type_get(const Eolian_Class *klass);
337 const Eolian_Documentation *eolian_class_documentation_get(const Eolian_Class *klass); 347 const Eolian_Documentation *eolian_class_documentation_get(const Eolian_Class *klass);
338 const char *eolian_class_eo_prefix_get(const Eolian_Class *klass); 348 const char *eolian_class_eo_prefix_get(const Eolian_Class *klass);
349 const char *eolian_class_event_prefix_get(const Eolian_Class *klass);
339 const char *eolian_class_data_type_get(const Eolian_Class *klass); 350 const char *eolian_class_data_type_get(const Eolian_Class *klass);
340 const Eolian_Class *eolian_class_parent_get(const Eolian_Class *klass); 351 const Eolian_Class *eolian_class_parent_get(const Eolian_Class *klass);
352 Eina_Iterator *eolian_class_requires_get(const Eolian_Class *klass);
341 Eina_Iterator *eolian_class_extensions_get(const Eolian_Class *klass); 353 Eina_Iterator *eolian_class_extensions_get(const Eolian_Class *klass);
342 Eina_Iterator *eolian_class_functions_get(const Eolian_Class *klass, Eolian_Function_Type func_type); 354 Eina_Iterator *eolian_class_functions_get(const Eolian_Class *klass, Eolian_Function_Type func_type);
343 Eolian_Function_Type eolian_function_type_get(const Eolian_Function *function_id); 355 Eolian_Function_Type eolian_function_type_get(const Eolian_Function *function_id);
@@ -363,6 +375,7 @@ ffi.cdef [[
363 const Eolian_Documentation *eolian_function_return_documentation_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype); 375 const Eolian_Documentation *eolian_function_return_documentation_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
364 Eina_Bool eolian_function_return_is_warn_unused(const Eolian_Function *foo_id, Eolian_Function_Type ftype); 376 Eina_Bool eolian_function_return_is_warn_unused(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
365 Eina_Bool eolian_function_object_is_const(const Eolian_Function *function_id); 377 Eina_Bool eolian_function_object_is_const(const Eolian_Function *function_id);
378 const Eolian_Class *eolian_function_class_get(const Eolian_Function *function_id);
366 const Eolian_Class *eolian_implement_class_get(const Eolian_Implement *impl); 379 const Eolian_Class *eolian_implement_class_get(const Eolian_Implement *impl);
367 const Eolian_Class *eolian_implement_implementing_class_get(const Eolian_Implement *impl); 380 const Eolian_Class *eolian_implement_implementing_class_get(const Eolian_Implement *impl);
368 const Eolian_Function *eolian_implement_function_get(const Eolian_Implement *impl, Eolian_Function_Type *func_type); 381 const Eolian_Function *eolian_implement_function_get(const Eolian_Implement *impl, Eolian_Function_Type *func_type);
@@ -376,6 +389,7 @@ ffi.cdef [[
376 const Eolian_Class *eolian_constructor_class_get(const Eolian_Constructor *ctor); 389 const Eolian_Class *eolian_constructor_class_get(const Eolian_Constructor *ctor);
377 const Eolian_Function *eolian_constructor_function_get(const Eolian_Constructor *ctor); 390 const Eolian_Function *eolian_constructor_function_get(const Eolian_Constructor *ctor);
378 Eina_Bool eolian_constructor_is_optional(const Eolian_Constructor *ctor); 391 Eina_Bool eolian_constructor_is_optional(const Eolian_Constructor *ctor);
392 Eina_Bool eolian_constructor_is_ctor_param(const Eolian_Constructor *ctor);
379 Eina_Iterator *eolian_class_constructors_get(const Eolian_Class *klass); 393 Eina_Iterator *eolian_class_constructors_get(const Eolian_Class *klass);
380 Eina_Iterator *eolian_class_events_get(const Eolian_Class *klass); 394 Eina_Iterator *eolian_class_events_get(const Eolian_Class *klass);
381 const Eolian_Type *eolian_event_type_get(const Eolian_Event *event); 395 const Eolian_Type *eolian_event_type_get(const Eolian_Event *event);
@@ -384,12 +398,18 @@ ffi.cdef [[
384 Eolian_Object_Scope eolian_event_scope_get(const Eolian_Event *event); 398 Eolian_Object_Scope eolian_event_scope_get(const Eolian_Event *event);
385 Eina_Bool eolian_event_is_hot(const Eolian_Event *event); 399 Eina_Bool eolian_event_is_hot(const Eolian_Event *event);
386 Eina_Bool eolian_event_is_restart(const Eolian_Event *event); 400 Eina_Bool eolian_event_is_restart(const Eolian_Event *event);
401 Eina_Iterator *eolian_class_parts_get(const Eolian_Class *klass);
387 const char *eolian_event_c_name_get(const Eolian_Event *event); 402 const char *eolian_event_c_name_get(const Eolian_Event *event);
403 const Eolian_Class *eolian_part_class_get(const Eolian_Part *part);
404 const Eolian_Documentation *eolian_part_documentation_get(const Eolian_Part *part);
405 const Eolian_Event *eolian_class_event_by_name_get(const Eolian_Class *klass, const char *event_name);
388 Eina_Bool eolian_class_ctor_enable_get(const Eolian_Class *klass); 406 Eina_Bool eolian_class_ctor_enable_get(const Eolian_Class *klass);
389 Eina_Bool eolian_class_dtor_enable_get(const Eolian_Class *klass); 407 Eina_Bool eolian_class_dtor_enable_get(const Eolian_Class *klass);
390 const char *eolian_class_c_get_function_name_get(const Eolian_Class *klass); 408 const char *eolian_class_c_get_function_name_get(const Eolian_Class *klass);
391 Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp); 409 Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp);
392 Eolian_Type_Builtin_Type eolian_type_builtin_type_get(const Eolian_Type *tp); 410 Eolian_Type_Builtin_Type eolian_type_builtin_type_get(const Eolian_Type *tp);
411 const char *eolian_class_c_name_get(const Eolian_Class *klass);
412 const char *eolian_class_c_data_type_get(const Eolian_Class *klass);
393 Eolian_Typedecl_Type eolian_typedecl_type_get(const Eolian_Typedecl *tp); 413 Eolian_Typedecl_Type eolian_typedecl_type_get(const Eolian_Typedecl *tp);
394 Eina_Iterator *eolian_typedecl_struct_fields_get(const Eolian_Typedecl *tp); 414 Eina_Iterator *eolian_typedecl_struct_fields_get(const Eolian_Typedecl *tp);
395 const Eolian_Struct_Type_Field *eolian_typedecl_struct_field_get(const Eolian_Typedecl *tp, const char *field); 415 const Eolian_Struct_Type_Field *eolian_typedecl_struct_field_get(const Eolian_Typedecl *tp, const char *field);
@@ -534,6 +554,14 @@ local object_idx, wrap_object = gen_wrap {
534 return tonumber(eolian.eolian_object_type_get(cast_obj(self))) 554 return tonumber(eolian.eolian_object_type_get(cast_obj(self)))
535 end, 555 end,
536 556
557 unit_get = function(self)
558 local v = eolian.eolian_object_unit_get(cast_obj(self))
559 if v == nil then
560 return nil
561 end
562 return v
563 end,
564
537 line_get = function(self) 565 line_get = function(self)
538 return tonumber(eolian.eolian_object_line_get(cast_obj(self))) 566 return tonumber(eolian.eolian_object_line_get(cast_obj(self)))
539 end, 567 end,
@@ -579,6 +607,12 @@ local object_idx, wrap_object = gen_wrap {
579ffi.metatype("Eolian_Object", { __index = object_idx }) 607ffi.metatype("Eolian_Object", { __index = object_idx })
580 608
581local unit_idx, wrap_unit = gen_wrap { 609local unit_idx, wrap_unit = gen_wrap {
610 state_get = function(self)
611 local v = eolian.eolian_unit_state_get(cast_unit(self))
612 if v == nil then return nil end
613 return v
614 end,
615
582 children_get = function(self) 616 children_get = function(self)
583 return Ptr_Iterator("const Eolian_Unit*", 617 return Ptr_Iterator("const Eolian_Unit*",
584 eolian.eolian_unit_children_get(cast_unit(self))) 618 eolian.eolian_unit_children_get(cast_unit(self)))
@@ -590,6 +624,12 @@ local unit_idx, wrap_unit = gen_wrap {
590 return ffi.string(v) 624 return ffi.string(v)
591 end, 625 end,
592 626
627 file_path_get = function(self)
628 local v = eolian.eolian_unit_file_path_get(cast_unit(self))
629 if v == nil then return nil end
630 return ffi.string(v)
631 end,
632
593 object_by_name_get = function(self, name) 633 object_by_name_get = function(self, name)
594 local v = eolian.eolian_unit_object_by_name_get(cast_unit(self), name) 634 local v = eolian.eolian_unit_object_by_name_get(cast_unit(self), name)
595 if v == nil then return nil end 635 if v == nil then return nil end
@@ -670,8 +710,43 @@ local unit_idx, wrap_unit = gen_wrap {
670 710
671ffi.metatype("Eolian_Unit", { __index = unit_idx }) 711ffi.metatype("Eolian_Unit", { __index = unit_idx })
672 712
713local panic_cbs = {}
714local error_cbs = {}
715
716local obj_to_idx = function(obj)
717 return tonumber(ffi.cast("size_t", obj))
718end
719
720local panic_cb, err_cb
721
722panic_cb = ffi.gc(ffi.cast("Eolian_Panic_Cb", function(state, msg)
723 local pcb = panic_cbs[obj_to_idx(self)]
724 assert(pcb, "internal error: no prror cb")
725 pcb(state, ffi.string(msg))
726end), function(cb)
727 cb:free()
728end)
729
730err_cb = ffi.gc(ffi.cast("Eolian_Panic_Cb", function(obj, msg, data)
731 local ecb = error_cbs[obj_to_idx(self)]
732 assert(ecb, "internal error: no error cb")
733 ecb(obj, ffi.string(msg))
734end), function(cb)
735 cb:free()
736end)
737
673ffi.metatype("Eolian_State", { 738ffi.metatype("Eolian_State", {
674 __index = wrap_unit { 739 __index = wrap_unit {
740 panic_cb_set = function(self, cb)
741 panic_cbs[obj_to_idx(self)] = cb
742 eolian.eolian_state_panic_cb_set(self, panic_cb)
743 end,
744
745 error_cb_set = function(self, cb)
746 error_cbs[obj_to_idx(self)] = cb
747 eolian.eolian_state_error_cb_set(self, err_cb)
748 end,
749
675 directory_add = function(self, dir) 750 directory_add = function(self, dir)
676 return eolian.eolian_state_directory_add(self, dir) ~= 0 751 return eolian.eolian_state_directory_add(self, dir) ~= 0
677 end, 752 end,
@@ -770,6 +845,9 @@ ffi.metatype("Eolian_State", {
770 end 845 end
771 }, 846 },
772 __gc = function(self) 847 __gc = function(self)
848 local idx = obj_to_idx(self)
849 panic_cbs[idx] = nil
850 error_cbs[idx] = nil
773 eolian.eolian_state_free(self) 851 eolian.eolian_state_free(self)
774 end 852 end
775}) 853})
@@ -1127,6 +1205,12 @@ M.Function = ffi.metatype("Eolian_Function", {
1127 1205
1128 is_const = function(self) 1206 is_const = function(self)
1129 return eolian.eolian_function_object_is_const(self) ~= 0 1207 return eolian.eolian_function_object_is_const(self) ~= 0
1208 end,
1209
1210 class_get = function(self)
1211 local v = eolian.eolian_function_class_get(self)
1212 if v == nil then return nil end
1213 return v
1130 end 1214 end
1131 } 1215 }
1132}) 1216})
@@ -1241,6 +1325,10 @@ ffi.metatype("Eolian_Constructor", {
1241 1325
1242 is_optional = function(self) 1326 is_optional = function(self)
1243 return eolian.eolian_constructor_is_optional(self) ~= 0 1327 return eolian.eolian_constructor_is_optional(self) ~= 0
1328 end,
1329
1330 is_ctor_param = function(self)
1331 return eolian.eolian_constructor_is_ctor_param(self) ~= 0
1244 end 1332 end
1245 } 1333 }
1246}) 1334})
@@ -1285,6 +1373,22 @@ ffi.metatype("Eolian_Event", {
1285 } 1373 }
1286}) 1374})
1287 1375
1376ffi.metatype("Eolian_Part", {
1377 __index = wrap_object {
1378 class_get = function(self)
1379 local v = eolian.eolian_part_class_get(self)
1380 if v == nil then return nil end
1381 return v
1382 end,
1383
1384 documentation_get = function(self)
1385 local v = eolian.eolian_part_documentation_get(self)
1386 if v == nil then return nil end
1387 return v
1388 end
1389 }
1390})
1391
1288M.class_type = { 1392M.class_type = {
1289 UNKNOWN = 0, 1393 UNKNOWN = 0,
1290 REGULAR = 1, 1394 REGULAR = 1,
@@ -1315,6 +1419,14 @@ M.Class = ffi.metatype("Eolian_Class", {
1315 return ffi.string(v) 1419 return ffi.string(v)
1316 end, 1420 end,
1317 1421
1422 event_prefix_get = function(self)
1423 local v = eolian.eolian_class_event_prefix_get(self)
1424 if v == nil then
1425 return self:eo_prefix_get()
1426 end
1427 return ffi.string(v)
1428 end,
1429
1318 data_type_get = function(self) 1430 data_type_get = function(self)
1319 local v = eolian.eolian_class_data_type_get(self) 1431 local v = eolian.eolian_class_data_type_get(self)
1320 if v == nil then return nil end 1432 if v == nil then return nil end
@@ -1332,6 +1444,11 @@ M.Class = ffi.metatype("Eolian_Class", {
1332 eolian.eolian_class_extensions_get(self)) 1444 eolian.eolian_class_extensions_get(self))
1333 end, 1445 end,
1334 1446
1447 requires_get = function(self)
1448 return Ptr_Iterator("const Eolian_Class*",
1449 eolian.eolian_class_requires_get(self))
1450 end,
1451
1335 functions_get = function(self, func_type) 1452 functions_get = function(self, func_type)
1336 return Ptr_Iterator("const Eolian_Function*", 1453 return Ptr_Iterator("const Eolian_Function*",
1337 eolian.eolian_class_functions_get(self, func_type)) 1454 eolian.eolian_class_functions_get(self, func_type))
@@ -1359,6 +1476,17 @@ M.Class = ffi.metatype("Eolian_Class", {
1359 eolian.eolian_class_events_get(self)) 1476 eolian.eolian_class_events_get(self))
1360 end, 1477 end,
1361 1478
1479 event_by_name_get = function(self, name)
1480 local v = eolian.eolian_class_event_by_name_get(self, name)
1481 if v == nil then return nil end
1482 return v
1483 end,
1484
1485 parts_get = function(self)
1486 return Ptr_Iterator("const Eolian_Part*",
1487 eolian.eolian_class_parts_get(self))
1488 end,
1489
1362 ctor_enable_get = function(self) 1490 ctor_enable_get = function(self)
1363 return eolian.eolian_class_ctor_enable_get(self) ~= 0 1491 return eolian.eolian_class_ctor_enable_get(self) ~= 0
1364 end, 1492 end,
@@ -1371,6 +1499,18 @@ M.Class = ffi.metatype("Eolian_Class", {
1371 local v = eolian.eolian_class_c_get_function_name_get(self) 1499 local v = eolian.eolian_class_c_get_function_name_get(self)
1372 if v == nil then return nil end 1500 if v == nil then return nil end
1373 return ffi_stringshare(v) 1501 return ffi_stringshare(v)
1502 end,
1503
1504 c_name_get = function(self)
1505 local v = eolian.eolian_class_c_name_get(self)
1506 if v == nil then return nil end
1507 return ffi_stringshare(v)
1508 end,
1509
1510 c_data_type_get = function(self)
1511 local v = eolian.eolian_class_c_data_type_get(self)
1512 if v == nil then return nil end
1513 return ffi_stringshare(v)
1374 end 1514 end
1375 } 1515 }
1376}) 1516})