本文整理匯總了Python中haystack.config.Config.get_word_size方法的典型用法代碼示例。如果您正苦於以下問題:Python Config.get_word_size方法的具體用法?Python Config.get_word_size怎麽用?Python Config.get_word_size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類haystack.config.Config
的用法示例。
在下文中一共展示了Config.get_word_size方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: HAYSTACK_POINTER
# 需要導入模塊: from haystack.config import Config [as 別名]
# 或者: from haystack.config.Config import get_word_size [as 別名]
def HAYSTACK_POINTER(cls):
# check cls as ctypes obj
if cls is None: # VOID
cls = type(None)# ctypes.c_void_p # ctypes.c_ulong
clsname = 'c_void'
else:
fake_ptr_base_type = Config.WORDTYPE # 4 or 8 len
# create object that is a pointer ( see model.isPointer )
clsname = cls.__name__
import _ctypes
klass = type('haystack.model.LP_%d_%s'%(Config.WORDSIZE, clsname),( _ctypes._SimpleCData,),{'_type_': Config.get_word_type_char(), '_subtype_': cls, '_sub_addr_': lambda x: x.value, '__repr__': lambda x: '%s(%d)'%(clsname,x.value)}) #, '__str__': lambda x: str(x.value)
#klass = type('haystack.model.LP_%d_%s'%(Config.WORDSIZE, clsname),( Config.WORDTYPE,),{'_subtype_': cls, '_sub_addr_': lambda x: x.value, '__repr__': lambda x: '%s(%d)'%(clsname,x.value)}) #, '__str__': lambda x: str(x.value)
klass._sub_addr_ = property(klass._sub_addr_)
return klass
if Config.get_word_size() != ctypes.sizeof(ctypes.c_void_p):
log.warning('Changing POINTER size to %d bytes'%(Config.get_word_size()))
ctypes.POINTER = HAYSTACK_POINTER
#0xbc32f5c7L
# The book registers all haystack modules, and classes, and can keep
# some pointer refs on memory allocated within special cases...
# see ctypes._pointer_type_cache , _reset_cache()
class _book(object):
modules = set()
classes = dict()
refs = dict()
def __init__(self):
pass
def addModule(self, mod):
self.modules.add(mod)