summaryrefslogtreecommitdiff
path: root/src/scripts
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2018-03-08 22:48:01 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2018-03-08 22:48:01 +0100
commit10448fec97997f47944b4cfcc36b2f629be81eab (patch)
tree6c99049f50d4abab1f1bfb38237a2107b339183f /src/scripts
parent59aabb0945761261c80a02b5b8a05e5b48773e70 (diff)
pyolian: add Eolian_Object APIs and remove obsolete file_get ones
Diffstat (limited to 'src/scripts')
-rw-r--r--src/scripts/pyolian/eolian.py88
-rw-r--r--src/scripts/pyolian/eolian_lib.py38
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
40class 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
40class Eolian_Function_Type(IntEnum): 58class 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
633class Class(EolianBaseObject): 651class 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
675class 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
782class Part(EolianBaseObject): 820class 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
800class Constructor(EolianBaseObject): 838class 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
821class Event(EolianBaseObject): 859class 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
863class Function(EolianBaseObject): 901class 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
1026class Function_Parameter(EolianBaseObject): 1064class 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
1067class Implement(EolianBaseObject): 1105class 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
1120class Type(EolianBaseObject): 1158class 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
1213class Typedecl(EolianBaseObject): 1247class 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
1299class Enum_Type_Field(EolianBaseObject): 1329class 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
1325class Struct_Type_Field(EolianBaseObject): 1355class 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
1344class Expression(EolianBaseObject): 1374class 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
1387class Variable(EolianBaseObject): 1417class 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
1435class Declaration(EolianBaseObject): 1461class 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
1469class Documentation(EolianBaseObject): # OK (1 TODO Unit*) 1495class 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
235lib.eolian_declaration_get_by_name.argtypes = [c_void_p, c_char_p] 235lib.eolian_declaration_get_by_name.argtypes = [c_void_p, c_char_p]
236lib.eolian_declaration_get_by_name.restype = c_void_p 236lib.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);
241lib.eolian_object_type_get.argtypes = [c_void_p]
242lib.eolian_object_type_get.restype = c_int
243
244# EAPI const char *eolian_object_file_get(const Eolian_Object *obj);
245lib.eolian_object_file_get.argtypes = [c_void_p]
246lib.eolian_object_file_get.restype = c_char_p
247
248# EAPI int eolian_object_line_get(const Eolian_Object *obj);
249lib.eolian_object_line_get.argtypes = [c_void_p]
250lib.eolian_object_line_get.restype = c_int
251
252# EAPI int eolian_object_column_get(const Eolian_Object *obj);
253lib.eolian_object_column_get.argtypes = [c_void_p]
254lib.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);
241lib.eolian_class_file_get.argtypes = [c_void_p,] 257lib.eolian_object_name_get.argtypes = [c_void_p]
242lib.eolian_class_file_get.restype = c_char_p 258lib.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);
245lib.eolian_class_full_name_get.argtypes = [c_void_p,] 263lib.eolian_class_full_name_get.argtypes = [c_void_p,]
@@ -608,10 +626,6 @@ lib.eolian_typedecl_enum_legacy_prefix_get.restype = c_char_p
608lib.eolian_typedecl_documentation_get.argtypes = [c_void_p,] 626lib.eolian_typedecl_documentation_get.argtypes = [c_void_p,]
609lib.eolian_typedecl_documentation_get.restype = c_void_p 627lib.eolian_typedecl_documentation_get.restype = c_void_p
610 628
611# EAPI Eina_Stringshare *eolian_typedecl_file_get(const Eolian_Typedecl *tp);
612lib.eolian_typedecl_file_get.argtypes = [c_void_p,]
613lib.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);
616lib.eolian_typedecl_base_type_get.argtypes = [c_void_p,] 630lib.eolian_typedecl_base_type_get.argtypes = [c_void_p,]
617lib.eolian_typedecl_base_type_get.restype = c_void_p 631lib.eolian_typedecl_base_type_get.restype = c_void_p
@@ -658,10 +672,6 @@ lib.eolian_type_type_get.restype = c_int
658lib.eolian_type_builtin_type_get.argtypes = [c_void_p,] 672lib.eolian_type_builtin_type_get.argtypes = [c_void_p,]
659lib.eolian_type_builtin_type_get.restype = c_int 673lib.eolian_type_builtin_type_get.restype = c_int
660 674
661# EAPI Eina_Stringshare *eolian_type_file_get(const Eolian_Type *tp);
662lib.eolian_type_file_get.argtypes = [c_void_p,]
663lib.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);
666lib.eolian_type_base_type_get.argtypes = [c_void_p,] 676lib.eolian_type_base_type_get.argtypes = [c_void_p,]
667lib.eolian_type_base_type_get.restype = c_void_p 677lib.eolian_type_base_type_get.restype = c_void_p
@@ -754,10 +764,6 @@ lib.eolian_variable_type_get.restype = c_int
754lib.eolian_variable_documentation_get.argtypes = [c_void_p,] 764lib.eolian_variable_documentation_get.argtypes = [c_void_p,]
755lib.eolian_variable_documentation_get.restype = c_void_p 765lib.eolian_variable_documentation_get.restype = c_void_p
756 766
757# EAPI Eina_Stringshare *eolian_variable_file_get(const Eolian_Variable *var);
758lib.eolian_variable_file_get.argtypes = [c_void_p,]
759lib.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);
762lib.eolian_variable_base_type_get.argtypes = [c_void_p,] 768lib.eolian_variable_base_type_get.argtypes = [c_void_p,]
763lib.eolian_variable_base_type_get.restype = c_void_p 769lib.eolian_variable_base_type_get.restype = c_void_p