File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33
44class CEnum (AbstractCEnum ):
5- ...
5+ @classmethod
6+ def sizeof (cls ) -> int :
7+ "Type size (in bytes)"
8+ return cls .__size__
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ class HtmlFont(CEnum):
2121 __def__ = """
2222 #define NONE 0
2323
24- enum htmlfont {
24+ enum HtmlFont {
2525 HTMLFONT_NONE = NONE,
2626 HTMLFONT_BOLD,
2727 HTMLFONT_ITALIC,
@@ -87,4 +87,14 @@ def test_struct_with_enum():
8787 s1 = StructWithEnum ()
8888 s1 .unpack (packed )
8989 assert s1 .font == HtmlFont .HTMLFONT_NONE
90- assert s1 .font_size == 20
90+
91+
92+ def test_sizeof ():
93+ assert cstruct .sizeof ("enum Dummy" ) == 4
94+ assert cstruct .sizeof ("enum HtmlFont" ) == 2
95+
96+
97+ # def test_type():
98+ # color = cstruct.parse("enum Color : short { red, green, blue };")
99+ # assert color.__size__ == 2
100+ # assert cstruct.sizeof("enum Color") == 2
You can’t perform that action at this time.
0 commit comments