大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
实现原理
我们提供的服务有:成都网站建设、成都网站制作、微信公众号开发、网站优化、网站认证、开平ssl等。为上1000+企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的开平网站制作公司Category和Class Extension的区别
Category添加的实例方法是存储在其对应的类对象里,类方法存储在其对应的元类对象里
Category添加的方法是在runtime过程中动态添加的
Category编译完成后结构
多个分类
int mcount = 0;
int i = cats->count; // cats 为分类数组
while (i--) {
auto& entry = cats->list[i];
method_list_t *mlist = entry.cat->methodsFoMeta(isMeta);
mlists[mcount++] = mlist;
// 后编译的分类方法先取出来添加到方法
// ...
}
struct _category_t {
const char *name;
struct _class_t *cls;
const struct _method_list_t *instance_methods;
const struct _method_list_t *class_methods;
const struct _protocol_list_t *protocols;
const struct _prop_list_t *properties;
};
void attachList(List* const * addedLists, uint32_t addedCount) {
if (addedCount == 0) return;
if (haveArray()) {
uint32_t oldCount = array()->count;
uint32_t newCount = oldCount + addedCount;
setArray((array_t *)realloc(array(), array_t::byteSize(newCount)));
array()->count = newCount;
memmove(array()->lists, addedLists, addedCount * sizeof(array()->lists[0]));
memcopy(array()->lists, addedLists, addedCount * sizeof(array()->lists[0]));
}
}
void attachLists(List* const * addedLists, uint32_t addedCount) {
if (addedCount == 0) return;
if (hasArray()) {
// many lists ->many lists
uint32_t oldCount = array()->count;
uint32_t newCount = oldCount + addedCount;
array_t *newArray = (array_t *)malloc(array_t::byteSize(newCount));
newArray->count = newCount;
array()->count = newCount;
for (int i = oldCount - 1; i >= 0; i--)
newArray->lists[i + addedCount] = array()->lists[i];
for (unsigned i = 0; i< addedCount; i++)
newArray->lists[i] = addedLists[i];
free(array());
setArray(newArray);
validate();
}
}
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧