Esempio n. 1
0
Protocol *objc_allocateProtocol(const char *name)
{
	if (objc_getProtocol(name) != NULL) { return NULL; }
	Protocol *p = calloc(1, sizeof(Protocol2));
	p->name = strdup(name);
	return p;
}
Esempio n. 2
0
Protocol *objc_allocateProtocol(const char *name)
{
	if (objc_getProtocol(name) != NULL) { return NULL; }
	Protocol *p = (Protocol*)class_createInstance((Class)incompleteProtocolClass(), 0);
	p->name = strdup(name);
	return p;
}
Esempio n. 3
0
void objc_registerProtocol(Protocol *proto)
{
	if (NULL == proto) { return; }
	LOCK_RUNTIME_FOR_SCOPE();
	if (objc_getProtocol(proto->name) != NULL) { return; }
	if (nil != proto->isa) { return; }
	proto->isa = ObjC2ProtocolClass;
	protocol_table_insert((struct objc_protocol2*)proto);
}
Esempio n. 4
0
void AddClassProtocols(Class conv, old_protocol_list* list)
{
	for (long i = 0; i < list->count; i++)
	{
		Protocol* p = objc_getProtocol(list->list[i]->name);
		assert(p != nullptr);
		class_addProtocol(conv, p);
	}
}
Esempio n. 5
0
void AddClassProtocols(Class c, const protocol_list_t* list, intptr_t slide)
{
	for (size_t i = 0; i < list->count; i++)
	{
		const char* name = list->elem(i, slide)->name;
		Protocol* p = objc_getProtocol(name);
		assert(p != nullptr);
		class_addProtocol(c, p);
	}
}
Esempio n. 6
0
Protocol* RegisterProtocol(const protocol_t* prot, intptr_t slide)
{
	Protocol *existingProtocol = objc_getProtocol(prot->name);

	// Return existing protocols
	if (existingProtocol)
	{
		LOG << "Found existing ObjC Protocol: " << prot->name << std::endl;
		return existingProtocol;
	}

	LOG << "Processing ObjC Protocol: " << prot->name << std::endl;
	Protocol* conv = objc_allocateProtocol(prot->name);
	size_t methodIndex = 0;

	if (prot->protocols)
	{
		for (size_t i = 0; i < prot->protocols->count; i++)
		{
			const char* name = prot->protocols->elem(i, slide)->name;
			protocol_addProtocol(conv, objc_getProtocol(name));
		}
	}

	if (prot->methods)
		RegisterProtocolMethods(conv, prot->methods, prot->extMethTypes, methodIndex, true, true);
	if (prot->staticMethods)
		RegisterProtocolMethods(conv, prot->staticMethods, prot->extMethTypes, methodIndex, true, false);
	if (prot->optMethods)
		RegisterProtocolMethods(conv, prot->optMethods, prot->extMethTypes, methodIndex, false, true);
	if (prot->optStaticMethods)
		RegisterProtocolMethods(conv, prot->optStaticMethods, prot->extMethTypes, methodIndex, false, false);

	if (prot->properties)
		ConvertProperties(prot->properties, [conv](const char* name, const objc_property_attribute_t* attr, unsigned int count) { protocol_addProperty(conv, name, attr, count, true, true);  });
	
	objc_registerProtocol(conv);
	return conv;
}