コード例 #1
0
ファイル: _abi1reader.py プロジェクト: Maroc-OS/EcaFretni
def _analyzeProtocol(machO, d, analyzer, preped, protoListPtrs):
	"""Analyze a prepared ``old_protocol`` struct, and return a tuple of
	:class:`~objc.protocol.Protocol`\\s and an iterable of addresses of
	protocols it has adopted."""

	(namePtr, instMethods, classMethods) = preped
	
	name = d(namePtr)
	proto = Protocol(name)
	
	proto.addClassMethods(map(analyzer, reversed(classMethods)))
	proto.addMethods(map(analyzer, reversed(instMethods)))
	
	protocolRefs = _readProtocolRefListsAt(machO, protoListPtrs)
	
	return (proto, protocolRefs)
コード例 #2
0
ファイル: _abi2reader.py プロジェクト: Maroc-OS/EcaFretni
def readProtocol(machO, vmaddr):
	"""Peek a ``protocol_t`` at *offset*. Returns a tuple of
	:class:`~objc.protocol.Protocol` and an iterable of protocol addresses it is
	adopting."""

	#	typedef struct protocol_t {
	#		id isa;
	#		const char *name;
	#		struct protocol_list_t *protocols;
	#		method_list_t *instanceMethods;
	#		method_list_t *classMethods;
	#		method_list_t *optionalInstanceMethods;
	#		method_list_t *optionalClassMethods;
	#		struct objc_property_list *instanceProperties;
	#	} protocol_t;
	
	pos = machO.fromVM(vmaddr) + machO.origin
	(_, namePtr, protocolListPtr, instMethodsPtr, classMethodsPtr, optInstMethodsPtr, optClassMethodsPtr, propsPtr) = peekStruct(machO.file, machO.makeStruct('8^'), position=pos)
	
	name = machO.derefString(namePtr)
	protocolRefs = _readProtocolRefListAt(machO, protocolListPtr)
	
	proto = Protocol(name)
	proto.addClassMethods(readMethodListAt(machO, classMethodsPtr, optional=False))
	proto.addClassMethods(readMethodListAt(machO, optClassMethodsPtr, optional=True))
	proto.addMethods(readMethodListAt(machO, instMethodsPtr, optional=False))
	proto.addMethods(readMethodListAt(machO, optInstMethodsPtr, optional=True))

	proto.addProperties(readPropertyListAt(machO, propsPtr))

	return (proto, protocolRefs)
コード例 #3
0
def readProtocol(machO, vmaddr):
	"""Peek a ``protocol_t`` at *offset*. Returns a tuple of
	:class:`~objc.protocol.Protocol` and an iterable of protocol addresses it is
	adopting."""

	#	typedef struct protocol_t {
	#		id isa;
	#		const char *name;
	#		struct protocol_list_t *protocols;
	#		method_list_t *instanceMethods;
	#		method_list_t *classMethods;
	#		method_list_t *optionalInstanceMethods;
	#		method_list_t *optionalClassMethods;
	#		struct objc_property_list *instanceProperties;
	#	} protocol_t;
	
	pos = machO.fromVM(vmaddr) + machO.origin
	(_, namePtr, protocolListPtr, instMethodsPtr, classMethodsPtr, optInstMethodsPtr, optClassMethodsPtr, propsPtr) = peekStruct(machO.file, machO.makeStruct('8^'), position=pos)
	
	name = machO.derefString(namePtr)
	protocolRefs = _readProtocolRefListAt(machO, protocolListPtr)
	
	proto = Protocol(name)
	proto.addClassMethods(readMethodListAt(machO, classMethodsPtr, optional=False))
	proto.addClassMethods(readMethodListAt(machO, optClassMethodsPtr, optional=True))
	proto.addMethods(readMethodListAt(machO, instMethodsPtr, optional=False))
	proto.addMethods(readMethodListAt(machO, optInstMethodsPtr, optional=True))

	proto.addProperties(readPropertyListAt(machO, propsPtr))

	return (proto, protocolRefs)