Handle big endian bitfields correctly

This commit is contained in:
Jerry James 2023-09-13 08:31:22 -06:00
parent 3cd5daf025
commit 0c02195510
No known key found for this signature in database
GPG key ID: 757AADA178D4C91A
2 changed files with 15 additions and 5 deletions

View file

@ -18,6 +18,7 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import os
import sys
import typing as T
from functools import cached_property
@ -948,8 +949,8 @@ class Repository(GirNode):
return self.lookup_namespace(ns).get_type(dir_entry.DIR_ENTRY_NAME)
def _resolve_type_id(self, type_id: int) -> GirType:
if type_id & 0xFFFFFF == 0:
type_id = (type_id >> 27) & 0x1F
if type_id & (0xFFFFFF if sys.byteorder == "little" else 0xFFFFFF00) == 0:
type_id = ((type_id >> 27) if sys.byteorder == "little" else type_id) & 0x1F
# simple type
if type_id == typelib.TYPE_BOOLEAN:
return BoolType()