mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
# Copyright (c) 2018-2020 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 stl_containers
|
|
import simple_class_obj
|
|
sys.path.append(os.getcwd())
|
|
|
|
SIZE_OF_INT = 4
|
|
SIZE_OF_BOOL = 1
|
|
SIZE_OF_INT64 = 8
|
|
SIZE_OF_UINT256 = 32
|
|
|
|
|
|
def get_special_type_obj(gobj):
|
|
obj_type = gobj.type.strip_typedefs()
|
|
if stl_containers.VectorObj.is_this_type(obj_type):
|
|
return stl_containers.VectorObj(gobj)
|
|
if stl_containers.ListObj.is_this_type(obj_type):
|
|
return stl_containers.ListObj(gobj)
|
|
if stl_containers.PairObj.is_this_type(obj_type):
|
|
return stl_containers.PairObj(gobj)
|
|
if stl_containers.MapObj.is_this_type(obj_type):
|
|
return stl_containers.MapObj(gobj)
|
|
if stl_containers.SetObj.is_this_type(obj_type):
|
|
return stl_containers.SetObj(gobj)
|
|
if simple_class_obj.SimpleClassObj.is_this_type(obj_type):
|
|
return simple_class_obj.SimpleClassObj(gobj)
|
|
return False
|
|
|
|
|
|
def is_special_type(obj_type):
|
|
if stl_containers.VectorObj.is_this_type(obj_type):
|
|
return True
|
|
if stl_containers.ListObj.is_this_type(obj_type):
|
|
return True
|
|
if stl_containers.PairObj.is_this_type(obj_type):
|
|
return True
|
|
if stl_containers.MapObj.is_this_type(obj_type):
|
|
return True
|
|
if stl_containers.SetObj.is_this_type(obj_type):
|
|
return True
|
|
if simple_class_obj.SimpleClassObj.is_this_type(obj_type):
|
|
return True
|
|
return False
|
|
|
|
|
|
def get_instance_size(gobj):
|
|
obj = get_special_type_obj(gobj)
|
|
if not obj:
|
|
return gobj.type.sizeof
|
|
return obj.get_used_size()
|