mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 21:12:48 +01:00
097a8e7196
that's a result of: contrib/devtools/copyright_header.py update ./ it is not scripted diff, because it works differentlly on my localhost and in CI: CI doesn't want to use git commit date which is mocked to 30th Dec of 2023
58 lines
2.0 KiB
Python
58 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
# Copyright (c) 2018-2023 The Dash Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
#
|
|
|
|
import sys
|
|
import os
|
|
import common_helpers
|
|
sys.path.append(os.getcwd())
|
|
|
|
|
|
simple_types = ["CMasternode", "CMasternodeVerification",
|
|
"CMasternodeBroadcast", "CMasternodePing",
|
|
"CMasternodeMan", "CDarksendQueue", "CDarkSendEntry",
|
|
"CTransaction", "CMutableTransaction", "CCoinJoinBaseSession",
|
|
"CCoinJoinBaseManager", "CCoinJoinClientSession",
|
|
"CCoinJoinClientManager", "CCoinJoinServer", "CMasternodePayments",
|
|
"CMasternodePaymentVote", "CMasternodeBlockPayees",
|
|
"CMasternodePayee", "CInstantSend", "CTxLockRequest",
|
|
"CTxLockVote", "CTxLockCandidate", "COutPoint",
|
|
"COutPointLock", "CSporkManager", "CMasternodeSync",
|
|
"CGovernanceManager", "CRateCheckBuffer", "CGovernanceObject",
|
|
"CGovernanceVote", "CGovernanceObjectVoteFile"]
|
|
|
|
simple_templates = ["CacheMultiMap", "CacheMap"]
|
|
|
|
|
|
class SimpleClassObj:
|
|
|
|
def __init__ (self, gobj):
|
|
self.obj = gobj
|
|
|
|
@classmethod
|
|
def is_this_type(cls, obj_type):
|
|
str_type = str(obj_type)
|
|
if str_type in simple_types:
|
|
return True
|
|
for templ in simple_templates:
|
|
if str_type.find(templ + "<") == 0:
|
|
return True
|
|
return False
|
|
|
|
def get_used_size(self):
|
|
size = 0
|
|
fields = self.obj.type.fields()
|
|
for f in fields:
|
|
# check if it is static field
|
|
if not hasattr(f, "bitpos"):
|
|
continue
|
|
# process base class size
|
|
if f.is_base_class:
|
|
size += common_helpers.get_instance_size(self.obj.cast(f.type.strip_typedefs()))
|
|
continue
|
|
# process simple field
|
|
size += common_helpers.get_instance_size(self.obj[f.name])
|
|
return size
|