Skip to content

Commit

Permalink
Update metadata generator to support new names for ambiguous declarat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
ivanbuhov authored and jasssonpet committed Sep 11, 2015
1 parent 03c8f38 commit d496dc0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/NativeScript/GlobalObject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,20 @@ static EncodedJSValue JSC_HOST_CALL collectGarbage(ExecState* execState) {
CString protocolName = protocol_getName(aProtocol);
const Meta* meta = MetaFile::instance()->globalTable()->findMeta(protocolName.data());
if (meta && meta->type() != MetaType::ProtocolType) {
protocolName = WTF::String::format("%sProtocol", protocolName.data()).utf8();
meta = MetaFile::instance()->globalTable()->findMeta(protocolName.data());
WTF::String newProtocolname = WTF::String::format("%sProtocol", protocolName.data());

size_t protocolIndex = 2;
while (objc_getProtocol(newProtocolname.utf8().data())) {
newProtocolname = WTF::String::format("%sProtocol%d", protocolName.data(), protocolIndex++);
}

meta = MetaFile::instance()->globalTable()->findMeta(newProtocolname.utf8().data());
}
ASSERT(meta && meta->type() == MetaType::ProtocolType);

ObjCProtocolWrapper* protocolWrapper = ObjCProtocolWrapper::create(this->vm(), ObjCProtocolWrapper::createStructure(this->vm(), this, this->objectPrototype()), static_cast<const ProtocolMeta*>(meta), aProtocol);
this->_objCProtocolWrappers.insert(std::pair<const Protocol*, Strong<ObjCProtocolWrapper>>(aProtocol, Strong<ObjCProtocolWrapper>(this->vm(), protocolWrapper)));
this->putDirectWithoutTransition(this->vm(), Identifier::fromString(this->globalExec(), protocolName.data()), protocolWrapper, DontDelete | ReadOnly);
this->_objCProtocolWrappers.insert({ aProtocol, Strong<ObjCProtocolWrapper>(this->vm(), protocolWrapper) });
this->putDirectWithoutTransition(this->vm(), Identifier::fromString(this->globalExec(), meta->jsName()), protocolWrapper, DontDelete | ReadOnly);

return protocolWrapper;
}
Expand Down
2 changes: 1 addition & 1 deletion src/metadata-generator

0 comments on commit d496dc0

Please sign in to comment.