# Path: cemu/memory.py
# class MemoryPermission:
# class MemorySection:
#     def __init__(self, perm: str):
#     def parse(self, perm: str) -> None:
#     def __str__(self) -> str:
#     def short(self) -> str:
#     def __init__(self, name: str, addr: int, size: int, perm: str, __file=None):
#     def __str__(self) -> str:
#     def export(self) -> MemoryLayoutEntryType:
#     def __contains__(self, addr: int) -> bool:
# 
# Path: cemu/utils.py
# def ishex(x:string) -> bool:
#     if x.startswith("0x") or x.startswith("0X"):
#         x = x[2:]
#     return all([c in string.hexdigits for c in x])


import os
from PyQt5.QtCore import (
    Qt,
    QVariant,
    QStringListModel
)
from PyQt5.QtWidgets import (
    QVBoxLayout,
    QTableWidget,
    QHeaderView,
    QTableWidgetItem,
    QDockWidget,
    QWidget,
    QTableView,
    QListView,
    QPushButton,
    QGridLayout,
    QHBoxLayout,
    QLabel,
    QLineEdit,
    QMessageBox,
    QCheckBox,
)
from cemu.memory import (
    MemorySection,
    MemoryLayoutEntryType,
)
from cemu.utils import (
    ishex,
)
from typing import List, Tuple, Any







class MemoryMappingWidget(QDockWidget):
    def __init__(self, parent, *args, **kwargs):
        super(MemoryMappingWidget, self).__init__("Memory map", parent)
        self.log = self.parentWidget().log
        layout = QVBoxLayout()
        self.__memory_mapping = [
            MemorySection(".text",  0x00004000, 0x1000, "READ|EXEC"),
            MemorySection(".data",  0x00005000, 0x1000, "READ|WRITE"),
            MemorySection(".stack", 0x00006000, 0x4000, "READ|WRITE"),

# Path: cemu/memory.py
# class MemoryPermission:
# class MemorySection:
#     def __init__(self, perm: str):
#     def parse(self, perm: str) -> None:
#     def __str__(self) -> str:
#     def short(self) -> str:
#     def __init__(self, name: str, addr: int, size: int, perm: str, __file=None):
#     def __str__(self) -> str:
#     def export(self) -> MemoryLayoutEntryType:
#     def __contains__(self, addr: int) -> bool:
# 
# Path: cemu/utils.py
# def ishex(x:string) -> bool:
#     if x.startswith("0x") or x.startswith("0X"):
#         x = x[2:]
#     return all([c in string.hexdigits for c in x])


# Path: cemu/ui/mapping.py
import os
from PyQt5.QtCore import (
    Qt,
    QVariant,
    QStringListModel
)
from PyQt5.QtWidgets import (
    QVBoxLayout,
    QTableWidget,
    QHeaderView,
    QTableWidgetItem,
    QDockWidget,
    QWidget,
    QTableView,
    QListView,
    QPushButton,
    QGridLayout,
    QHBoxLayout,
    QLabel,
    QLineEdit,
    QMessageBox,
    QCheckBox,
)
from cemu.memory import (
    MemorySection,
    MemoryLayoutEntryType,
)
from cemu.utils import (
    ishex,
)
from typing import List, Tuple, Any








class MemoryMappingWidget(QDockWidget):
    def __init__(self, parent, *args, **kwargs):
        super(MemoryMappingWidget, self).__init__("Memory map", parent)
        self.log = self.parentWidget().log
        layout = QVBoxLayout()
        self.__memory_mapping = [
            MemorySection(".text",  0x00004000, 0x1000, "READ|EXEC"),
            MemorySection(".data",  0x00005000, 0x1000, "READ|WRITE"),
            MemorySection(".stack", 0x00006000, 0x4000, "READ|WRITE"),

            MemorySection(".misc",  0x0000a000, 0x1000, "ALL"),