diff options
author | Daniel Kolesa <d.kolesa@osg.samsung.com> | 2018-03-08 22:48:01 +0100 |
---|---|---|
committer | Daniel Kolesa <d.kolesa@osg.samsung.com> | 2018-03-08 22:48:01 +0100 |
commit | 10448fec97997f47944b4cfcc36b2f629be81eab (patch) | |
tree | 6c99049f50d4abab1f1bfb38237a2107b339183f /src/scripts | |
parent | 59aabb0945761261c80a02b5b8a05e5b48773e70 (diff) |
pyolian: add Eolian_Object APIs and remove obsolete file_get ones
Diffstat (limited to 'src/scripts')
-rw-r--r-- | src/scripts/pyolian/eolian.py | 88 | ||||
-rw-r--r-- | src/scripts/pyolian/eolian_lib.py | 38 |
2 files changed, 79 insertions, 47 deletions
diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py index 55f4fea971..0693ebae05 100644 --- a/src/scripts/pyolian/eolian.py +++ b/src/scripts/pyolian/eolian.py | |||
@@ -37,6 +37,24 @@ _already_halted = False | |||
37 | 37 | ||
38 | ### Eolian Enums ############################################################ | 38 | ### Eolian Enums ############################################################ |
39 | 39 | ||
40 | class Eolian_Object_Type(IntEnum): | ||
41 | UNKNOWN = 0 | ||
42 | CLASS = 1 | ||
43 | TYPEDECL = 2 | ||
44 | STRUCT_FIELD = 3 | ||
45 | ENUM_FIELD = 4 | ||
46 | TYPE = 5 | ||
47 | VARIABLE = 6 | ||
48 | EXPRESSION = 7 | ||
49 | FUNCTION = 8 | ||
50 | FUNCTION_PARAMETER = 9 | ||
51 | EVENT = 10 | ||
52 | PART = 11 | ||
53 | IMPLEMENT = 12 | ||
54 | CONSTRUCTOR = 13 | ||
55 | DOCUMENTATION = 14 | ||
56 | DECLARATION = 15 | ||
57 | |||
40 | class Eolian_Function_Type(IntEnum): | 58 | class Eolian_Function_Type(IntEnum): |
41 | UNRESOLVED = 0 | 59 | UNRESOLVED = 0 |
42 | PROPERTY = 1 | 60 | PROPERTY = 1 |
@@ -630,7 +648,31 @@ class Namespace(object): | |||
630 | 648 | ||
631 | ### Eolian Classes ########################################################## | 649 | ### Eolian Classes ########################################################## |
632 | 650 | ||
633 | class Class(EolianBaseObject): | 651 | class Object(EolianBaseObject): |
652 | def __repr__(self): | ||
653 | return "<eolian.Object '{0.name}', {0.type!s}>".format(self) | ||
654 | |||
655 | @cached_property | ||
656 | def name(self): | ||
657 | return _str_to_py(lib.eolian_object_name_get(self._obj)) | ||
658 | |||
659 | @cached_property | ||
660 | def file(self): | ||
661 | return _str_to_py(lib.eolian_object_file_get(self._obj)) | ||
662 | |||
663 | @cached_property | ||
664 | def line(self): | ||
665 | return int(lib.eolian_object_line_get(self._obj)) | ||
666 | |||
667 | @cached_property | ||
668 | def column(self): | ||
669 | return int(lib.eolian_object_column_get(self._obj)) | ||
670 | |||
671 | @cached_property | ||
672 | def type(self): | ||
673 | return Eolian_Object_Type(lib.eolian_object_type_get(self._obj)) | ||
674 | |||
675 | class Class(Object): | ||
634 | def __repr__(self): | 676 | def __repr__(self): |
635 | return "<eolian.Class '{0.full_name}', {0.type!s}>".format(self) | 677 | return "<eolian.Class '{0.full_name}', {0.type!s}>".format(self) |
636 | 678 | ||
@@ -741,10 +783,6 @@ class Class(EolianBaseObject): | |||
741 | return '.'.join(self.namespaces) | 783 | return '.'.join(self.namespaces) |
742 | 784 | ||
743 | @cached_property | 785 | @cached_property |
744 | def file(self): | ||
745 | return _str_to_py(lib.eolian_class_file_get(self._obj)) | ||
746 | |||
747 | @cached_property | ||
748 | def ctor_enable(self): | 786 | def ctor_enable(self): |
749 | return bool(lib.eolian_class_ctor_enable_get(self._obj)) | 787 | return bool(lib.eolian_class_ctor_enable_get(self._obj)) |
750 | 788 | ||
@@ -779,7 +817,7 @@ class Class(EolianBaseObject): | |||
779 | return Iterator(Part, lib.eolian_class_parts_get(self._obj)) | 817 | return Iterator(Part, lib.eolian_class_parts_get(self._obj)) |
780 | 818 | ||
781 | 819 | ||
782 | class Part(EolianBaseObject): | 820 | class Part(Object): |
783 | def __repr__(self): | 821 | def __repr__(self): |
784 | return "<eolian.Part '{0.name}'>".format(self) | 822 | return "<eolian.Part '{0.name}'>".format(self) |
785 | 823 | ||
@@ -797,7 +835,7 @@ class Part(EolianBaseObject): | |||
797 | return Documentation(c_doc) if c_doc else None | 835 | return Documentation(c_doc) if c_doc else None |
798 | 836 | ||
799 | 837 | ||
800 | class Constructor(EolianBaseObject): | 838 | class Constructor(Object): |
801 | def __repr__(self): | 839 | def __repr__(self): |
802 | return "<eolian.Constructor '{0.full_name}', optional={0.is_optional}>".format(self) | 840 | return "<eolian.Constructor '{0.full_name}', optional={0.is_optional}>".format(self) |
803 | 841 | ||
@@ -818,7 +856,7 @@ class Constructor(EolianBaseObject): | |||
818 | return Class(lib.eolian_constructor_class_get(self._obj)) | 856 | return Class(lib.eolian_constructor_class_get(self._obj)) |
819 | 857 | ||
820 | 858 | ||
821 | class Event(EolianBaseObject): | 859 | class Event(Object): |
822 | def __repr__(self): | 860 | def __repr__(self): |
823 | return "<eolian.Event '{0.name}', c_name='{0.c_name}'>".format(self) | 861 | return "<eolian.Event '{0.name}', c_name='{0.c_name}'>".format(self) |
824 | 862 | ||
@@ -860,7 +898,7 @@ class Event(EolianBaseObject): | |||
860 | return bool(lib.eolian_event_is_restart(self._obj)) | 898 | return bool(lib.eolian_event_is_restart(self._obj)) |
861 | 899 | ||
862 | 900 | ||
863 | class Function(EolianBaseObject): | 901 | class Function(Object): |
864 | def __repr__(self): | 902 | def __repr__(self): |
865 | return "<eolian.Function '{0.name}'>".format(self) | 903 | return "<eolian.Function '{0.name}'>".format(self) |
866 | 904 | ||
@@ -1023,7 +1061,7 @@ class Function(EolianBaseObject): | |||
1023 | return Implement(c_impl) if c_impl else None | 1061 | return Implement(c_impl) if c_impl else None |
1024 | 1062 | ||
1025 | 1063 | ||
1026 | class Function_Parameter(EolianBaseObject): | 1064 | class Function_Parameter(Object): |
1027 | def __repr__(self): | 1065 | def __repr__(self): |
1028 | return "<eolian.Function_Parameter '{0.name}', type={0.type}," \ | 1066 | return "<eolian.Function_Parameter '{0.name}', type={0.type}," \ |
1029 | " optional={0.is_optional}, nullable={0.is_nullable}>".format(self) | 1067 | " optional={0.is_optional}, nullable={0.is_nullable}>".format(self) |
@@ -1064,7 +1102,7 @@ class Function_Parameter(EolianBaseObject): | |||
1064 | return Expression(c_expr) if c_expr else None | 1102 | return Expression(c_expr) if c_expr else None |
1065 | 1103 | ||
1066 | 1104 | ||
1067 | class Implement(EolianBaseObject): | 1105 | class Implement(Object): |
1068 | def __repr__(self): | 1106 | def __repr__(self): |
1069 | return "<eolian.Implement '{0.full_name}'>".format(self) | 1107 | return "<eolian.Implement '{0.full_name}'>".format(self) |
1070 | 1108 | ||
@@ -1117,7 +1155,7 @@ class Implement(EolianBaseObject): | |||
1117 | return not self.is_property | 1155 | return not self.is_property |
1118 | 1156 | ||
1119 | 1157 | ||
1120 | class Type(EolianBaseObject): | 1158 | class Type(Object): |
1121 | def __repr__(self): | 1159 | def __repr__(self): |
1122 | # return "<eolian.Type '{0.full_name}', type: {0.type!s}, c_type: '{0.c_type}'>".format(self) | 1160 | # return "<eolian.Type '{0.full_name}', type: {0.type!s}, c_type: '{0.c_type}'>".format(self) |
1123 | return "<eolian.Type '{0.full_name}', type={0.type!s}>".format(self) | 1161 | return "<eolian.Type '{0.full_name}', type={0.type!s}>".format(self) |
@@ -1194,10 +1232,6 @@ class Type(EolianBaseObject): | |||
1194 | return Class(c_cls) if c_cls else None | 1232 | return Class(c_cls) if c_cls else None |
1195 | 1233 | ||
1196 | @cached_property | 1234 | @cached_property |
1197 | def file(self): | ||
1198 | return _str_to_py(lib.eolian_type_file_get(self._obj)) | ||
1199 | |||
1200 | @cached_property | ||
1201 | def is_owned(self): | 1235 | def is_owned(self): |
1202 | return bool(lib.eolian_type_is_owned(self._obj)) | 1236 | return bool(lib.eolian_type_is_owned(self._obj)) |
1203 | 1237 | ||
@@ -1210,7 +1244,7 @@ class Type(EolianBaseObject): | |||
1210 | return bool(lib.eolian_type_is_ptr(self._obj)) | 1244 | return bool(lib.eolian_type_is_ptr(self._obj)) |
1211 | 1245 | ||
1212 | 1246 | ||
1213 | class Typedecl(EolianBaseObject): | 1247 | class Typedecl(Object): |
1214 | def __repr__(self): | 1248 | def __repr__(self): |
1215 | return "<eolian.Typedecl '{0.full_name}', type={0.type!s}>".format(self) | 1249 | return "<eolian.Typedecl '{0.full_name}', type={0.type!s}>".format(self) |
1216 | 1250 | ||
@@ -1223,10 +1257,6 @@ class Typedecl(EolianBaseObject): | |||
1223 | return _str_to_py(lib.eolian_typedecl_full_name_get(self._obj)) | 1257 | return _str_to_py(lib.eolian_typedecl_full_name_get(self._obj)) |
1224 | 1258 | ||
1225 | @cached_property | 1259 | @cached_property |
1226 | def file(self): | ||
1227 | return _str_to_py(lib.eolian_typedecl_file_get(self._obj)) | ||
1228 | |||
1229 | @cached_property | ||
1230 | def type(self): | 1260 | def type(self): |
1231 | return Eolian_Typedecl_Type(lib.eolian_typedecl_type_get(self._obj)) | 1261 | return Eolian_Typedecl_Type(lib.eolian_typedecl_type_get(self._obj)) |
1232 | 1262 | ||
@@ -1296,7 +1326,7 @@ class Typedecl(EolianBaseObject): | |||
1296 | return Function(c_func) if c_func else None | 1326 | return Function(c_func) if c_func else None |
1297 | 1327 | ||
1298 | 1328 | ||
1299 | class Enum_Type_Field(EolianBaseObject): | 1329 | class Enum_Type_Field(Object): |
1300 | def __repr__(self): | 1330 | def __repr__(self): |
1301 | return "<eolian.Enum_Type_Field '{0.name}', c_name='{0.c_name}'>".format(self) | 1331 | return "<eolian.Enum_Type_Field '{0.name}', c_name='{0.c_name}'>".format(self) |
1302 | 1332 | ||
@@ -1322,7 +1352,7 @@ class Enum_Type_Field(EolianBaseObject): | |||
1322 | return Documentation(c_doc) if c_doc else None | 1352 | return Documentation(c_doc) if c_doc else None |
1323 | 1353 | ||
1324 | 1354 | ||
1325 | class Struct_Type_Field(EolianBaseObject): | 1355 | class Struct_Type_Field(Object): |
1326 | def __repr__(self): | 1356 | def __repr__(self): |
1327 | return "<eolian.Struct_Type_Field '{0.name}', type={0.type!s}>".format(self) | 1357 | return "<eolian.Struct_Type_Field '{0.name}', type={0.type!s}>".format(self) |
1328 | 1358 | ||
@@ -1341,7 +1371,7 @@ class Struct_Type_Field(EolianBaseObject): | |||
1341 | return Documentation(c_doc) if c_doc else None | 1371 | return Documentation(c_doc) if c_doc else None |
1342 | 1372 | ||
1343 | 1373 | ||
1344 | class Expression(EolianBaseObject): | 1374 | class Expression(Object): |
1345 | def __repr__(self): | 1375 | def __repr__(self): |
1346 | return "<eolian.Expression type={0.type!s}, serialize='{0.serialize}'>".format(self) | 1376 | return "<eolian.Expression type={0.type!s}, serialize='{0.serialize}'>".format(self) |
1347 | 1377 | ||
@@ -1384,7 +1414,7 @@ class Expression(EolianBaseObject): | |||
1384 | return Expression(c_expr) if c_expr is not None else None | 1414 | return Expression(c_expr) if c_expr is not None else None |
1385 | 1415 | ||
1386 | 1416 | ||
1387 | class Variable(EolianBaseObject): | 1417 | class Variable(Object): |
1388 | def __repr__(self): | 1418 | def __repr__(self): |
1389 | return "<eolian.Variable '{0.full_name}', type={0.type!s}, file={0.file}>".format(self) | 1419 | return "<eolian.Variable '{0.full_name}', type={0.type!s}, file={0.file}>".format(self) |
1390 | 1420 | ||
@@ -1414,10 +1444,6 @@ class Variable(EolianBaseObject): | |||
1414 | return Expression(c_expr) if c_expr else None | 1444 | return Expression(c_expr) if c_expr else None |
1415 | 1445 | ||
1416 | @cached_property | 1446 | @cached_property |
1417 | def file(self): | ||
1418 | return _str_to_py(lib.eolian_variable_file_get(self._obj)) | ||
1419 | |||
1420 | @cached_property | ||
1421 | def base_type(self): | 1447 | def base_type(self): |
1422 | c_type = lib.eolian_variable_base_type_get(self._obj) | 1448 | c_type = lib.eolian_variable_base_type_get(self._obj) |
1423 | return Type(c_type) if c_type else None | 1449 | return Type(c_type) if c_type else None |
@@ -1432,7 +1458,7 @@ class Variable(EolianBaseObject): | |||
1432 | return Documentation(c_doc) if c_doc else None | 1458 | return Documentation(c_doc) if c_doc else None |
1433 | 1459 | ||
1434 | 1460 | ||
1435 | class Declaration(EolianBaseObject): | 1461 | class Declaration(Object): |
1436 | def __repr__(self): | 1462 | def __repr__(self): |
1437 | return "<eolian.Declaration '{0.name}'>".format(self) | 1463 | return "<eolian.Declaration '{0.name}'>".format(self) |
1438 | 1464 | ||
@@ -1466,7 +1492,7 @@ class _Eolian_Doc_Token_Struct(ctypes.Structure): | |||
1466 | ("text_end", c_char_p)] | 1492 | ("text_end", c_char_p)] |
1467 | 1493 | ||
1468 | 1494 | ||
1469 | class Documentation(EolianBaseObject): # OK (1 TODO Unit*) | 1495 | class Documentation(Object): # OK (1 TODO Unit*) |
1470 | # def __repr__(self): | 1496 | # def __repr__(self): |
1471 | # return "<eolian.Documentation '{0.name}'>".format(self) | 1497 | # return "<eolian.Documentation '{0.name}'>".format(self) |
1472 | 1498 | ||
diff --git a/src/scripts/pyolian/eolian_lib.py b/src/scripts/pyolian/eolian_lib.py index e4e1bc819e..1ea3898d58 100644 --- a/src/scripts/pyolian/eolian_lib.py +++ b/src/scripts/pyolian/eolian_lib.py | |||
@@ -235,11 +235,29 @@ lib.eolian_all_declarations_get.restype = c_void_p | |||
235 | lib.eolian_declaration_get_by_name.argtypes = [c_void_p, c_char_p] | 235 | lib.eolian_declaration_get_by_name.argtypes = [c_void_p, c_char_p] |
236 | lib.eolian_declaration_get_by_name.restype = c_void_p | 236 | lib.eolian_declaration_get_by_name.restype = c_void_p |
237 | 237 | ||
238 | ### Eolian_Class ############################################################ | 238 | ### Eolian_Object ########################################################### |
239 | |||
240 | # EAPI Eolian_Object_Type eolian_object_type_get(const Eolian_Object *obj); | ||
241 | lib.eolian_object_type_get.argtypes = [c_void_p] | ||
242 | lib.eolian_object_type_get.restype = c_int | ||
243 | |||
244 | # EAPI const char *eolian_object_file_get(const Eolian_Object *obj); | ||
245 | lib.eolian_object_file_get.argtypes = [c_void_p] | ||
246 | lib.eolian_object_file_get.restype = c_char_p | ||
247 | |||
248 | # EAPI int eolian_object_line_get(const Eolian_Object *obj); | ||
249 | lib.eolian_object_line_get.argtypes = [c_void_p] | ||
250 | lib.eolian_object_line_get.restype = c_int | ||
251 | |||
252 | # EAPI int eolian_object_column_get(const Eolian_Object *obj); | ||
253 | lib.eolian_object_column_get.argtypes = [c_void_p] | ||
254 | lib.eolian_object_column_get.restype = c_int | ||
239 | 255 | ||
240 | # EAPI Eina_Stringshare *eolian_class_file_get(const Eolian_Class *klass); | 256 | # EAPI const char *eolian_object_name_get(const Eolian_Object *obj); |
241 | lib.eolian_class_file_get.argtypes = [c_void_p,] | 257 | lib.eolian_object_name_get.argtypes = [c_void_p] |
242 | lib.eolian_class_file_get.restype = c_char_p | 258 | lib.eolian_object_name_get.restype = c_char_p |
259 | |||
260 | ### Eolian_Class ############################################################ | ||
243 | 261 | ||
244 | # EAPI Eina_Stringshare *eolian_class_full_name_get(const Eolian_Class *klass); | 262 | # EAPI Eina_Stringshare *eolian_class_full_name_get(const Eolian_Class *klass); |
245 | lib.eolian_class_full_name_get.argtypes = [c_void_p,] | 263 | lib.eolian_class_full_name_get.argtypes = [c_void_p,] |
@@ -608,10 +626,6 @@ lib.eolian_typedecl_enum_legacy_prefix_get.restype = c_char_p | |||
608 | lib.eolian_typedecl_documentation_get.argtypes = [c_void_p,] | 626 | lib.eolian_typedecl_documentation_get.argtypes = [c_void_p,] |
609 | lib.eolian_typedecl_documentation_get.restype = c_void_p | 627 | lib.eolian_typedecl_documentation_get.restype = c_void_p |
610 | 628 | ||
611 | # EAPI Eina_Stringshare *eolian_typedecl_file_get(const Eolian_Typedecl *tp); | ||
612 | lib.eolian_typedecl_file_get.argtypes = [c_void_p,] | ||
613 | lib.eolian_typedecl_file_get.restype = c_char_p | ||
614 | |||
615 | # EAPI const Eolian_Type *eolian_typedecl_base_type_get(const Eolian_Typedecl *tp); | 629 | # EAPI const Eolian_Type *eolian_typedecl_base_type_get(const Eolian_Typedecl *tp); |
616 | lib.eolian_typedecl_base_type_get.argtypes = [c_void_p,] | 630 | lib.eolian_typedecl_base_type_get.argtypes = [c_void_p,] |
617 | lib.eolian_typedecl_base_type_get.restype = c_void_p | 631 | lib.eolian_typedecl_base_type_get.restype = c_void_p |
@@ -658,10 +672,6 @@ lib.eolian_type_type_get.restype = c_int | |||
658 | lib.eolian_type_builtin_type_get.argtypes = [c_void_p,] | 672 | lib.eolian_type_builtin_type_get.argtypes = [c_void_p,] |
659 | lib.eolian_type_builtin_type_get.restype = c_int | 673 | lib.eolian_type_builtin_type_get.restype = c_int |
660 | 674 | ||
661 | # EAPI Eina_Stringshare *eolian_type_file_get(const Eolian_Type *tp); | ||
662 | lib.eolian_type_file_get.argtypes = [c_void_p,] | ||
663 | lib.eolian_type_file_get.restype = c_char_p | ||
664 | |||
665 | # EAPI const Eolian_Type *eolian_type_base_type_get(const Eolian_Type *tp); | 675 | # EAPI const Eolian_Type *eolian_type_base_type_get(const Eolian_Type *tp); |
666 | lib.eolian_type_base_type_get.argtypes = [c_void_p,] | 676 | lib.eolian_type_base_type_get.argtypes = [c_void_p,] |
667 | lib.eolian_type_base_type_get.restype = c_void_p | 677 | lib.eolian_type_base_type_get.restype = c_void_p |
@@ -754,10 +764,6 @@ lib.eolian_variable_type_get.restype = c_int | |||
754 | lib.eolian_variable_documentation_get.argtypes = [c_void_p,] | 764 | lib.eolian_variable_documentation_get.argtypes = [c_void_p,] |
755 | lib.eolian_variable_documentation_get.restype = c_void_p | 765 | lib.eolian_variable_documentation_get.restype = c_void_p |
756 | 766 | ||
757 | # EAPI Eina_Stringshare *eolian_variable_file_get(const Eolian_Variable *var); | ||
758 | lib.eolian_variable_file_get.argtypes = [c_void_p,] | ||
759 | lib.eolian_variable_file_get.restype = c_char_p | ||
760 | |||
761 | # EAPI const Eolian_Type *eolian_variable_base_type_get(const Eolian_Variable *var); | 767 | # EAPI const Eolian_Type *eolian_variable_base_type_get(const Eolian_Variable *var); |
762 | lib.eolian_variable_base_type_get.argtypes = [c_void_p,] | 768 | lib.eolian_variable_base_type_get.argtypes = [c_void_p,] |
763 | lib.eolian_variable_base_type_get.restype = c_void_p | 769 | lib.eolian_variable_base_type_get.restype = c_void_p |