-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleMetaMeta.py
More file actions
46 lines (34 loc) · 1.41 KB
/
ExampleMetaMeta.py
File metadata and controls
46 lines (34 loc) · 1.41 KB
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
# SPDX-FileCopyrightText: 2020-2023 Jochem Rutgers
#
# SPDX-License-Identifier: MPL-2.0
from collections import namedtuple
ExampleMetaObjectMeta = namedtuple('ExampleMetaObjectMeta', ['name', 'cname', 'type', 'ctype', 'size', 'isfunction', 'f', 'offset', 'init', 'axi'])
class ExampleMetaMeta(object):
def __init__(self):
self._objects = [
ExampleMetaObjectMeta('some int', 'some_int', 'int32', 'int32_t', 4, False, None, 16, int(42), 0),
ExampleMetaObjectMeta('a double', 'a_double', 'double', 'double', 8, False, None, 0, float('1.618'), None),
ExampleMetaObjectMeta('world', 'world', 'string', 'char', 7, False, None, 8, 'hello', None)]
@property
def name(self):
return 'ExampleMeta'
@property
def hash(self):
return '96cc75d260a03f4931816b2bc0824eed28faa9ae'
@property
def objects(self):
return self._objects
@property
def functions(self):
return filter(lambda o: o.isfunction, self._objects)
@property
def variables(self):
return filter(lambda o: not o.isfunction, self._objects)
def __len__(self):
return len(self._objects)
def __getitem__(self, key):
return next(filter(lambda o: o.name == key, self._objects))
def __getattr__(self, name):
return next(filter(lambda o: o.cname == name, self._objects))
def __iter__(self):
return iter(self._objects)